BAEL-1970 fixed formatting

This commit is contained in:
mprevisic 2019-04-12 09:13:59 +02:00
parent c3bd97f39a
commit 6ae1e85d13
1 changed files with 33 additions and 33 deletions

View File

@ -22,49 +22,49 @@ import org.springframework.test.context.junit4.SpringRunner;
@ActiveProfiles("logback-test")
public class LogbackTestLogLevelIntegrationTest {
@Autowired
private TestRestTemplate restTemplate;
@Autowired
private TestRestTemplate restTemplate;
@Rule
public OutputCapture outputCapture = new OutputCapture();
@Rule
public OutputCapture outputCapture = new OutputCapture();
private String baseUrl = "/testLogLevel";
private String baseUrl = "/testLogLevel";
@Test
public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
@Test
public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputContainsLogForOurPackage("DEBUG");
}
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputContainsLogForOurPackage("DEBUG");
}
@Test
public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
@Test
public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputDoesntContainLogForOtherPackages("DEBUG");
}
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputDoesntContainLogForOtherPackages("DEBUG");
}
@Test
public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintErrorLogs() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
@Test
public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintErrorLogs() {
ResponseEntity<String> response = restTemplate.getForEntity(baseUrl, String.class);
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputContainsLogForOurPackage("ERROR");
assertThatOutputContainsLogForOtherPackages("ERROR");
}
assertThat(response.getStatusCode().value()).isEqualTo(200);
assertThatOutputContainsLogForOurPackage("ERROR");
assertThatOutputContainsLogForOtherPackages("ERROR");
}
private void assertThatOutputContainsLogForOurPackage(String level) {
assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*");
}
private void assertThatOutputContainsLogForOurPackage(String level) {
assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*");
}
private void assertThatOutputDoesntContainLogForOtherPackages(String level) {
assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level);
}
private void assertThatOutputDoesntContainLogForOtherPackages(String level) {
assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level);
}
private void assertThatOutputContainsLogForOtherPackages(String level) {
assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level);
}
private void assertThatOutputContainsLogForOtherPackages(String level) {
assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level);
}
}