Commit b71daac5 authored by Andy Wilkinson's avatar Andy Wilkinson

Remove redundant logic for uninstalling Tomcat's URL stream handler factory

Closes gh-8622
parent 5810ae28
...@@ -16,19 +16,14 @@ ...@@ -16,19 +16,14 @@
package org.springframework.boot.autoconfigure.jersey; package org.springframework.boot.autoconfigure.jersey;
import java.net.URL;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.Wrapper; import org.apache.catalina.Wrapper;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.apache.tomcat.util.buf.UDecoder; import org.apache.tomcat.util.buf.UDecoder;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer; import org.glassfish.jersey.servlet.ServletContainer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -47,7 +42,6 @@ import org.springframework.context.annotation.Configuration; ...@@ -47,7 +42,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -65,14 +59,6 @@ public class JerseyAutoConfigurationServletContainerTests { ...@@ -65,14 +59,6 @@ public class JerseyAutoConfigurationServletContainerTests {
@ClassRule @ClassRule
public static OutputCapture output = new OutputCapture(); public static OutputCapture output = new OutputCapture();
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void existingJerseyServletIsAmended() { public void existingJerseyServletIsAmended() {
assertThat(output.toString()) assertThat(output.toString())
......
...@@ -17,16 +17,12 @@ ...@@ -17,16 +17,12 @@
package org.springframework.boot.autoconfigure.security; package org.springframework.boot.autoconfigure.security;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleModule;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -47,7 +43,6 @@ import org.springframework.context.annotation.Import; ...@@ -47,7 +43,6 @@ import org.springframework.context.annotation.Import;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -61,14 +56,6 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests { ...@@ -61,14 +56,6 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
// gh-4154 // gh-4154
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void testSecurityFilterDoesNotCauseEarlyInitialization() throws Exception { public void testSecurityFilterDoesNotCauseEarlyInitialization() throws Exception {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(); AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
......
...@@ -17,15 +17,11 @@ ...@@ -17,15 +17,11 @@
package org.springframework.boot.autoconfigure.security.oauth2; package org.springframework.boot.autoconfigure.security.oauth2;
import java.net.URI; import java.net.URI;
import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.Base64; import java.util.Base64;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
...@@ -123,14 +119,6 @@ public class OAuth2AutoConfigurationTests { ...@@ -123,14 +119,6 @@ public class OAuth2AutoConfigurationTests {
private AnnotationConfigServletWebServerApplicationContext context; private AnnotationConfigServletWebServerApplicationContext context;
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void testDefaultConfiguration() { public void testDefaultConfiguration() {
this.context = new AnnotationConfigServletWebServerApplicationContext(); this.context = new AnnotationConfigServletWebServerApplicationContext();
......
...@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.web.servlet; ...@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.web.servlet;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
...@@ -34,13 +33,10 @@ import org.apache.catalina.Context; ...@@ -34,13 +33,10 @@ import org.apache.catalina.Context;
import org.apache.catalina.Valve; import org.apache.catalina.Valve;
import org.apache.catalina.valves.AccessLogValve; import org.apache.catalina.valves.AccessLogValve;
import org.apache.catalina.valves.RemoteIpValve; import org.apache.catalina.valves.RemoteIpValve;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.apache.coyote.AbstractProtocol; import org.apache.coyote.AbstractProtocol;
import org.eclipse.jetty.server.NCSARequestLog; import org.eclipse.jetty.server.NCSARequestLog;
import org.eclipse.jetty.server.RequestLog; import org.eclipse.jetty.server.RequestLog;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
...@@ -59,7 +55,6 @@ import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFa ...@@ -59,7 +55,6 @@ import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFa
import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.mock.env.MockEnvironment; import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean;
...@@ -90,14 +85,6 @@ public class DefaultServletWebServerFactoryCustomizerTests { ...@@ -90,14 +85,6 @@ public class DefaultServletWebServerFactoryCustomizerTests {
this.customizer = new DefaultServletWebServerFactoryCustomizer(this.properties); this.customizer = new DefaultServletWebServerFactoryCustomizer(this.properties);
} }
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void tomcatAccessLogIsDisabledByDefault() { public void tomcatAccessLogIsDisabledByDefault() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
......
...@@ -17,13 +17,10 @@ ...@@ -17,13 +17,10 @@
package org.springframework.boot.autoconfigure.web.servlet; package org.springframework.boot.autoconfigure.web.servlet;
import java.net.URI; import java.net.URI;
import java.net.URL;
import javax.servlet.MultipartConfigElement; import javax.servlet.MultipartConfigElement;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.After; import org.junit.After;
import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
...@@ -80,14 +77,6 @@ public class MultipartAutoConfigurationTests { ...@@ -80,14 +77,6 @@ public class MultipartAutoConfigurationTests {
} }
} }
@Before
@After
public void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void webServerWithNothing() throws Exception { public void webServerWithNothing() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext( this.context = new AnnotationConfigServletWebServerApplicationContext(
......
...@@ -16,14 +16,9 @@ ...@@ -16,14 +16,9 @@
package org.springframework.boot.autoconfigure.web.servlet; package org.springframework.boot.autoconfigure.web.servlet;
import java.net.URL;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener; import javax.servlet.ServletContextListener;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
...@@ -35,7 +30,6 @@ import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebSe ...@@ -35,7 +30,6 @@ import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebSe
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -48,14 +42,6 @@ import static org.mockito.Mockito.verify; ...@@ -48,14 +42,6 @@ import static org.mockito.Mockito.verify;
*/ */
public class ServletWebServerServletContextListenerTests { public class ServletWebServerServletContextListenerTests {
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void registeredServletContextListenerBeanIsCalledByJetty() { public void registeredServletContextListenerBeanIsCalledByJetty() {
registeredServletContextListenerBeanIsCalled(JettyConfiguration.class); registeredServletContextListenerBeanIsCalled(JettyConfiguration.class);
......
...@@ -22,7 +22,6 @@ import java.lang.annotation.Retention; ...@@ -22,7 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.net.URI; import java.net.URI;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -33,10 +32,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -33,10 +32,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
...@@ -55,7 +51,6 @@ import org.springframework.http.HttpStatus; ...@@ -55,7 +51,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity; import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.validation.BindException; import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -86,14 +81,6 @@ public class BasicErrorControllerIntegrationTests { ...@@ -86,14 +81,6 @@ public class BasicErrorControllerIntegrationTests {
} }
} }
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public void testErrorForMachineClient() throws Exception { public void testErrorForMachineClient() throws Exception {
......
...@@ -16,15 +16,10 @@ ...@@ -16,15 +16,10 @@
package org.springframework.boot.autoconfigure.websocket; package org.springframework.boot.autoconfigure.websocket;
import java.net.URL;
import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerContainer;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
...@@ -34,7 +29,6 @@ import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebSe ...@@ -34,7 +29,6 @@ import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebSe
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -59,14 +53,6 @@ public class WebSocketAutoConfigurationTests { ...@@ -59,14 +53,6 @@ public class WebSocketAutoConfigurationTests {
} }
} }
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void tomcatServerContainerIsAvailableFromTheServletContext() { public void tomcatServerContainerIsAvailableFromTheServletContext() {
serverContainerIsAvailableFromTheServletContext(TomcatConfiguration.class, serverContainerIsAvailableFromTheServletContext(TomcatConfiguration.class,
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.websocket; package org.springframework.boot.autoconfigure.websocket;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
...@@ -27,12 +26,9 @@ import java.util.concurrent.TimeUnit; ...@@ -27,12 +26,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.apache.tomcat.websocket.WsWebSocketContainer; import org.apache.tomcat.websocket.WsWebSocketContainer;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
...@@ -101,14 +97,6 @@ public class WebSocketMessagingAutoConfigurationTests { ...@@ -101,14 +97,6 @@ public class WebSocketMessagingAutoConfigurationTests {
this.sockJsClient.stop(); this.sockJsClient.stop();
} }
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void basicMessagingWithJsonResponse() throws Throwable { public void basicMessagingWithJsonResponse() throws Throwable {
Object result = performStompSubscription("/app/json"); Object result = performStompSubscription("/app/json");
......
...@@ -16,13 +16,9 @@ ...@@ -16,13 +16,9 @@
package org.springframework.boot.devtools.integrationtest; package org.springframework.boot.devtools.integrationtest;
import java.net.URL;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -52,7 +48,6 @@ import org.springframework.http.HttpStatus; ...@@ -52,7 +48,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -73,14 +68,6 @@ public class HttpTunnelIntegrationTests { ...@@ -73,14 +68,6 @@ public class HttpTunnelIntegrationTests {
@Autowired @Autowired
private Config config; private Config config;
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void httpServerDirect() throws Exception { public void httpServerDirect() throws Exception {
String url = "http://localhost:" + this.config.httpServerPort + "/hello"; String url = "http://localhost:" + this.config.httpServerPort + "/hello";
......
...@@ -16,13 +16,8 @@ ...@@ -16,13 +16,8 @@
package org.springframework.boot.context.embedded; package org.springframework.boot.context.embedded;
import java.net.URL;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.apache.tomcat.util.http.LegacyCookieProcessor; import org.apache.tomcat.util.http.LegacyCookieProcessor;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
...@@ -33,7 +28,6 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostPro ...@@ -33,7 +28,6 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostPro
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -44,14 +38,6 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -44,14 +38,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
public class TomcatLegacyCookieProcessorExampleTests { public class TomcatLegacyCookieProcessorExampleTests {
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void cookieProcessorIsCustomized() { public void cookieProcessorIsCustomized() {
ServletWebServerApplicationContext applicationContext = (ServletWebServerApplicationContext) new SpringApplication( ServletWebServerApplicationContext applicationContext = (ServletWebServerApplicationContext) new SpringApplication(
......
...@@ -16,13 +16,8 @@ ...@@ -16,13 +16,8 @@
package org.springframework.boot.test.context; package org.springframework.boot.test.context;
import java.net.URL;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -33,7 +28,6 @@ import org.springframework.boot.web.server.LocalServerPort; ...@@ -33,7 +28,6 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
...@@ -65,14 +59,6 @@ public abstract class AbstractSpringBootTestWebServerWebEnvironmentTests { ...@@ -65,14 +59,6 @@ public abstract class AbstractSpringBootTestWebServerWebEnvironmentTests {
@Autowired @Autowired
private TestRestTemplate restTemplate; private TestRestTemplate restTemplate;
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
public WebApplicationContext getContext() { public WebApplicationContext getContext() {
return this.context; return this.context;
} }
......
...@@ -16,12 +16,7 @@ ...@@ -16,12 +16,7 @@
package org.springframework.boot.web.reactive.server; package org.springframework.boot.web.reactive.server;
import java.net.URL;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
...@@ -36,7 +31,6 @@ import org.springframework.http.MediaType; ...@@ -36,7 +31,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.ClientResponse;
...@@ -74,14 +68,6 @@ public abstract class AbstractReactiveWebServerFactoryTests { ...@@ -74,14 +68,6 @@ public abstract class AbstractReactiveWebServerFactoryTests {
} }
} }
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
protected abstract AbstractReactiveWebServerFactory getFactory(); protected abstract AbstractReactiveWebServerFactory getFactory();
@Test @Test
......
...@@ -17,13 +17,9 @@ ...@@ -17,13 +17,9 @@
package org.springframework.boot.web.servlet.context; package org.springframework.boot.web.servlet.context;
import java.net.URI; import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
...@@ -42,7 +38,6 @@ import org.springframework.http.client.ClientHttpRequest; ...@@ -42,7 +38,6 @@ import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.StreamUtils; import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -72,14 +67,6 @@ public class ServletWebServerMvcIntegrationTests { ...@@ -72,14 +67,6 @@ public class ServletWebServerMvcIntegrationTests {
} }
} }
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Test @Test
public void tomcat() throws Exception { public void tomcat() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext( this.context = new AnnotationConfigServletWebServerApplicationContext(
......
...@@ -59,7 +59,6 @@ import javax.servlet.ServletResponse; ...@@ -59,7 +59,6 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.InputStreamFactory; import org.apache.http.client.entity.InputStreamFactory;
import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.client.protocol.HttpClientContext;
...@@ -73,9 +72,7 @@ import org.apache.http.ssl.TrustStrategy; ...@@ -73,9 +72,7 @@ import org.apache.http.ssl.TrustStrategy;
import org.apache.jasper.EmbeddedServletOptions; import org.apache.jasper.EmbeddedServletOptions;
import org.apache.jasper.servlet.JspServlet; import org.apache.jasper.servlet.JspServlet;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assume; import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
...@@ -140,14 +137,6 @@ public abstract class AbstractServletWebServerFactoryTests { ...@@ -140,14 +137,6 @@ public abstract class AbstractServletWebServerFactoryTests {
private final HttpClientContext httpClientContext = HttpClientContext.create(); private final HttpClientContext httpClientContext = HttpClientContext.create();
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
null);
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@After @After
public void tearDown() { public void tearDown() {
if (this.webServer != null) { if (this.webServer != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment