Prevent run failures in tests from polluting LoggerContext

This commit is contained in:
Andy Wilkinson
2015-08-17 20:37:00 +01:00
parent 9e88dced88
commit 8067a53682

View File

@@ -16,13 +16,17 @@
package org.springframework.boot.devtools;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import ch.qos.logback.classic.Logger;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
@@ -38,6 +42,12 @@ public class RemoteUrlPropertyExtractorTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
@After
public void preventRunFailuresFromPollutingLoggerContext() {
((Logger) LoggerFactory.getLogger(RemoteUrlPropertyExtractorTests.class))
.getLoggerContext().getTurboFilterList().clear();
}
@Test
public void missingUrl() throws Exception {
this.thrown.expect(IllegalStateException.class);