Switch to new class loader filter runner

This commit is contained in:
Dave Syer
2017-05-11 17:28:32 +01:00
parent bf905ccae0
commit 4b4e7650fa
12 changed files with 469 additions and 246 deletions

View File

@@ -2,6 +2,8 @@ package org.springframework.cloud.autoconfigure;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.ClassPathExclusions;
@@ -30,7 +32,7 @@ public class RefreshAutoConfigurationClassPathTests {
private static ConfigurableApplicationContext getApplicationContext(
Class<?> configuration, String... properties) {
return new SpringApplicationBuilder(configuration).web(false)
return new SpringApplicationBuilder(configuration).web(WebApplicationType.NONE)
.properties(properties).run();
}

View File

@@ -3,6 +3,7 @@ package org.springframework.cloud.autoconfigure;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.rule.OutputCapture;
@@ -33,7 +34,7 @@ public class RefreshAutoConfigurationTests {
private static ConfigurableApplicationContext getApplicationContext(
Class<?> configuration, String... properties) {
return new SpringApplicationBuilder(configuration).web(false)
return new SpringApplicationBuilder(configuration).web(WebApplicationType.NONE)
.properties(properties).run();
}

View File

@@ -2,12 +2,11 @@ package org.springframework.cloud.bootstrap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.bootstrap.BootstrapOrderingSpringApplicationJsonIntegrationTests.Application;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -17,9 +16,6 @@ import static org.springframework.cloud.bootstrap.TestHigherPriorityBootstrapCon
@SpringBootTest(classes = Application.class)
public class BootstrapSourcesOrderingTests {
@Autowired
private ConfigurableEnvironment environment;
@Test
public void sourcesAreOrderedCorrectly() {
Class<?> firstConstructedClass = firstToBeCreated.get();

View File

@@ -4,15 +4,12 @@ import java.util.Arrays;
import java.util.Map;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;

View File

@@ -17,7 +17,9 @@
package org.springframework.cloud.context.scope.refresh;
import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -37,7 +39,7 @@ public class RefreshScopeSerializationTests {
@Test
public void defaultApplicationContextId() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
TestConfiguration.class).web(false).run();
TestConfiguration.class).web(WebApplicationType.NONE).run();
assertThat(context.getId(), is(equalTo("application")));
}
@@ -52,7 +54,7 @@ public class RefreshScopeSerializationTests {
private DefaultListableBeanFactory getBeanFactory() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
TestConfiguration.class).web(false).run();
TestConfiguration.class).web(WebApplicationType.NONE).run();
DefaultListableBeanFactory factory = (DefaultListableBeanFactory) context
.getAutowireCapableBeanFactory();
return factory;

View File

@@ -25,7 +25,9 @@ import java.util.Map;
import org.junit.After;
import org.junit.Test;
import org.springframework.boot.Banner.Mode;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
@@ -65,7 +67,7 @@ public class RefreshEndpointTests {
@Test
public void keysComputedWhenAdded() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).web(false)
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE)
.bannerMode(Mode.OFF).properties("spring.cloud.bootstrap.name:none")
.run();
RefreshScope scope = new RefreshScope();
@@ -79,7 +81,7 @@ public class RefreshEndpointTests {
@Test
public void keysComputedWhenOveridden() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).web(false)
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE)
.bannerMode(Mode.OFF).properties("spring.cloud.bootstrap.name:none")
.run();
RefreshScope scope = new RefreshScope();
@@ -94,7 +96,7 @@ public class RefreshEndpointTests {
@Test
public void keysComputedWhenChangesInExternalProperties() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).web(false)
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE)
.bannerMode(Mode.OFF).properties("spring.cloud.bootstrap.name:none")
.run();
RefreshScope scope = new RefreshScope();
@@ -110,7 +112,7 @@ public class RefreshEndpointTests {
@Test
public void springMainSourcesEmptyInRefreshCycle() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).web(false)
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE)
.bannerMode(Mode.OFF).properties("spring.cloud.bootstrap.name:none")
.run();
RefreshScope scope = new RefreshScope();
@@ -128,7 +130,7 @@ public class RefreshEndpointTests {
@Test
public void eventsPublishedInOrder() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).web(false)
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE)
.bannerMode(Mode.OFF).run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
@@ -144,7 +146,7 @@ public class RefreshEndpointTests {
@Test
public void shutdownHooksCleaned() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(Empty.class)
.web(false).bannerMode(Mode.OFF).run();
.web(WebApplicationType.NONE).bannerMode(Mode.OFF).run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(context);
ContextRefresher contextRefresher = new ContextRefresher(context, scope);