You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2018/07/10 13:54:07 UTC
[cxf] branch master updated: Minor code cleanup removing use of
deprecated stuff and handling generics a bit better.
This is an automated email from the ASF dual-hosted git repository.
dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new 468cf8f Minor code cleanup removing use of deprecated stuff and handling generics a bit better.
468cf8f is described below
commit 468cf8f3cfe9ef8285cd2ae66caddf666b7aaf13
Author: Daniel Kulp <dk...@apache.org>
AuthorDate: Tue Jul 10 09:53:36 2018 -0400
Minor code cleanup removing use of deprecated stuff and handling generics a bit better.
---
.../boot/autoconfigure/CxfAutoConfiguration.java | 4 ++--
.../autoconfigure/CxfAutoConfigurationTests.java | 28 ++++++++++++++--------
.../saml/sso/SamlpRequestComponentBuilder.java | 1 +
.../http_jetty/spring/ApplicationContextTest.java | 2 --
.../server/spring/ApplicationContextTest.java | 2 --
.../spring/ApplicationContextTest.java | 2 --
.../systest/http_jetty/EngineLifecycleTest.java | 1 -
.../cxf/systest/bus/SpringBusFactoryTest.java | 2 +-
.../org/apache/cxf/test/AbstractCXFSpringTest.java | 1 -
9 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/CxfAutoConfiguration.java b/integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/CxfAutoConfiguration.java
index c8fe687..6231de9 100644
--- a/integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/CxfAutoConfiguration.java
+++ b/integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/CxfAutoConfiguration.java
@@ -58,10 +58,10 @@ public class CxfAutoConfiguration {
@Bean
@ConditionalOnMissingBean(name = "cxfServletRegistration")
- public ServletRegistrationBean cxfServletRegistration() {
+ public ServletRegistrationBean<CXFServlet> cxfServletRegistration() {
String path = this.properties.getPath();
String urlMapping = path.endsWith("/") ? path + "*" : path + "/*";
- ServletRegistrationBean registration = new ServletRegistrationBean(
+ ServletRegistrationBean<CXFServlet> registration = new ServletRegistrationBean<>(
new CXFServlet(), urlMapping);
CxfProperties.Servlet servletProperties = this.properties.getServlet();
registration.setLoadOnStartup(servletProperties.getLoadOnStartup());
diff --git a/integration/spring-boot/autoconfigure/src/test/java/org/apache/cxf/spring/boot/autoconfigure/CxfAutoConfigurationTests.java b/integration/spring-boot/autoconfigure/src/test/java/org/apache/cxf/spring/boot/autoconfigure/CxfAutoConfigurationTests.java
index e869a78..783a33a 100644
--- a/integration/spring-boot/autoconfigure/src/test/java/org/apache/cxf/spring/boot/autoconfigure/CxfAutoConfigurationTests.java
+++ b/integration/spring-boot/autoconfigure/src/test/java/org/apache/cxf/spring/boot/autoconfigure/CxfAutoConfigurationTests.java
@@ -20,7 +20,7 @@ package org.apache.cxf.spring.boot.autoconfigure;
import org.hamcrest.Matcher;
import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.boot.test.util.EnvironmentTestUtils;
+import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.mock.web.MockServletContext;
import org.springframework.test.util.ReflectionTestUtils;
@@ -34,6 +34,9 @@ import org.junit.rules.ExpectedException;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasItem;
+
+import java.util.Map;
+
import static org.junit.Assert.assertThat;
/**
@@ -72,8 +75,9 @@ public class CxfAutoConfigurationTests {
@Test
public void customPathWithTrailingSlash() {
load(CxfAutoConfiguration.class, "cxf.path=/valid/");
- assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings(),
- (Matcher) hasItem("/valid/*"));
+ ServletRegistrationBean<?> registrationBean = this.context.getBean(ServletRegistrationBean.class);
+ Matcher<java.lang.Iterable<? super String>> v = hasItem("/valid/*");
+ assertThat(registrationBean.getUrlMappings(), v);
}
@Test
@@ -81,14 +85,15 @@ public class CxfAutoConfigurationTests {
load(CxfAutoConfiguration.class, "cxf.path=/valid");
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class).size(),
equalTo(1));
- assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings(),
- (Matcher) hasItem("/valid/*"));
+ ServletRegistrationBean<?> registrationBean = this.context.getBean(ServletRegistrationBean.class);
+ Matcher<java.lang.Iterable<? super String>> v = hasItem("/valid/*");
+ assertThat(registrationBean.getUrlMappings(), v);
}
@Test
public void customLoadOnStartup() {
load(CxfAutoConfiguration.class, "cxf.servlet.load-on-startup=1");
- ServletRegistrationBean registrationBean = this.context
+ ServletRegistrationBean<?> registrationBean = this.context
.getBean(ServletRegistrationBean.class);
assertThat(ReflectionTestUtils.getField(registrationBean, "loadOnStartup"),
equalTo(1));
@@ -98,16 +103,19 @@ public class CxfAutoConfigurationTests {
public void customInitParameters() {
load(CxfAutoConfiguration.class, "cxf.servlet.init.key1=value1",
"spring.cxf.servlet.init.key2=value2");
- ServletRegistrationBean registrationBean = this.context
+ ServletRegistrationBean<?> registrationBean = this.context
.getBean(ServletRegistrationBean.class);
- assertThat(registrationBean.getInitParameters(), (Matcher) hasEntry("key1", "value1"));
- assertThat(registrationBean.getInitParameters(), (Matcher) hasEntry("key2", "value2"));
+ Matcher<Map<? extends String, ? extends String>> v1 = hasEntry("key1", "value1");
+ Matcher<Map<? extends String, ? extends String>> v2 = hasEntry("key2", "value2");
+
+ assertThat(registrationBean.getInitParameters(), v1);
+ assertThat(registrationBean.getInitParameters(), v2);
}
private void load(Class<?> config, String... environment) {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.setServletContext(new MockServletContext());
- EnvironmentTestUtils.addEnvironment(ctx, environment);
+ TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(config);
ctx.refresh();
this.context = ctx;
diff --git a/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlpRequestComponentBuilder.java b/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlpRequestComponentBuilder.java
index 6c581f0..554441d 100644
--- a/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlpRequestComponentBuilder.java
+++ b/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlpRequestComponentBuilder.java
@@ -95,6 +95,7 @@ public final class SamlpRequestComponentBuilder {
return authnRequest;
}
+ @SuppressWarnings("unchecked")
public static LogoutRequest createLogoutRequest(
SAMLVersion version,
Issuer issuer,
diff --git a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java b/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
index 6e809dc..1396511 100644
--- a/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
+++ b/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
@@ -85,7 +85,6 @@ public class ApplicationContextTest extends Assert {
//ctx.refresh();
checkContext(ctx);
ctx.close();
- ctx.destroy();
}
@Test
public void testContextWithProperties() throws Exception {
@@ -96,7 +95,6 @@ public class ApplicationContextTest extends Assert {
new String[] {S1, s4});
checkContext(ctx);
ctx.close();
- ctx.destroy();
}
private void checkContext(TestApplicationContext ctx) throws Exception {
ConfigurerImpl cfg = new ConfigurerImpl(ctx);
diff --git a/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/spring/ApplicationContextTest.java b/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/spring/ApplicationContextTest.java
index 703c130..c5ea154 100644
--- a/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/spring/ApplicationContextTest.java
+++ b/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/spring/ApplicationContextTest.java
@@ -85,7 +85,6 @@ public class ApplicationContextTest extends Assert {
//ctx.refresh();
checkContext(ctx);
ctx.close();
- ctx.destroy();
}
@Test
@@ -97,7 +96,6 @@ public class ApplicationContextTest extends Assert {
new String[] {S1, s4});
checkContext(ctx);
ctx.close();
- ctx.destroy();
}
private void checkContext(TestApplicationContext ctx) throws Exception {
ConfigurerImpl cfg = new ConfigurerImpl(ctx);
diff --git a/rt/transports/http-undertow/src/test/java/org/apache/cxf/transport/http_undertow/spring/ApplicationContextTest.java b/rt/transports/http-undertow/src/test/java/org/apache/cxf/transport/http_undertow/spring/ApplicationContextTest.java
index 538babb..68fbdda 100644
--- a/rt/transports/http-undertow/src/test/java/org/apache/cxf/transport/http_undertow/spring/ApplicationContextTest.java
+++ b/rt/transports/http-undertow/src/test/java/org/apache/cxf/transport/http_undertow/spring/ApplicationContextTest.java
@@ -85,7 +85,6 @@ public class ApplicationContextTest extends Assert {
checkContext(ctx);
ctx.close();
- ctx.destroy();
}
@Test
public void testContextWithProperties() throws Exception {
@@ -96,7 +95,6 @@ public class ApplicationContextTest extends Assert {
new String[] {S1, s4});
checkContext(ctx);
ctx.close();
- ctx.destroy();
}
private void checkContext(TestApplicationContext ctx) throws Exception {
ConfigurerImpl cfg = new ConfigurerImpl(ctx);
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
index 576fd94..5d25534 100644
--- a/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
@@ -142,7 +142,6 @@ public class EngineLifecycleTest extends Assert {
}
public void shutdownService() throws Exception {
- applicationContext.destroy();
applicationContext.close();
}
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
index 60f6ec6..d7a0a31 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
@@ -67,7 +67,7 @@ public class SpringBusFactoryTest extends Assert {
checkBindingExtensions(bus);
checkHTTPTransportFactories(bus);
checkOtherCoreExtensions(bus);
- ctx.destroy();
+ ctx.close();
}
@Test
public void testLoadBusWithApplicationContext() throws BusException {
diff --git a/testutils/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java b/testutils/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java
index b5641b3..ecce143 100644
--- a/testutils/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java
+++ b/testutils/src/main/java/org/apache/cxf/test/AbstractCXFSpringTest.java
@@ -77,7 +77,6 @@ public abstract class AbstractCXFSpringTest extends AbstractCXFTest {
@After
public void teardownBeans() {
applicationContext.close();
- applicationContext.destroy();
applicationContext = null;
}