diff --git a/spring-boot-actuator/pom.xml b/spring-boot-actuator/pom.xml
index 3eb06c8c7a2..89fac901456 100644
--- a/spring-boot-actuator/pom.xml
+++ b/spring-boot-actuator/pom.xml
@@ -1,5 +1,6 @@
-
+
4.0.0
org.springframework.boot
@@ -197,7 +198,8 @@
spring-data-solr
true
-
+
wstx-asl
org.codehaus.woodstox
@@ -278,8 +280,7 @@
org.springframework.boot
- spring-boot
- test-jar
+ spring-boot-test
test
@@ -287,17 +288,6 @@
spring-boot-test-support
test
-
- org.springframework.boot
- spring-boot-test
- test
-
-
- org.springframework.boot
- spring-boot-test
- test-jar
- test
-
ch.qos.logback
logback-classic
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ActuatorConfigurationClassTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ActuatorConfigurationClassTests.java
index 8c1a5f6f06e..36f74882538 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ActuatorConfigurationClassTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/ActuatorConfigurationClassTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.boot.actuate;
-import org.springframework.boot.test.testutil.AbstractConfigurationClassTests;
+import org.springframework.boot.testsupport.context.AbstractConfigurationClassTests;
/**
* Tests for the actuator module's {@code @Configuration} classes.
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
index 44121dfb2e3..118a3e1ac08 100755
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
@@ -63,7 +63,7 @@ import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.test.util.TestPropertyValues;
-import org.springframework.boot.testutil.Matched;
+import org.springframework.boot.testsupport.assertj.Matched;
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/JolokiaAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/JolokiaAutoConfigurationTests.java
index 264cd79f0f7..dfc43ee16ee 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/JolokiaAutoConfigurationTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/JolokiaAutoConfigurationTests.java
@@ -27,6 +27,7 @@ import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping;
import org.springframework.boot.actuate.endpoint.mvc.JolokiaMvcEndpoint;
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpointSecurityInterceptor;
+import org.springframework.boot.actuate.servlet.MockServletWebServerFactory;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
@@ -34,7 +35,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
-import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesNoSecurityTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesNoSecurityTests.java
index 0290a2c634f..36937d2b58e 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesNoSecurityTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesNoSecurityTests.java
@@ -21,9 +21,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java
index dcc79d6487e..f4d31386366 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java
@@ -40,12 +40,12 @@ import org.springframework.boot.actuate.endpoint.TomcatPublicMetrics;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.actuate.metrics.rich.RichGauge;
import org.springframework.boot.actuate.metrics.rich.RichGaugeReader;
+import org.springframework.boot.actuate.servlet.MockServletWebServerFactory;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvidersConfiguration;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
-import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.ConfigurableApplicationContext;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cloudfoundry/SkipSslVerificationHttpRequestFactoryTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cloudfoundry/SkipSslVerificationHttpRequestFactoryTests.java
index 4a8d901e8ff..df585067b15 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cloudfoundry/SkipSslVerificationHttpRequestFactoryTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cloudfoundry/SkipSslVerificationHttpRequestFactoryTests.java
@@ -24,11 +24,11 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.springframework.boot.testsupport.web.servlet.ExampleServlet;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
-import org.springframework.boot.web.servlet.server.ExampleServlet;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.ResourceAccessException;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java
index 6b60f4cfbc3..122a7d039e0 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java
@@ -31,9 +31,9 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockHttpServletRequest;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityMvcEndpointSecurityInterceptorTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityMvcEndpointSecurityInterceptorTests.java
index 070d430da83..8db900cd0ad 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityMvcEndpointSecurityInterceptorTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityMvcEndpointSecurityInterceptorTests.java
@@ -27,8 +27,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockServletContext;
import org.springframework.web.method.HandlerMethod;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepositoryTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepositoryTests.java
index a298f585ff2..a281adbed6f 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepositoryTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepositoryTests.java
@@ -24,7 +24,7 @@ import org.junit.Test;
import org.springframework.boot.actuate.metrics.Iterables;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.actuate.metrics.writer.Delta;
-import org.springframework.boot.redis.RedisTestServer;
+import org.springframework.boot.testsupport.rule.RedisTestServer;
import org.springframework.data.redis.core.StringRedisTemplate;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMultiMetricRepositoryTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMultiMetricRepositoryTests.java
index 1612b39f923..f4537dcd4a6 100644
--- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMultiMetricRepositoryTests.java
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMultiMetricRepositoryTests.java
@@ -34,7 +34,7 @@ import org.junit.runners.Parameterized.Parameters;
import org.springframework.boot.actuate.metrics.Iterables;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.actuate.metrics.writer.Delta;
-import org.springframework.boot.redis.RedisTestServer;
+import org.springframework.boot.testsupport.rule.RedisTestServer;
import org.springframework.data.redis.core.StringRedisTemplate;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/servlet/MockServletWebServerFactory.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/servlet/MockServletWebServerFactory.java
new file mode 100644
index 00000000000..d2b9c8bdace
--- /dev/null
+++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/servlet/MockServletWebServerFactory.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.actuate.servlet;
+
+import java.util.Arrays;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter;
+import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredServlet;
+import org.springframework.boot.web.server.WebServer;
+import org.springframework.boot.web.server.WebServerException;
+import org.springframework.boot.web.servlet.ServletContextInitializer;
+import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
+import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
+
+import static org.mockito.Mockito.spy;
+
+/**
+ * Mock {@link ServletWebServerFactory}.
+ *
+ * @author Phillip Webb
+ * @author Andy Wilkinson
+ */
+public class MockServletWebServerFactory extends AbstractServletWebServerFactory {
+
+ private MockServletWebServer webServer;
+
+ @Override
+ public WebServer getWebServer(ServletContextInitializer... initializers) {
+ this.webServer = spy(
+ new MockServletWebServer(mergeInitializers(initializers), getPort()));
+ return this.webServer;
+ }
+
+ public MockServletWebServer getWebServer() {
+ return this.webServer;
+ }
+
+ public ServletContext getServletContext() {
+ return getWebServer() == null ? null : getWebServer().getServletContext();
+ }
+
+ public RegisteredServlet getRegisteredServlet(int index) {
+ return getWebServer() == null ? null : getWebServer().getRegisteredServlet(index);
+ }
+
+ public RegisteredFilter getRegisteredFilter(int index) {
+ return getWebServer() == null ? null : getWebServer().getRegisteredFilters(index);
+ }
+
+ public static class MockServletWebServer
+ extends org.springframework.boot.testsupport.web.servlet.MockServletWebServer
+ implements WebServer {
+
+ public MockServletWebServer(ServletContextInitializer[] initializers, int port) {
+ super(Arrays.stream(initializers)
+ .map((i) -> (Initializer) (s) -> i.onStartup(s))
+ .toArray(Initializer[]::new), port);
+ }
+
+ @Override
+ public void start() throws WebServerException {
+ }
+
+ }
+
+}
diff --git a/spring-boot-actuator/src/test/resources/log4j2-test.xml b/spring-boot-actuator/src/test/resources/log4j2-test.xml
new file mode 100644
index 00000000000..8c0f7f46525
--- /dev/null
+++ b/spring-boot-actuator/src/test/resources/log4j2-test.xml
@@ -0,0 +1,17 @@
+
+
+
+ %xwEx
+ %5p
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-boot-actuator/src/test/resources/logback.xml b/spring-boot-actuator/src/test/resources/logback.xml
deleted file mode 100644
index ee10b29b61c..00000000000
--- a/spring-boot-actuator/src/test/resources/logback.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml
index 48c9cde59ad..fc25f6fb604 100755
--- a/spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-autoconfigure/pom.xml
@@ -678,12 +678,6 @@
true
-
- org.springframework.boot
- spring-boot
- test-jar
- test
-
org.springframework.boot
spring-boot-test-support
@@ -694,12 +688,6 @@
spring-boot-test
test
-
- org.springframework.boot
- spring-boot-test
- test-jar
- test
-
ch.qos.logback
logback-classic
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigureConfigurationClassTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigureConfigurationClassTests.java
index 4065037c241..b7cae732bd9 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigureConfigurationClassTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigureConfigurationClassTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.boot.autoconfigure;
-import org.springframework.boot.test.testutil.AbstractConfigurationClassTests;
+import org.springframework.boot.testsupport.context.AbstractConfigurationClassTests;
/**
* Tests for the auto-configure module's {@code @Configuration} classes.
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java
index 067353f5c31..100c2a8d342 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java
@@ -32,9 +32,9 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.test.City;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
index b21435256f1..068f4bae469 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
@@ -56,9 +56,9 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.cache.support.MockCachingProvider;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java
index 7b952cb206f..775538d1d78 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java
@@ -33,7 +33,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionEvaluationRepor
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.util.TestPropertyValues;
-import org.springframework.boot.testutil.Matched;
+import org.springframework.boot.testsupport.assertj.Matched;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Condition;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanWithFilteredClasspathTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanWithFilteredClasspathTests.java
index 13a295aea9b..c5c810ac11f 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanWithFilteredClasspathTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanWithFilteredClasspathTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@ import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/OnBeanConditionTypeDeductionFailureTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/OnBeanConditionTypeDeductionFailureTests.java
index 4bc959a7ee1..17284b37085 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/OnBeanConditionTypeDeductionFailureTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/OnBeanConditionTypeDeductionFailureTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.condition.OnBeanCondition.BeanTypeDeductionException;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java
index ed76ff0485a..0121ac197d6 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java
@@ -24,9 +24,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import redis.clients.jedis.Jedis;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.util.StringUtils;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java
index 4b6a7084282..dc1f8f5d259 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java
@@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.data.alt.redis.CityRedisRepository
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.autoconfigure.data.redis.city.City;
import org.springframework.boot.autoconfigure.data.redis.city.CityRepository;
-import org.springframework.boot.redis.RedisTestServer;
+import org.springframework.boot.testsupport.rule.RedisTestServer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationWithoutJacksonTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationWithoutJacksonTests.java
index 3400344d235..efcd7486d1c 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationWithoutJacksonTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfigurationWithoutJacksonTests.java
@@ -22,8 +22,8 @@ import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.mock.web.MockServletContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java
index 6e36a452aa5..078648f87fb 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java
@@ -30,9 +30,9 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfigurationWithoutJacksonTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfigurationWithoutJacksonTests.java
index 9ba26f52252..e53b72317c1 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfigurationWithoutJacksonTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfigurationWithoutJacksonTests.java
@@ -20,8 +20,8 @@ import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzerTests.java
index c1086780a7f..081d53ef687 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzerTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.diagnostics.FailureAnalysis;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializerTests.java
index 2a94e345c07..bbd09ee9b0c 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializerTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializerTests.java
@@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.context.event.ApplicationFailedEvent;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -52,7 +52,7 @@ import static org.junit.Assert.fail;
public class AutoConfigurationReportLoggingInitializerTests {
@Rule
- public InternalOutputCapture outputCapture = new InternalOutputCapture();
+ public OutputCapture outputCapture = new OutputCapture();
private AutoConfigurationReportLoggingInitializer initializer = new AutoConfigurationReportLoggingInitializer();
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityPropertiesTests.java
index 4e2eae7e27b..d9bfea4c258 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityPropertiesTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityPropertiesTests.java
@@ -16,12 +16,16 @@
package org.springframework.boot.autoconfigure.security;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
import org.junit.Test;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
-import org.springframework.boot.context.properties.source.MockConfigurationPropertySource;
+import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import static org.assertj.core.api.Assertions.assertThat;
@@ -60,9 +64,10 @@ public class SecurityPropertiesTests {
@Test
public void testBindingIgnoredMultiValuedList() {
- MockConfigurationPropertySource source = new MockConfigurationPropertySource();
- source.put("security.ignored[0]", "/css/**");
- source.put("security.ignored[1]", "/foo/**");
+ Map map = new LinkedHashMap<>();
+ map.put("security.ignored[0]", "/css/**");
+ map.put("security.ignored[1]", "/foo/**");
+ MapConfigurationPropertySource source = new MapConfigurationPropertySource(map);
bind(source);
assertThat(this.security.getIgnored()).hasSize(2);
assertThat(this.security.getIgnored().contains("/foo/**")).isTrue();
@@ -94,7 +99,7 @@ public class SecurityPropertiesTests {
}
private void bind(String name, String value) {
- bind(new MockConfigurationPropertySource(name, value));
+ bind(new MapConfigurationPropertySource(Collections.singletonMap(name, value)));
}
private void bind(ConfigurationPropertySource source) {
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java
index a570c1ce1a6..2bd3ce48c7a 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java
@@ -34,10 +34,10 @@ import org.springframework.boot.autoconfigure.security.oauth2.OAuth2ClientProper
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2RestOperationsConfiguration;
import org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration;
import org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration;
+import org.springframework.boot.autoconfigure.web.servlet.MockServletWebServerFactory;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.TestPropertyValues;
-import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java
index 0c0a3ac65b7..20a3338268a 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java
@@ -23,7 +23,7 @@ import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
-import org.springframework.boot.redis.RedisTestServer;
+import org.springframework.boot.testsupport.rule.RedisTestServer;
import org.springframework.session.data.redis.RedisFlushMode;
import org.springframework.session.data.redis.RedisOperationsSessionRepository;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationWithHibernateValidatorMissingElImplTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationWithHibernateValidatorMissingElImplTests.java
index f615b7bfadd..b54deb1623b 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationWithHibernateValidatorMissingElImplTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationWithHibernateValidatorMissingElImplTests.java
@@ -22,8 +22,8 @@ import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationWithoutValidatorTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationWithoutValidatorTests.java
index 53b7568e194..911626f0d3a 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationWithoutValidatorTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationWithoutValidatorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@ import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java
index 48393aec54c..2d986f6b438 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java
@@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.web;
import org.junit.Test;
-import org.springframework.boot.testutil.Matched;
+import org.springframework.boot.testsupport.assertj.Matched;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.endsWith;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
index cf95527fb92..fc8ea5439a8 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
@@ -26,7 +26,8 @@ import org.junit.Test;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.boot.context.properties.source.MockConfigurationPropertySource;
+import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
+import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import static org.assertj.core.api.Assertions.assertThat;
@@ -183,8 +184,7 @@ public class ServerPropertiesTests {
}
private void bind(Map map) {
- MockConfigurationPropertySource source = new MockConfigurationPropertySource();
- map.forEach(source::put);
+ ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
new Binder(source).bind("server", Bindable.ofInstance(this.properties));
}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java
index 81765a9c75f..8becf80ecac 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java
@@ -45,7 +45,8 @@ import org.mockito.MockitoAnnotations;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.boot.context.properties.source.MockConfigurationPropertySource;
+import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
+import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyWebServer;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
@@ -617,8 +618,7 @@ public class DefaultServletWebServerFactoryCustomizerTests {
}
private void bindProperties(Map map) {
- MockConfigurationPropertySource source = new MockConfigurationPropertySource();
- map.forEach(source::put);
+ ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
new Binder(source).bind("server", Bindable.ofInstance(this.properties));
}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/FilterOrderingIntegrationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/FilterOrderingIntegrationTests.java
index b7d665a813c..37d35785149 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/FilterOrderingIntegrationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/FilterOrderingIntegrationTests.java
@@ -30,12 +30,11 @@ import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConf
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter;
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
-import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.MockServletWebServerFactory.RegisteredFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnection;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfigurationTests.java
index 3fb11415de8..eb814fb204b 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfigurationTests.java
@@ -35,7 +35,6 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter;
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
-import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java
new file mode 100644
index 00000000000..b6df5760360
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.autoconfigure.web.servlet;
+
+import java.util.Arrays;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter;
+import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredServlet;
+import org.springframework.boot.web.server.WebServer;
+import org.springframework.boot.web.server.WebServerException;
+import org.springframework.boot.web.servlet.ServletContextInitializer;
+import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
+import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
+
+import static org.mockito.Mockito.spy;
+
+/**
+ * Mock {@link ServletWebServerFactory}.
+ *
+ * @author Phillip Webb
+ * @author Andy Wilkinson
+ */
+public class MockServletWebServerFactory extends AbstractServletWebServerFactory {
+
+ private MockServletWebServer webServer;
+
+ @Override
+ public WebServer getWebServer(ServletContextInitializer... initializers) {
+ this.webServer = spy(
+ new MockServletWebServer(mergeInitializers(initializers), getPort()));
+ return this.webServer;
+ }
+
+ public MockServletWebServer getWebServer() {
+ return this.webServer;
+ }
+
+ public ServletContext getServletContext() {
+ return getWebServer() == null ? null : getWebServer().getServletContext();
+ }
+
+ public RegisteredServlet getRegisteredServlet(int index) {
+ return getWebServer() == null ? null : getWebServer().getRegisteredServlet(index);
+ }
+
+ public RegisteredFilter getRegisteredFilter(int index) {
+ return getWebServer() == null ? null : getWebServer().getRegisteredFilters(index);
+ }
+
+ public static class MockServletWebServer
+ extends org.springframework.boot.testsupport.web.servlet.MockServletWebServer
+ implements WebServer {
+
+ public MockServletWebServer(ServletContextInitializer[] initializers, int port) {
+ super(Arrays.stream(initializers)
+ .map((i) -> (Initializer) (s) -> i.onStartup(s))
+ .toArray(Initializer[]::new), port);
+ }
+
+ @Override
+ public void start() throws WebServerException {
+ }
+
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java
index bcd983fc7f5..9531d00e0b2 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java
@@ -31,7 +31,6 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
index ebe127dc4f8..8cc47b1e761 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
@@ -49,7 +49,6 @@ import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
-import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/spring-boot-cli/pom.xml b/spring-boot-cli/pom.xml
index b95d47ede0e..1db89e2f346 100644
--- a/spring-boot-cli/pom.xml
+++ b/spring-boot-cli/pom.xml
@@ -140,8 +140,7 @@
org.springframework.boot
- spring-boot
- test-jar
+ spring-boot-test-support
test
diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/install/GroovyGrabDependencyResolverTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/install/GroovyGrabDependencyResolverTests.java
index a1050b337f4..b5615edb3db 100644
--- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/install/GroovyGrabDependencyResolverTests.java
+++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/install/GroovyGrabDependencyResolverTests.java
@@ -31,7 +31,7 @@ import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
import org.springframework.boot.cli.compiler.GroovyCompilerScope;
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration;
-import org.springframework.boot.testutil.Matched;
+import org.springframework.boot.testsupport.assertj.Matched;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItems;
diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml
index 92213390e40..52a547bcc7f 100644
--- a/spring-boot-dependencies/pom.xml
+++ b/spring-boot-dependencies/pom.xml
@@ -225,23 +225,11 @@
spring-boot
2.0.0.BUILD-SNAPSHOT
-
- org.springframework.boot
- spring-boot
- test-jar
- 2.0.0.BUILD-SNAPSHOT
-
org.springframework.boot
spring-boot-test
2.0.0.BUILD-SNAPSHOT
-
- org.springframework.boot
- spring-boot-test
- test-jar
- 2.0.0.BUILD-SNAPSHOT
-
org.springframework.boot
spring-boot-test-autoconfigure
diff --git a/spring-boot-devtools/derby.log b/spring-boot-devtools/derby.log
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/spring-boot-devtools/pom.xml b/spring-boot-devtools/pom.xml
index 08dd3574682..ef20def8fb8 100644
--- a/spring-boot-devtools/pom.xml
+++ b/spring-boot-devtools/pom.xml
@@ -86,12 +86,6 @@
true
-
- org.springframework.boot
- spring-boot
- test-jar
- test
-
org.springframework.boot
spring-boot-test-support
diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java
index 9ad2d89f9ae..12964311b81 100644
--- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java
+++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsEmbeddedDataSourceAutoConfigurationTests.java
@@ -25,8 +25,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.ConfigurableApplicationContext;
import static org.mockito.Mockito.times;
diff --git a/spring-boot-docs/pom.xml b/spring-boot-docs/pom.xml
index 1a2475a4d0e..96d569930aa 100644
--- a/spring-boot-docs/pom.xml
+++ b/spring-boot-docs/pom.xml
@@ -774,12 +774,6 @@
true
-
- org.springframework.boot
- spring-boot
- test-jar
- test
-
org.springframework.boot
spring-boot-test-support
diff --git a/spring-boot-docs/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderExampleTests.java b/spring-boot-docs/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderExampleTests.java
index 2774836a420..4cf1952d51d 100644
--- a/spring-boot-docs/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderExampleTests.java
+++ b/spring-boot-docs/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderExampleTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.rule.OutputCapture;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestDatabaseAutoConfigurationNoEmbeddedTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestDatabaseAutoConfigurationNoEmbeddedTests.java
index b75012588b8..5db6b5ae46c 100644
--- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestDatabaseAutoConfigurationNoEmbeddedTests.java
+++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestDatabaseAutoConfigurationNoEmbeddedTests.java
@@ -23,10 +23,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithoutJacksonIntegrationTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithoutJacksonIntegrationTests.java
index 4937b8ac2a2..e1d65e16fca 100644
--- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithoutJacksonIntegrationTests.java
+++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithoutJacksonIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@ import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-test/pom.xml b/spring-boot-test/pom.xml
index f4b28b8a930..e0308842c89 100644
--- a/spring-boot-test/pom.xml
+++ b/spring-boot-test/pom.xml
@@ -111,12 +111,6 @@
true
-
- org.springframework.boot
- spring-boot
- test-jar
- test
-
org.springframework.boot
spring-boot-test-support
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactoryTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactoryTests.java
index 53e5f4ed66f..02538a95a85 100644
--- a/spring-boot-test/src/test/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactoryTests.java
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactoryTests.java
@@ -20,9 +20,9 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathOverrides;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.rule.OutputCapture;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathOverrides;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito110Tests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito110Tests.java
index 07a6a5ce540..9ec460784f5 100644
--- a/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito110Tests.java
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito110Tests.java
@@ -22,8 +22,8 @@ import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runner.notification.Failure;
-import org.springframework.boot.junit.runner.classpath.ClassPathOverrides;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathOverrides;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito21Tests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito21Tests.java
index d0c8a3f8008..e92529b3231 100644
--- a/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito21Tests.java
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito21Tests.java
@@ -22,8 +22,8 @@ import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runner.notification.Failure;
-import org.springframework.boot.junit.runner.classpath.ClassPathOverrides;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathOverrides;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito22Tests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito22Tests.java
index 2c545b1259d..71b6b4d3bd8 100644
--- a/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito22Tests.java
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito22Tests.java
@@ -22,8 +22,8 @@ import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runner.notification.Failure;
-import org.springframework.boot.junit.runner.classpath.ClassPathOverrides;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathOverrides;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito25Tests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito25Tests.java
index b6f5de37b7b..adfc655fef8 100644
--- a/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito25Tests.java
+++ b/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/Mockito25Tests.java
@@ -22,8 +22,8 @@ import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runner.notification.Failure;
-import org.springframework.boot.junit.runner.classpath.ClassPathOverrides;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathOverrides;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-tools/spring-boot-autoconfigure-processor/src/test/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessorTests.java b/spring-boot-tools/spring-boot-autoconfigure-processor/src/test/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessorTests.java
index c50f6978314..55e491ebbc3 100644
--- a/spring-boot-tools/spring-boot-autoconfigure-processor/src/test/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessorTests.java
+++ b/spring-boot-tools/spring-boot-autoconfigure-processor/src/test/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessorTests.java
@@ -27,7 +27,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
-import org.springframework.boot.junit.compiler.TestCompiler;
+import org.springframework.boot.testsupport.compiler.TestCompiler;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java
index d5d4bd995c5..1e4bdac115c 100644
--- a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java
+++ b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java
@@ -71,7 +71,7 @@ import org.springframework.boot.configurationsample.specific.InnerClassRootConfi
import org.springframework.boot.configurationsample.specific.InvalidAccessorProperties;
import org.springframework.boot.configurationsample.specific.InvalidDoubleRegistrationProperties;
import org.springframework.boot.configurationsample.specific.SimplePojo;
-import org.springframework.boot.junit.compiler.TestCompiler;
+import org.springframework.boot.testsupport.compiler.TestCompiler;
import org.springframework.util.FileCopyUtils;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestProject.java b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestProject.java
index aeb76620e47..00f857e8106 100644
--- a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestProject.java
+++ b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestProject.java
@@ -36,8 +36,8 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
import org.springframework.boot.configurationsample.ConfigurationProperties;
import org.springframework.boot.configurationsample.NestedConfigurationProperty;
-import org.springframework.boot.junit.compiler.TestCompiler;
-import org.springframework.boot.junit.compiler.TestCompiler.TestCompilationTask;
+import org.springframework.boot.testsupport.compiler.TestCompiler;
+import org.springframework.boot.testsupport.compiler.TestCompiler.TestCompilationTask;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.FileSystemUtils;
diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/fieldvalues/AbstractFieldValuesProcessorTests.java b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/fieldvalues/AbstractFieldValuesProcessorTests.java
index ad475e308e9..fcc553f5296 100644
--- a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/fieldvalues/AbstractFieldValuesProcessorTests.java
+++ b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/fieldvalues/AbstractFieldValuesProcessorTests.java
@@ -34,7 +34,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.boot.configurationsample.fieldvalues.FieldValues;
-import org.springframework.boot.junit.compiler.TestCompiler;
+import org.springframework.boot.testsupport.compiler.TestCompiler;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot-tools/spring-boot-loader/pom.xml b/spring-boot-tools/spring-boot-loader/pom.xml
index f77a3e6dd6e..00cc554856e 100644
--- a/spring-boot-tools/spring-boot-loader/pom.xml
+++ b/spring-boot-tools/spring-boot-loader/pom.xml
@@ -47,6 +47,11 @@
1.46
test
+
+
+ org.springframework.boot
+ spring-boot-test-support
+
diff --git a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/InternalOutputCapture.java b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/InternalOutputCapture.java
deleted file mode 100644
index bf837a45128..00000000000
--- a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/InternalOutputCapture.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2012-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.boot.loader;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-/**
- * Internal JUnit {@code @Rule} to capture output from System.out and System.err.
- *
- * @author Phillip Webb
- */
-class InternalOutputCapture implements TestRule {
-
- private CaptureOutputStream captureOut;
-
- private CaptureOutputStream captureErr;
-
- private ByteArrayOutputStream copy;
-
- @Override
- public Statement apply(final Statement base, Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- captureOutput();
- try {
- base.evaluate();
- }
- finally {
- releaseOutput();
- }
- }
- };
- }
-
- protected void captureOutput() {
- this.copy = new ByteArrayOutputStream();
- this.captureOut = new CaptureOutputStream(System.out, this.copy);
- this.captureErr = new CaptureOutputStream(System.err, this.copy);
- System.setOut(new PrintStream(this.captureOut));
- System.setErr(new PrintStream(this.captureErr));
- }
-
- protected void releaseOutput() {
- System.setOut(this.captureOut.getOriginal());
- System.setErr(this.captureErr.getOriginal());
- this.copy = null;
- }
-
- public void flush() {
- try {
- this.captureOut.flush();
- this.captureErr.flush();
- }
- catch (IOException ex) {
- // ignore
- }
- }
-
- @Override
- public String toString() {
- flush();
- return this.copy.toString();
- }
-
- private static class CaptureOutputStream extends OutputStream {
-
- private final PrintStream original;
-
- private final OutputStream copy;
-
- CaptureOutputStream(PrintStream original, OutputStream copy) {
- this.original = original;
- this.copy = copy;
- }
-
- @Override
- public void write(int b) throws IOException {
- this.copy.write(b);
- this.original.write(b);
- this.original.flush();
- }
-
- @Override
- public void write(byte[] b) throws IOException {
- write(b, 0, b.length);
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- this.copy.write(b, off, len);
- this.original.write(b, off, len);
- }
-
- public PrintStream getOriginal() {
- return this.original;
- }
-
- @Override
- public void flush() throws IOException {
- this.copy.flush();
- this.original.flush();
- }
-
- }
-
-}
diff --git a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java
index 35412a40a97..c62bd797bcb 100644
--- a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java
+++ b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java
@@ -39,6 +39,7 @@ import org.mockito.MockitoAnnotations;
import org.springframework.boot.loader.archive.Archive;
import org.springframework.boot.loader.archive.ExplodedArchive;
import org.springframework.boot.loader.archive.JarFileArchive;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.core.io.FileSystemResource;
import org.springframework.test.util.ReflectionTestUtils;
@@ -53,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PropertiesLauncherTests {
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
@Rule
public ExpectedException expected = ExpectedException.none();
diff --git a/spring-boot-tools/spring-boot-test-support/pom.xml b/spring-boot-tools/spring-boot-test-support/pom.xml
index 33cda6ea6a6..fc889c72356 100644
--- a/spring-boot-tools/spring-boot-test-support/pom.xml
+++ b/spring-boot-tools/spring-boot-test-support/pom.xml
@@ -19,12 +19,6 @@
${basedir}/../..
-
-
- junit
- junit
- provided
-
org.apache.maven
@@ -66,16 +60,50 @@
org.springframework
spring-core
+
+ org.hamcrest
+ hamcrest-core
+
+
+ org.hamcrest
+ hamcrest-library
+
+
+ org.assertj
+ assertj-core
+
+
+
+ javax.servlet
+ javax.servlet-api
+ true
+
+
+ org.mockito
+ mockito-core
+ true
+
+
+ org.springframework.data
+ spring-data-redis
+ true
+
+
+ org.springframework
+ spring-context
+ true
+
+
+
+ junit
+ junit
+ provided
+
org.hibernate
hibernate-validator
test
-
- org.springframework
- spring-context
- test
-
diff --git a/spring-boot/src/test/java/org/springframework/boot/testutil/Matched.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/Matched.java
similarity index 96%
rename from spring-boot/src/test/java/org/springframework/boot/testutil/Matched.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/Matched.java
index 2bf302739ef..2aa0356c68b 100644
--- a/spring-boot/src/test/java/org/springframework/boot/testutil/Matched.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/Matched.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.testutil;
+package org.springframework.boot.testsupport.assertj;
import org.assertj.core.api.Condition;
import org.hamcrest.Matcher;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/package-info.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/package-info.java
new file mode 100644
index 00000000000..ac465259486
--- /dev/null
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Utilities and helpers for AssertJ.
+ */
+package org.springframework.boot.testsupport.assertj;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/TestCompiler.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/TestCompiler.java
similarity index 98%
rename from spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/TestCompiler.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/TestCompiler.java
index 5e3883d94c1..e7783a1b5db 100644
--- a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/TestCompiler.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/TestCompiler.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.junit.compiler;
+package org.springframework.boot.testsupport.compiler;
import java.io.File;
import java.io.IOException;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/package-info.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/package-info.java
similarity index 92%
rename from spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/package-info.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/package-info.java
index e76ad73ef96..45cc6aad737 100644
--- a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/package-info.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/package-info.java
@@ -17,4 +17,4 @@
/**
* Utilities to work with the Java compiler at test time.
*/
-package org.springframework.boot.junit.compiler;
+package org.springframework.boot.testsupport.compiler;
diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/AbstractConfigurationClassTests.java
similarity index 98%
rename from spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/AbstractConfigurationClassTests.java
index bb41f33a63c..33da6644b6e 100644
--- a/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/AbstractConfigurationClassTests.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.test.testutil;
+package org.springframework.boot.testsupport.context;
import java.io.File;
import java.io.IOException;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/package-info.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/package-info.java
new file mode 100644
index 00000000000..7173d4d77f9
--- /dev/null
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Utilities to help test Spring contexts.
+ */
+package org.springframework.boot.testsupport.context;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/package-info.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/package-info.java
new file mode 100644
index 00000000000..6e727d5cf0f
--- /dev/null
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Internal support classes used in Spring Boot tests.
+ */
+package org.springframework.boot.testsupport;
diff --git a/spring-boot/src/test/java/org/springframework/boot/testutil/InternalOutputCapture.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/OutputCapture.java
similarity index 87%
rename from spring-boot/src/test/java/org/springframework/boot/testutil/InternalOutputCapture.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/OutputCapture.java
index 34158b3a16a..52f415659d1 100644
--- a/spring-boot/src/test/java/org/springframework/boot/testutil/InternalOutputCapture.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/OutputCapture.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.testutil;
+package org.springframework.boot.testsupport.rule;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -29,9 +29,6 @@ import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
-import org.springframework.boot.ansi.AnsiOutput;
-import org.springframework.boot.ansi.AnsiOutput.Enabled;
-
import static org.hamcrest.Matchers.allOf;
/**
@@ -40,7 +37,7 @@ import static org.hamcrest.Matchers.allOf;
* @author Phillip Webb
* @author Andy Wilkinson
*/
-public class InternalOutputCapture implements TestRule {
+public class OutputCapture implements TestRule {
private CaptureOutputStream captureOut;
@@ -61,10 +58,9 @@ public class InternalOutputCapture implements TestRule {
}
finally {
try {
- if (!InternalOutputCapture.this.matchers.isEmpty()) {
- String output = InternalOutputCapture.this.toString();
- Assert.assertThat(output,
- allOf(InternalOutputCapture.this.matchers));
+ if (!OutputCapture.this.matchers.isEmpty()) {
+ String output = OutputCapture.this.toString();
+ Assert.assertThat(output, allOf(OutputCapture.this.matchers));
}
}
finally {
@@ -76,7 +72,7 @@ public class InternalOutputCapture implements TestRule {
}
protected void captureOutput() {
- AnsiOutput.setEnabled(Enabled.NEVER);
+ // FIXME AnsiOutput.setEnabled(Enabled.NEVER);
this.copy = new ByteArrayOutputStream();
this.captureOut = new CaptureOutputStream(System.out, this.copy);
this.captureErr = new CaptureOutputStream(System.err, this.copy);
@@ -85,7 +81,7 @@ public class InternalOutputCapture implements TestRule {
}
protected void releaseOutput() {
- AnsiOutput.setEnabled(Enabled.DETECT);
+ // FIXME AnsiOutput.setEnabled(Enabled.DETECT);
System.setOut(this.captureOut.getOriginal());
System.setErr(this.captureErr.getOriginal());
this.copy = null;
diff --git a/spring-boot/src/test/java/org/springframework/boot/redis/RedisTestServer.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/RedisTestServer.java
similarity index 92%
rename from spring-boot/src/test/java/org/springframework/boot/redis/RedisTestServer.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/RedisTestServer.java
index 772de98b3e7..a077fa50b1b 100644
--- a/spring-boot/src/test/java/org/springframework/boot/redis/RedisTestServer.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/RedisTestServer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2015 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.redis;
+package org.springframework.boot.testsupport.rule;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,7 +64,9 @@ public class RedisTestServer implements TestRule {
}
/**
- * @return the connection factory if any
+ * Return the Redis connection factory or {@code null} if the factory is not
+ * available.
+ * @return the connection factory or {@code null}
*/
public RedisConnectionFactory getConnectionFactory() {
return this.connectionFactory;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/package-info.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/package-info.java
new file mode 100644
index 00000000000..f84a5491cc4
--- /dev/null
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/rule/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Internal JUnit rules used in Spring Boot tests.
+ */
+package org.springframework.boot.testsupport.rule;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ClassPathExclusions.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ClassPathExclusions.java
similarity index 95%
rename from spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ClassPathExclusions.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ClassPathExclusions.java
index 39006d4b3f6..7bbbbbbc2eb 100644
--- a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ClassPathExclusions.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ClassPathExclusions.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.junit.runner.classpath;
+package org.springframework.boot.testsupport.runner.classpath;
import java.io.File;
import java.lang.annotation.ElementType;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ClassPathOverrides.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ClassPathOverrides.java
similarity index 95%
rename from spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ClassPathOverrides.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ClassPathOverrides.java
index c683a9b8695..d51fd389211 100644
--- a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ClassPathOverrides.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ClassPathOverrides.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.junit.runner.classpath;
+package org.springframework.boot.testsupport.runner.classpath;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ModifiedClassPathRunner.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ModifiedClassPathRunner.java
similarity index 99%
rename from spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ModifiedClassPathRunner.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ModifiedClassPathRunner.java
index 87ef49ece59..6a619814690 100644
--- a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ModifiedClassPathRunner.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/ModifiedClassPathRunner.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.junit.runner.classpath;
+package org.springframework.boot.testsupport.runner.classpath;
import java.io.File;
import java.lang.annotation.Annotation;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/package-info.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/package-info.java
similarity index 91%
rename from spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/package-info.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/package-info.java
index 6f165a8969d..663bae807e0 100644
--- a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/package-info.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/classpath/package-info.java
@@ -17,4 +17,4 @@
/**
* Custom JUnit runner to change the classpath.
*/
-package org.springframework.boot.junit.runner.classpath;
+package org.springframework.boot.testsupport.runner.classpath;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/package-info.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/package-info.java
similarity index 92%
rename from spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/package-info.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/package-info.java
index 2170758eea2..a56e3000d70 100644
--- a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/package-info.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/runner/package-info.java
@@ -17,4 +17,4 @@
/**
* Custom JUnit runners used in Spring Boot's own tests.
*/
-package org.springframework.boot.junit.runner;
+package org.springframework.boot.testsupport.runner;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/ExampleFilter.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/ExampleFilter.java
similarity index 95%
rename from spring-boot/src/test/java/org/springframework/boot/web/servlet/server/ExampleFilter.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/ExampleFilter.java
index 30d658c260c..81071a5b2bd 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/ExampleFilter.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/ExampleFilter.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.web.servlet.server;
+package org.springframework.boot.testsupport.web.servlet;
import java.io.IOException;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/ExampleServlet.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/ExampleServlet.java
similarity index 97%
rename from spring-boot/src/test/java/org/springframework/boot/web/servlet/server/ExampleServlet.java
rename to spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/ExampleServlet.java
index bb5d85fb4f1..ea6a9ad3b03 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/ExampleServlet.java
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/ExampleServlet.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.web.servlet.server;
+package org.springframework.boot.testsupport.web.servlet;
import java.io.IOException;
diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java
new file mode 100644
index 00000000000..4916c1471e5
--- /dev/null
+++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.testsupport.web.servlet;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Base class for Mock {@code ServletWebServer} implementations. Reduces the amount of
+ * code that would otherwise be duplicated in {@code spring-boot},
+ * {@code spring-boot-autoconfigure} and {@code spring-boot-actuator}.
+ *
+ * @author Phillip Webb
+ * @author Andy Wilkinson
+ */
+public abstract class MockServletWebServer {
+
+ private ServletContext servletContext;
+
+ private final Initializer[] initializers;
+
+ private final List registeredServlets = new ArrayList<>();
+
+ private final List registeredFilters = new ArrayList<>();
+
+ private final int port;
+
+ public MockServletWebServer(Initializer[] initializers, int port) {
+ this.initializers = initializers;
+ this.port = port;
+ initialize();
+ }
+
+ private void initialize() {
+ try {
+ this.servletContext = mock(ServletContext.class);
+ given(this.servletContext.addServlet(anyString(), (Servlet) any()))
+ .willAnswer(new Answer() {
+ @Override
+ public ServletRegistration.Dynamic answer(
+ InvocationOnMock invocation) throws Throwable {
+ RegisteredServlet registeredServlet = new RegisteredServlet(
+ (Servlet) invocation.getArguments()[1]);
+ MockServletWebServer.this.registeredServlets
+ .add(registeredServlet);
+ return registeredServlet.getRegistration();
+ }
+ });
+ given(this.servletContext.addFilter(anyString(), (Filter) any()))
+ .willAnswer(new Answer() {
+ @Override
+ public FilterRegistration.Dynamic answer(
+ InvocationOnMock invocation) throws Throwable {
+ RegisteredFilter registeredFilter = new RegisteredFilter(
+ (Filter) invocation.getArguments()[1]);
+ MockServletWebServer.this.registeredFilters
+ .add(registeredFilter);
+ return registeredFilter.getRegistration();
+ }
+ });
+ final Map initParameters = new HashMap<>();
+ given(this.servletContext.setInitParameter(anyString(), anyString()))
+ .will(new Answer() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ initParameters.put(invocation.getArgument(0),
+ invocation.getArgument(1));
+ return null;
+ }
+
+ });
+ given(this.servletContext.getInitParameterNames())
+ .willReturn(Collections.enumeration(initParameters.keySet()));
+ given(this.servletContext.getInitParameter(anyString()))
+ .willAnswer(new Answer() {
+ @Override
+ public String answer(InvocationOnMock invocation)
+ throws Throwable {
+ return initParameters.get(invocation.getArgument(0));
+ }
+ });
+ given(this.servletContext.getAttributeNames())
+ .willReturn(MockServletWebServer.emptyEnumeration());
+ given(this.servletContext.getNamedDispatcher("default"))
+ .willReturn(mock(RequestDispatcher.class));
+ for (Initializer initializer : this.initializers) {
+ initializer.onStartup(this.servletContext);
+ }
+ }
+ catch (ServletException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public void stop() {
+ this.servletContext = null;
+ this.registeredServlets.clear();
+ }
+
+ public ServletContext getServletContext() {
+ return this.servletContext;
+ }
+
+ public Servlet[] getServlets() {
+ Servlet[] servlets = new Servlet[this.registeredServlets.size()];
+ for (int i = 0; i < servlets.length; i++) {
+ servlets[i] = this.registeredServlets.get(i).getServlet();
+ }
+ return servlets;
+ }
+
+ public RegisteredServlet getRegisteredServlet(int index) {
+ return getRegisteredServlets().get(index);
+ }
+
+ public List getRegisteredServlets() {
+ return this.registeredServlets;
+ }
+
+ public RegisteredFilter getRegisteredFilters(int index) {
+ return getRegisteredFilters().get(index);
+ }
+
+ public List getRegisteredFilters() {
+ return this.registeredFilters;
+ }
+
+ public int getPort() {
+ return this.port;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Enumeration emptyEnumeration() {
+ return (Enumeration) EmptyEnumeration.EMPTY_ENUMERATION;
+ }
+
+ private static class EmptyEnumeration implements Enumeration {
+
+ static final MockServletWebServer.EmptyEnumeration
diff --git a/spring-boot/src/test/java/org/springframework/boot/BannerTests.java b/spring-boot/src/test/java/org/springframework/boot/BannerTests.java
index f006568fd85..ba6545c2100 100644
--- a/spring-boot/src/test/java/org/springframework/boot/BannerTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/BannerTests.java
@@ -27,7 +27,7 @@ import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.Banner.Mode;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
@@ -59,7 +59,7 @@ public class BannerTests {
}
@Rule
- public InternalOutputCapture out = new InternalOutputCapture();
+ public OutputCapture out = new OutputCapture();
@Captor
private ArgumentCaptor> sourceClassCaptor;
diff --git a/spring-boot/src/test/java/org/springframework/boot/SimpleMainTests.java b/spring-boot/src/test/java/org/springframework/boot/SimpleMainTests.java
index cb8c77b1039..b0a483daf1d 100644
--- a/spring-boot/src/test/java/org/springframework/boot/SimpleMainTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/SimpleMainTests.java
@@ -23,7 +23,7 @@ import java.util.List;
import org.junit.Rule;
import org.junit.Test;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class SimpleMainTests {
@Rule
- public InternalOutputCapture outputCapture = new InternalOutputCapture();
+ public OutputCapture outputCapture = new OutputCapture();
private static final String SPRING_STARTUP = "root of context hierarchy";
diff --git a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
index 83e7e48236a..8799ca3c0f1 100644
--- a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
@@ -50,7 +50,7 @@ import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.ApplicationStartingEvent;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
@@ -123,7 +123,7 @@ public class SpringApplicationTests {
public ExpectedException thrown = ExpectedException.none();
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
private ConfigurableApplicationContext context;
diff --git a/spring-boot/src/test/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializerTests.java
index af8ec74fc76..fbdb3c80d2a 100644
--- a/spring-boot/src/test/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializerTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializerTests.java
@@ -33,7 +33,7 @@ import org.springframework.boot.context.configwarnings.dflt.InDefaultPackageWith
import org.springframework.boot.context.configwarnings.orgspring.InOrgSpringPackageConfiguration;
import org.springframework.boot.context.configwarnings.real.InRealButScanningProblemPackages;
import org.springframework.boot.context.configwarnings.real.InRealPackageConfiguration;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
@@ -52,7 +52,7 @@ public class ConfigurationWarningsApplicationContextInitializerTests {
+ "start due to a @ComponentScan of 'org.springframework'.";
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
@Test
public void logWarningInDefaultPackage() {
diff --git a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
index ef0a1cc62b8..366e266aa6e 100644
--- a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
@@ -44,7 +44,7 @@ import org.springframework.boot.WebApplicationType;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.env.EnvironmentPostProcessor;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
@@ -83,7 +83,7 @@ public class ConfigFileApplicationListenerTests {
public ExpectedException expected = ExpectedException.none();
@Rule
- public InternalOutputCapture out = new InternalOutputCapture();
+ public OutputCapture out = new OutputCapture();
private ConfigurableApplicationContext context;
diff --git a/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerIntegrationTests.java b/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerIntegrationTests.java
index 039fba6b3a7..1990744c1fb 100644
--- a/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerIntegrationTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerIntegrationTests.java
@@ -25,7 +25,7 @@ import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.boot.logging.LoggingSystem;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class LoggingApplicationListenerIntegrationTests {
@Rule
- public InternalOutputCapture outputCapture = new InternalOutputCapture();
+ public OutputCapture outputCapture = new OutputCapture();
@Test
public void loggingSystemRegisteredInTheContext() {
diff --git a/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java
index 97865a7e989..452623738c4 100644
--- a/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java
@@ -42,8 +42,6 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.logging.AbstractLoggingSystem;
import org.springframework.boot.logging.LogFile;
import org.springframework.boot.logging.LogLevel;
@@ -51,7 +49,9 @@ import org.springframework.boot.logging.LoggerConfiguration;
import org.springframework.boot.logging.LoggingInitializationContext;
import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.logging.java.JavaLoggingSystem;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
@@ -87,7 +87,7 @@ public class LoggingApplicationListenerTests {
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
- public InternalOutputCapture outputCapture = new InternalOutputCapture();
+ public OutputCapture outputCapture = new OutputCapture();
private final LoggingApplicationListener initializer = new LoggingApplicationListener();
diff --git a/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java b/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java
index 4ddb0766184..7e764ad4dc7 100644
--- a/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java
@@ -39,7 +39,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.boot.context.properties.bind.BindException;
import org.springframework.boot.context.properties.bind.validation.BindValidationException;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -75,7 +75,7 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
public ExpectedException thrown = ExpectedException.none();
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
private AnnotationConfigApplicationContext context;
diff --git a/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersIntegrationTests.java b/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersIntegrationTests.java
index 2511bdeabff..ea29372b990 100644
--- a/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersIntegrationTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersIntegrationTests.java
@@ -23,7 +23,7 @@ import org.junit.Test;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.boot.web.server.PortInUseException;
import org.springframework.context.annotation.Configuration;
@@ -38,7 +38,7 @@ import static org.junit.Assert.fail;
public class FailureAnalyzersIntegrationTests {
@Rule
- public InternalOutputCapture outputCapture = new InternalOutputCapture();
+ public OutputCapture outputCapture = new OutputCapture();
@Test
public void analysisIsPerformed() {
diff --git a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/ValidationExceptionFailureAnalyzerTests.java b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/ValidationExceptionFailureAnalyzerTests.java
index 1be55cf125a..74781cfece4 100644
--- a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/ValidationExceptionFailureAnalyzerTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/ValidationExceptionFailureAnalyzerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@ import org.junit.runner.RunWith;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.diagnostics.FailureAnalysis;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot/src/test/java/org/springframework/boot/env/NoSnakeYamlPropertySourceLoaderTests.java b/spring-boot/src/test/java/org/springframework/boot/env/NoSnakeYamlPropertySourceLoaderTests.java
index 41ac5964bb0..3cb0f19c0e1 100644
--- a/spring-boot/src/test/java/org/springframework/boot/env/NoSnakeYamlPropertySourceLoaderTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/env/NoSnakeYamlPropertySourceLoaderTests.java
@@ -21,8 +21,8 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.core.io.ByteArrayResource;
/**
diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggingSystemTests.java
index d45ba1118a3..d56e516455f 100644
--- a/spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggingSystemTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggingSystemTests.java
@@ -34,7 +34,7 @@ import org.springframework.boot.logging.AbstractLoggingSystemTests;
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.logging.LoggerConfiguration;
import org.springframework.boot.logging.LoggingSystem;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -62,7 +62,7 @@ public class JavaLoggingSystemTests extends AbstractLoggingSystemTests {
getClass().getClassLoader());
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
private Logger logger;
diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java
index fa61d4823dd..d978de8ce73 100644
--- a/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java
@@ -41,8 +41,8 @@ import org.springframework.boot.logging.AbstractLoggingSystemTests;
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.logging.LoggerConfiguration;
import org.springframework.boot.logging.LoggingSystem;
-import org.springframework.boot.testutil.InternalOutputCapture;
-import org.springframework.boot.testutil.Matched;
+import org.springframework.boot.testsupport.assertj.Matched;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;
@@ -65,7 +65,7 @@ import static org.mockito.Mockito.verify;
public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests {
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
private final TestLog4J2LoggingSystem loggingSystem = new TestLog4J2LoggingSystem();
diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
index d408664a88e..2c5b047bd67 100644
--- a/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
@@ -45,8 +45,8 @@ import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.logging.LoggerConfiguration;
import org.springframework.boot.logging.LoggingInitializationContext;
import org.springframework.boot.logging.LoggingSystem;
-import org.springframework.boot.testutil.InternalOutputCapture;
-import org.springframework.boot.testutil.Matched;
+import org.springframework.boot.testsupport.assertj.Matched;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;
@@ -70,7 +70,7 @@ import static org.mockito.Mockito.verify;
public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
private final LogbackLoggingSystem loggingSystem = new LogbackLoggingSystem(
getClass().getClassLoader());
diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java
index 76434a558df..eba0279be16 100644
--- a/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java
@@ -30,7 +30,7 @@ import org.slf4j.impl.StaticLoggerBinder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.logging.LoggingInitializationContext;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.context.support.TestPropertySourceUtils;
@@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.not;
public class SpringBootJoranConfiguratorTests {
@Rule
- public InternalOutputCapture out = new InternalOutputCapture();
+ public OutputCapture out = new OutputCapture();
private MockEnvironment environment;
diff --git a/spring-boot/src/test/java/org/springframework/boot/validation/MessageInterpolatorFactoryWithoutElIntegrationTests.java b/spring-boot/src/test/java/org/springframework/boot/validation/MessageInterpolatorFactoryWithoutElIntegrationTests.java
index e8fb801fb13..1e95c6e33b4 100644
--- a/spring-boot/src/test/java/org/springframework/boot/validation/MessageInterpolatorFactoryWithoutElIntegrationTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/validation/MessageInterpolatorFactoryWithoutElIntegrationTests.java
@@ -26,8 +26,8 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
-import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
+import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java
index 18751ecf051..1b32b6af26d 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java
@@ -48,7 +48,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.mockito.InOrder;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
@@ -74,7 +74,7 @@ public class TomcatServletWebServerFactoryTests
extends AbstractServletWebServerFactoryTests {
@Rule
- public InternalOutputCapture outputCapture = new InternalOutputCapture();
+ public OutputCapture outputCapture = new OutputCapture();
@Override
protected TomcatServletWebServerFactory getFactory() {
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java
index de6fd7c85c7..c9d27359013 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java
@@ -38,13 +38,13 @@ import org.apache.jasper.servlet.JspServlet;
import org.junit.Test;
import org.mockito.InOrder;
+import org.springframework.boot.testsupport.web.servlet.ExampleServlet;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.MimeMappings.Mapping;
import org.springframework.boot.web.server.PortInUseException;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests;
-import org.springframework.boot.web.servlet.server.ExampleServlet;
import org.springframework.http.HttpStatus;
import org.springframework.test.util.ReflectionTestUtils;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java
index 4d64c4271cc..b3ba0d4cb11 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java
@@ -24,7 +24,7 @@ import org.junit.rules.TemporaryFolder;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.boot.web.server.WebServer;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -52,7 +52,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
protected WebServer webServer;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java
index 6860c5253e3..46357aebd0b 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationBeanTests.java
@@ -20,7 +20,7 @@ import javax.servlet.Filter;
import org.junit.Test;
-import org.springframework.boot.testutil.MockFilter;
+import org.springframework.boot.web.servlet.mock.MockFilter;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationIntegrationTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationIntegrationTests.java
index da814ac689b..3f67aacf56c 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationIntegrationTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationIntegrationTests.java
@@ -21,9 +21,9 @@ import javax.servlet.Filter;
import org.junit.After;
import org.junit.Test;
-import org.springframework.boot.testutil.MockFilter;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
+import org.springframework.boot.web.servlet.mock.MockFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java
index 6331d463119..9e3de86b7f3 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java
@@ -35,7 +35,7 @@ import org.junit.rules.ExpectedException;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.springframework.boot.testutil.MockServlet;
+import org.springframework.boot.web.servlet.mock.MockServlet;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java
index c86f27a968d..ad7e3596813 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java
@@ -28,8 +28,8 @@ import javax.servlet.ServletResponse;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.testutil.MockServlet;
import org.springframework.boot.web.servlet.context.config.ExampleServletWebServerApplicationConfiguration;
+import org.springframework.boot.web.servlet.mock.MockServlet;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/config/ExampleServletWebServerApplicationConfiguration.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/config/ExampleServletWebServerApplicationConfiguration.java
index b6586beb7b8..02204df83d0 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/config/ExampleServletWebServerApplicationConfiguration.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/config/ExampleServletWebServerApplicationConfiguration.java
@@ -18,8 +18,8 @@ package org.springframework.boot.web.servlet.context.config;
import javax.servlet.Servlet;
-import org.springframework.boot.testutil.MockServlet;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContextTests;
+import org.springframework.boot.web.servlet.mock.MockServlet;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/spring-boot/src/test/java/org/springframework/boot/testutil/MockFilter.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/MockFilter.java
similarity index 91%
rename from spring-boot/src/test/java/org/springframework/boot/testutil/MockFilter.java
rename to spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/MockFilter.java
index dcda41151e5..57148c35694 100644
--- a/spring-boot/src/test/java/org/springframework/boot/testutil/MockFilter.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/MockFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.testutil;
+package org.springframework.boot.web.servlet.mock;
import java.io.IOException;
diff --git a/spring-boot/src/test/java/org/springframework/boot/testutil/MockServlet.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/MockServlet.java
similarity index 90%
rename from spring-boot/src/test/java/org/springframework/boot/testutil/MockServlet.java
rename to spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/MockServlet.java
index 0cb083a4f2f..0c09989035f 100644
--- a/spring-boot/src/test/java/org/springframework/boot/testutil/MockServlet.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/MockServlet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.boot.testutil;
+package org.springframework.boot.web.servlet.mock;
import java.io.IOException;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/package-info.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/package-info.java
new file mode 100644
index 00000000000..ba145974aa1
--- /dev/null
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/mock/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Additional mocks used for servlet testing.
+ */
+package org.springframework.boot.web.servlet.mock;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
index 25d820a15d2..5d712a4a590 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
@@ -83,7 +83,9 @@ import org.mockito.InOrder;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.ApplicationTemp;
-import org.springframework.boot.testutil.InternalOutputCapture;
+import org.springframework.boot.testsupport.rule.OutputCapture;
+import org.springframework.boot.testsupport.web.servlet.ExampleFilter;
+import org.springframework.boot.testsupport.web.servlet.ExampleServlet;
import org.springframework.boot.web.server.Compression;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.MimeMappings;
@@ -133,7 +135,7 @@ public abstract class AbstractServletWebServerFactoryTests {
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
- public InternalOutputCapture output = new InternalOutputCapture();
+ public OutputCapture output = new OutputCapture();
protected WebServer webServer;
diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java
index ef71941151d..0adaaa44520 100644
--- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java
+++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java
@@ -16,33 +16,16 @@
package org.springframework.boot.web.servlet.server;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
+import java.util.Arrays;
-import javax.servlet.Filter;
-import javax.servlet.FilterRegistration;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRegistration;
-
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
+import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter;
+import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredServlet;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.boot.web.servlet.ServletContextInitializer;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
/**
@@ -67,193 +50,31 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory
}
public ServletContext getServletContext() {
- return getWebServer() == null ? null : getWebServer().servletContext;
+ return getWebServer() == null ? null : getWebServer().getServletContext();
}
public RegisteredServlet getRegisteredServlet(int index) {
- return getWebServer() == null ? null
- : getWebServer().getRegisteredServlets().get(index);
+ return getWebServer() == null ? null : getWebServer().getRegisteredServlet(index);
}
public RegisteredFilter getRegisteredFilter(int index) {
- return getWebServer() == null ? null
- : getWebServer().getRegisteredFilters().get(index);
+ return getWebServer() == null ? null : getWebServer().getRegisteredFilters(index);
}
- public static class MockServletWebServer implements WebServer {
-
- private ServletContext servletContext;
-
- private final ServletContextInitializer[] initializers;
-
- private final List registeredServlets = new ArrayList<>();
-
- private final List registeredFilters = new ArrayList<>();
-
- private final int port;
+ public static class MockServletWebServer
+ extends org.springframework.boot.testsupport.web.servlet.MockServletWebServer
+ implements WebServer {
public MockServletWebServer(ServletContextInitializer[] initializers, int port) {
- this.initializers = initializers;
- this.port = port;
- initialize();
- }
-
- private void initialize() {
- try {
- this.servletContext = mock(ServletContext.class);
- given(this.servletContext.addServlet(anyString(), (Servlet) any()))
- .willAnswer(new Answer() {
- @Override
- public ServletRegistration.Dynamic answer(
- InvocationOnMock invocation) throws Throwable {
- RegisteredServlet registeredServlet = new RegisteredServlet(
- (Servlet) invocation.getArguments()[1]);
- MockServletWebServer.this.registeredServlets
- .add(registeredServlet);
- return registeredServlet.getRegistration();
- }
- });
- given(this.servletContext.addFilter(anyString(), (Filter) any()))
- .willAnswer(new Answer() {
- @Override
- public FilterRegistration.Dynamic answer(
- InvocationOnMock invocation) throws Throwable {
- RegisteredFilter registeredFilter = new RegisteredFilter(
- (Filter) invocation.getArguments()[1]);
- MockServletWebServer.this.registeredFilters
- .add(registeredFilter);
- return registeredFilter.getRegistration();
- }
- });
- final Map initParameters = new HashMap<>();
- given(this.servletContext.setInitParameter(anyString(), anyString()))
- .will(new Answer() {
- @Override
- public Void answer(InvocationOnMock invocation)
- throws Throwable {
- initParameters.put(invocation.getArgument(0),
- invocation.getArgument(1));
- return null;
- }
-
- });
- given(this.servletContext.getInitParameterNames())
- .willReturn(Collections.enumeration(initParameters.keySet()));
- given(this.servletContext.getInitParameter(anyString()))
- .willAnswer(new Answer() {
- @Override
- public String answer(InvocationOnMock invocation)
- throws Throwable {
- return initParameters.get(invocation.getArgument(0));
- }
- });
- given(this.servletContext.getAttributeNames())
- .willReturn(MockServletWebServer.emptyEnumeration());
- given(this.servletContext.getNamedDispatcher("default"))
- .willReturn(mock(RequestDispatcher.class));
- for (ServletContextInitializer initializer : this.initializers) {
- initializer.onStartup(this.servletContext);
- }
- }
- catch (ServletException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- @SuppressWarnings("unchecked")
- public static Enumeration emptyEnumeration() {
- return (Enumeration) EmptyEnumeration.EMPTY_ENUMERATION;
+ super(Arrays.stream(initializers)
+ .map((i) -> (Initializer) (s) -> i.onStartup(s))
+ .toArray(Initializer[]::new), port);
}
@Override
public void start() throws WebServerException {
}
- @Override
- public void stop() {
- this.servletContext = null;
- this.registeredServlets.clear();
- }
-
- public Servlet[] getServlets() {
- Servlet[] servlets = new Servlet[this.registeredServlets.size()];
- for (int i = 0; i < servlets.length; i++) {
- servlets[i] = this.registeredServlets.get(i).getServlet();
- }
- return servlets;
- }
-
- public List getRegisteredServlets() {
- return this.registeredServlets;
- }
-
- public List getRegisteredFilters() {
- return this.registeredFilters;
- }
-
- @Override
- public int getPort() {
- return this.port;
- }
-
- private static class EmptyEnumeration implements Enumeration {
-
- static final EmptyEnumeration