From bd9e3877f9d3d3f56d7268a8189fe333bccee818 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Mon, 15 Oct 2018 15:46:03 -0600 Subject: [PATCH] JDK 10 Compatibility Upgrading dependencies and reconfiguring PowerMock Issue: gh-5860 --- .../config/SecurityNamespaceHandlerTests.java | 17 ++++++++++++---- ...curityConfigurerAdapterPowermockTests.java | 10 +++++++--- .../WebSecurityConfigurerAdapterTests.java | 19 ++++++++++-------- ...ionManagementConfigurerServlet31Tests.java | 18 +++++++++-------- ...SessionManagementConfigServlet31Tests.java | 20 +++++++++---------- gradle/dependency-management.gradle | 2 +- ...ng-security-samples-javaconfig-form.gradle | 4 ++++ ...ng-security-samples-javaconfig-jdbc.gradle | 4 ++++ 8 files changed, 60 insertions(+), 34 deletions(-) diff --git a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java index c457f0a63f..9f5def988c 100644 --- a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java +++ b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java @@ -15,23 +15,31 @@ */ package org.springframework.security.config; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Matchers.*; -import static org.powermock.api.mockito.PowerMockito.*; - import org.apache.commons.logging.Log; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; + import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.messaging.Message; import org.springframework.security.config.util.InMemoryXmlApplicationContext; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.util.ClassUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.powermock.api.mockito.PowerMockito.doThrow; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.spy; +import static org.powermock.api.mockito.PowerMockito.verifyStatic; +import static org.powermock.api.mockito.PowerMockito.verifyZeroInteractions; + /** * * @author Luke Taylor @@ -40,6 +48,7 @@ import org.springframework.util.ClassUtils; */ @RunWith(PowerMockRunner.class) @PrepareForTest({ ClassUtils.class }) +@PowerMockIgnore({ "org.w3c.dom.*", "org.xml.sax.*", "org.apache.xerces.*", "javax.xml.parsers.*" }) public class SecurityNamespaceHandlerTests { @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterPowermockTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterPowermockTests.java index c3d837def5..c6d9c1a01b 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterPowermockTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterPowermockTests.java @@ -15,16 +15,15 @@ */ package org.springframework.security.config.annotation.web; -import static org.assertj.core.api.Assertions.assertThat; -import static org.powermock.api.mockito.PowerMockito.*; - import java.util.Arrays; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; + import org.springframework.core.io.support.SpringFactoriesLoader; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @@ -33,6 +32,10 @@ import org.springframework.security.config.annotation.web.configurers.AbstractHt import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import static org.assertj.core.api.Assertions.assertThat; +import static org.powermock.api.mockito.PowerMockito.spy; +import static org.powermock.api.mockito.PowerMockito.when; + /** * * @author Rob Winch @@ -40,6 +43,7 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon */ @RunWith(PowerMockRunner.class) @PrepareForTest({ SpringFactoriesLoader.class }) +@PowerMockIgnore({ "org.w3c.dom.*", "org.xml.sax.*", "org.apache.xerces.*", "javax.xml.parsers.*" }) public class WebSecurityConfigurerAdapterPowermockTests { ConfigurableWebApplicationContext context; diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.java index db8c39b5ad..5e3f922297 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.java @@ -15,12 +15,22 @@ */ package org.springframework.security.config.annotation.web; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationListener; @@ -48,14 +58,6 @@ import org.springframework.web.context.request.async.WebAsyncManager; import org.springframework.web.context.request.async.WebAsyncUtils; import org.springframework.web.filter.OncePerRequestFilter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.ThrowableAssert.catchThrowable; import static org.mockito.ArgumentMatchers.any; @@ -75,6 +77,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @PrepareForTest({WebAsyncManager.class}) @RunWith(PowerMockRunner.class) +@PowerMockIgnore({ "org.w3c.dom.*", "org.xml.sax.*", "org.apache.xerces.*", "javax.xml.parsers.*", "javax.xml.transform.*" }) public class WebSecurityConfigurerAdapterTests { @Rule public final SpringTestRule spring = new SpringTestRule(); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerServlet31Tests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerServlet31Tests.java index 6d5113c9ba..83b236cd2e 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerServlet31Tests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurerServlet31Tests.java @@ -15,15 +15,7 @@ */ package org.springframework.security.config.annotation.web.configurers; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.same; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; - import java.lang.reflect.Method; - import javax.servlet.Filter; import javax.servlet.http.HttpServletRequest; @@ -32,8 +24,10 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; + import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.mock.web.MockFilterChain; @@ -52,12 +46,20 @@ import org.springframework.security.web.csrf.CsrfToken; import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository; import org.springframework.util.ReflectionUtils; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.same; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.spy; +import static org.powermock.api.mockito.PowerMockito.verifyStatic; +import static org.powermock.api.mockito.PowerMockito.when; + /** * * @author Rob Winch */ @RunWith(PowerMockRunner.class) @PrepareForTest({ ReflectionUtils.class, Method.class }) +@PowerMockIgnore({ "org.w3c.dom.*", "org.xml.sax.*", "org.apache.xerces.*", "javax.xml.parsers.*" }) public class SessionManagementConfigurerServlet31Tests { @Mock Method method; diff --git a/config/src/test/java/org/springframework/security/config/http/SessionManagementConfigServlet31Tests.java b/config/src/test/java/org/springframework/security/config/http/SessionManagementConfigServlet31Tests.java index a1bf8cea93..b4a1c79d39 100644 --- a/config/src/test/java/org/springframework/security/config/http/SessionManagementConfigServlet31Tests.java +++ b/config/src/test/java/org/springframework/security/config/http/SessionManagementConfigServlet31Tests.java @@ -15,15 +15,7 @@ */ package org.springframework.security.config.http; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.same; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; - import java.lang.reflect.Method; - import javax.servlet.Filter; import javax.servlet.http.HttpServletRequest; @@ -32,14 +24,14 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; + import org.springframework.context.ConfigurableApplicationContext; import org.springframework.mock.web.MockFilterChain; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; - - import org.springframework.security.config.util.InMemoryXmlApplicationContext; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextImpl; @@ -47,12 +39,20 @@ import org.springframework.security.web.context.HttpRequestResponseHolder; import org.springframework.security.web.context.HttpSessionSecurityContextRepository; import org.springframework.util.ReflectionUtils; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.same; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.spy; +import static org.powermock.api.mockito.PowerMockito.verifyStatic; +import static org.powermock.api.mockito.PowerMockito.when; + /** * @author Rob Winch * */ @RunWith(PowerMockRunner.class) @PrepareForTest({ ReflectionUtils.class, Method.class }) +@PowerMockIgnore({ "org.w3c.dom.*", "org.xml.sax.*", "org.apache.xerces.*", "javax.xml.parsers.*" }) public class SessionManagementConfigServlet31Tests { private static final String XML_AUTHENTICATION_MANAGER = "" + " " + " " diff --git a/gradle/dependency-management.gradle b/gradle/dependency-management.gradle index 3291aab0a9..cad7319887 100644 --- a/gradle/dependency-management.gradle +++ b/gradle/dependency-management.gradle @@ -182,7 +182,7 @@ dependencyManagement { dependency 'org.mockito:mockito-core:2.22.0' dependency 'org.objenesis:objenesis:2.6' dependency 'org.openid4java:openid4java-nodeps:0.9.6' - dependency 'org.ow2.asm:asm:6.0' + dependency 'org.ow2.asm:asm:6.2.1' dependency 'org.reactivestreams:reactive-streams:1.0.1' dependency 'org.seleniumhq.selenium:htmlunit-driver:2.33.0' dependency 'org.seleniumhq.selenium:selenium-java:3.14.0' diff --git a/samples/javaconfig/form/spring-security-samples-javaconfig-form.gradle b/samples/javaconfig/form/spring-security-samples-javaconfig-form.gradle index 476733e3bb..09049fa989 100644 --- a/samples/javaconfig/form/spring-security-samples-javaconfig-form.gradle +++ b/samples/javaconfig/form/spring-security-samples-javaconfig-form.gradle @@ -27,6 +27,10 @@ dependencies { compile 'org.springframework:spring-webmvc' compile slf4jDependencies + compile 'javax.xml.bind:jaxb-api' + compile 'com.sun.xml.bind:jaxb-core' + compile 'com.sun.xml.bind:jaxb-impl' + providedCompile 'javax.servlet.jsp:javax.servlet.jsp-api' providedCompile 'javax.servlet:javax.servlet-api' diff --git a/samples/javaconfig/jdbc/spring-security-samples-javaconfig-jdbc.gradle b/samples/javaconfig/jdbc/spring-security-samples-javaconfig-jdbc.gradle index 80a9ec87a4..bc5b6135ad 100644 --- a/samples/javaconfig/jdbc/spring-security-samples-javaconfig-jdbc.gradle +++ b/samples/javaconfig/jdbc/spring-security-samples-javaconfig-jdbc.gradle @@ -28,6 +28,10 @@ dependencies { compile 'org.hibernate:hibernate-validator' compile slf4jDependencies + compile 'javax.xml.bind:jaxb-api' + compile 'com.sun.xml.bind:jaxb-core' + compile 'com.sun.xml.bind:jaxb-impl' + providedCompile 'javax.servlet.jsp:javax.servlet.jsp-api' providedCompile 'javax.servlet:javax.servlet-api'