* 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:
ACHRAF TAITAI 2024-04-11 06:57:54 +02:00 committed by GitHub
parent 661238c1b2
commit c4a14c6931
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}