Bael 7762 (#16321)
* BAEL-7765: How to fix JsonParseException: Unexpected character (code 115) when parsing unquoted JSON in Jackson * BAEL-7762: Specify logback.xml Location * Update LogbackConfiguration.java * BAEL-7762: Specify logback.xml Location * BAEL-7762: TEST * BAEL-7762: TEST --------- Co-authored-by: Grzegorz Piwowarek <gpiwowarek@gmail.com>
This commit is contained in:
parent
661238c1b2
commit
c4a14c6931
|
@ -0,0 +1,11 @@
|
|||
package com.baeldung.logging;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class LogbackConfiguration {
|
||||
public void setLogbackConfigurationFile(String path) {
|
||||
System.setProperty("logback.configurationFile", path);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.baeldung.logging;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = {LogbackConfiguration.class})
|
||||
public class LogbackConfigurationUnitTest {
|
||||
|
||||
@Autowired
|
||||
LogbackConfiguration logbackConfiguration;
|
||||
|
||||
@Test
|
||||
public void givenLogbackConfigurationFile_whenSettingLogbackConfiguration_thenFileLocationSet() {
|
||||
// Set the expected logback.xml location
|
||||
String expectedLocation = "/test/path/to/logback.xml";
|
||||
// Call the method to set the logback configuration file
|
||||
logbackConfiguration.setLogbackConfigurationFile(expectedLocation);
|
||||
// Verify that the system property is correctly set
|
||||
assertThat(System.getProperty("logback.configurationFile")).isEqualTo(expectedLocation);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue