INT-2689 - SI builds without warnings (Except Spring Integration HTTP)

* Ensure that no deprecation warnings occur
* Spring Integration builds with all tests successfully for Spring 3.1.2.RELEASE and 3.0.7.RELEASE (Except Spring Integration HTTP)

For reference see: https://jira.springsource.org/browse/INT-2689

INT-2694 - Fix Http Test Failures with Spring 3.0

As part of INT-2689, fix Http Test Failures in the Spring Integration Http Module when using Spring 3.0.7.RELEASE
For reference see: https://jira.springsource.org/browse/INT-2694
This commit is contained in:
Gunnar Hillert
2012-07-30 15:34:47 -04:00
committed by Oleg Zhurakousky
parent 19c53ed9e9
commit 57bc67b8fb
27 changed files with 283 additions and 168 deletions

View File

@@ -45,8 +45,9 @@ subprojects { subproject ->
junitVersion = '4.8.2' junitVersion = '4.8.2'
log4jVersion = '1.2.12' log4jVersion = '1.2.12'
mockitoVersion = '1.9.0' mockitoVersion = '1.9.0'
// When changing Spring Versions - don't forget to update bundlor ranges // When changing Spring Versions - don't forget to update bundlor ranges
springVersion = '3.1.2.RELEASE' springVersion = project.hasProperty('springVersion') ? getProperty('springVersion') : '3.1.2.RELEASE'
springAmqpVersion = '1.1.1.RELEASE' springAmqpVersion = '1.1.1.RELEASE'
springDataMongoVersion = '1.1.0.M1' springDataMongoVersion = '1.1.0.M1'
springDataRedisVersion = '1.0.1.RELEASE' springDataRedisVersion = '1.0.1.RELEASE'
@@ -355,7 +356,7 @@ project('spring-integration-http') {
dependencies { dependencies {
compile project(":spring-integration-core") compile project(":spring-integration-core")
compile "org.springframework:spring-webmvc:$springVersion" compile "org.springframework:spring-webmvc:$springVersion"
compile("javax.servlet:servlet-api:2.4", provided) compile("javax.servlet:javax.servlet-api:3.0.1", provided)
compile("commons-httpclient:commons-httpclient:3.1") { dep -> compile("commons-httpclient:commons-httpclient:3.1") { dep ->
optional dep optional dep
exclude group: 'junit', module: 'junit' exclude group: 'junit', module: 'junit'
@@ -517,12 +518,15 @@ project('spring-integration-jpa') {
testCompile "org.aspectj:aspectjrt:$aspectjVersion" testCompile "org.aspectj:aspectjrt:$aspectjVersion"
testCompile "org.aspectj:aspectjweaver:$aspectjVersion" testCompile "org.aspectj:aspectjweaver:$aspectjVersion"
testCompile "org.hibernate:hibernate-entitymanager:4.0.1.Final" testCompile "org.hibernate:hibernate-entitymanager:3.6.10.Final"
testCompile "org.eclipse.persistence:org.eclipse.persistence.jpa:2.3.2" testCompile "org.eclipse.persistence:org.eclipse.persistence.jpa:2.3.2"
testCompile "org.apache.openjpa:openjpa:2.2.0" testCompile "org.apache.openjpa:openjpa:2.2.0"
javaAgentSpringInstrument "org.springframework:spring-instrument:$springVersion" javaAgentSpringInstrument "org.springframework:spring-instrument:$springVersion"
javaAgentOpenJpa "org.apache.openjpa:openjpa:2.2.0" javaAgentOpenJpa "org.apache.openjpa:openjpa:2.2.0"
//Suppress openjpa annotation processor warnings
compileTestJava.options.compilerArgs = ["${xLintArg},-processing"]
} }
bundlor { bundlor {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ import org.springframework.util.ReflectionUtils.MethodCallback;
* Helper to provide common features for inspecting objects and locating annotated methods. * Helper to provide common features for inspecting objects and locating annotated methods.
* *
* @author Dave Syer * @author Dave Syer
* @author Gunnar Hillert
* *
*/ */
abstract class AnnotationFinder { abstract class AnnotationFinder {
@@ -45,6 +46,7 @@ abstract class AnnotationFinder {
return reference.get(); return reference.get();
} }
@SuppressWarnings("deprecation")
private static Class<?> getTargetClass(Object targetObject) { private static Class<?> getTargetClass(Object targetObject) {
Class<?> targetClass = targetObject.getClass(); Class<?> targetClass = targetObject.getClass();
if (AopUtils.isAopProxy(targetObject)) { if (AopUtils.isAopProxy(targetObject)) {

View File

@@ -100,6 +100,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
return this.messagingTemplate; return this.messagingTemplate;
} }
@SuppressWarnings("deprecation")
protected ConversionService getRequiredConversionService() { protected ConversionService getRequiredConversionService() {
if (this.getConversionService() == null) { if (this.getConversionService() == null) {
this.setConversionService(ConversionServiceFactory.createDefaultConversionService()); this.setConversionService(ConversionServiceFactory.createDefaultConversionService());

View File

@@ -63,6 +63,7 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer<Map<?,?>,
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.integration.transformer.AbstractPayloadTransformer#transformPayload(java.lang.Object) * @see org.springframework.integration.transformer.AbstractPayloadTransformer#transformPayload(java.lang.Object)
*/ */
@SuppressWarnings("deprecation")
protected Object transformPayload(Map<?,?> payload) throws Exception { protected Object transformPayload(Map<?,?> payload) throws Exception {
Object target = (this.targetClass != null) Object target = (this.targetClass != null)
? BeanUtils.instantiate(this.targetClass) ? BeanUtils.instantiate(this.targetClass)

View File

@@ -43,6 +43,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
private volatile ConversionService conversionService; private volatile ConversionService conversionService;
@SuppressWarnings("deprecation")
public BeanFactoryTypeConverter() { public BeanFactoryTypeConverter() {
synchronized (BeanFactoryTypeConverter.class) { synchronized (BeanFactoryTypeConverter.class) {
if (defaultConversionService == null) { if (defaultConversionService == null) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -72,6 +72,8 @@ import org.springframework.util.StringUtils;
* @author Mark Fisher * @author Mark Fisher
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Dave Syer * @author Dave Syer
* @author Gunnar Hillert
*
* @since 2.0 * @since 2.0
*/ */
public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator { public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator {
@@ -354,6 +356,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
return fallbackMethods; return fallbackMethods;
} }
@SuppressWarnings("deprecation")
private Class<?> getTargetClass(Object targetObject) { private Class<?> getTargetClass(Object targetObject) {
Class<?> targetClass = targetObject.getClass(); Class<?> targetClass = targetObject.getClass();
if (AopUtils.isAopProxy(targetObject)) { if (AopUtils.isAopProxy(targetObject)) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -225,7 +225,9 @@ public class MethodInvokingMessageGroupProcessorTests {
assertThat((Integer) ((Message<?>) result).getPayload(), is(7)); assertThat((Integer) ((Message<?>) result).getPayload(), is(7));
} }
@Test @Test
@SuppressWarnings("deprecation")
public void shouldFindSimpleAggregatorMethodWithIterator() throws Exception { public void shouldFindSimpleAggregatorMethodWithIterator() throws Exception {
@SuppressWarnings("unused") @SuppressWarnings("unused")

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@ public class DatatypeChannelTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void unsupportedTypeButConversionServiceSupports() { public void unsupportedTypeButConversionServiceSupports() {
QueueChannel channel = createChannel(Integer.class); QueueChannel channel = createChannel(Integer.class);
ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService(); ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
@@ -65,6 +66,7 @@ public class DatatypeChannelTests {
} }
@Test(expected = MessageDeliveryException.class) @Test(expected = MessageDeliveryException.class)
@SuppressWarnings("deprecation")
public void unsupportedTypeAndConversionServiceDoesNotSupport() { public void unsupportedTypeAndConversionServiceDoesNotSupport() {
QueueChannel channel = createChannel(Integer.class); QueueChannel channel = createChannel(Integer.class);
ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService(); ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
@@ -73,6 +75,7 @@ public class DatatypeChannelTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void unsupportedTypeButCustomConversionServiceSupports() { public void unsupportedTypeButCustomConversionServiceSupports() {
QueueChannel channel = createChannel(Integer.class); QueueChannel channel = createChannel(Integer.class);
GenericConversionService conversionService = ConversionServiceFactory.createDefaultConversionService(); GenericConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
@@ -108,6 +111,7 @@ public class DatatypeChannelTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void conversionServiceReferenceOverridesDefault() { public void conversionServiceReferenceOverridesDefault() {
GenericApplicationContext context = new GenericApplicationContext(); GenericApplicationContext context = new GenericApplicationContext();
Converter<Boolean, Integer> defaultConverter = new Converter<Boolean, Integer>() { Converter<Boolean, Integer> defaultConverter = new Converter<Boolean, Integer>() {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -67,6 +67,7 @@ public class GatewayProxyFactoryBeanTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void testRequestReplyWithAnonymousChannelConvertedTypeViaConversionService() throws Exception { public void testRequestReplyWithAnonymousChannelConvertedTypeViaConversionService() throws Exception {
QueueChannel requestChannel = new QueueChannel(); QueueChannel requestChannel = new QueueChannel();
startResponder(requestChannel); startResponder(requestChannel);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -36,6 +36,8 @@ import static junit.framework.Assert.assertNull;
/** /**
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Gunnar Hillert
*
* @since 2.0 * @since 2.0
*/ */
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@@ -112,6 +114,7 @@ public class MapToObjectTransformerTests {
assertEquals("1123 Main st", person.getAddress().getStreet()); assertEquals("1123 Main st", person.getAddress().getStreet());
} }
@SuppressWarnings("deprecation")
private ConfigurableBeanFactory getBeanFactory(){ private ConfigurableBeanFactory getBeanFactory(){
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
GenericConversionService conversionService = ConversionServiceFactory.createDefaultConversionService(); GenericConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2011 the original author or authors. * Copyright 2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@ import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.Properties; import java.util.Properties;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache; import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory; import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.DataPolicy; import com.gemstone.gemfire.cache.DataPolicy;
@@ -32,13 +31,15 @@ import com.gemstone.gemfire.distributed.DistributedSystem;
/** /**
* @author Costin Leau * @author Costin Leau
* @author David Turanski * @author David Turanski
* @author Gunnar Hillert
* *
* Runs as a standalone Java app. * Runs as a standalone Java app.
* Modified from SGF implementation for testing client/server CQ features * Modified from SGF implementation for testing client/server CQ features
*/ */
@SuppressWarnings("deprecation")
public class CacheServerProcess { public class CacheServerProcess {
@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Properties props = new Properties(); Properties props = new Properties();
@@ -51,7 +52,7 @@ public class CacheServerProcess {
Cache cache = CacheFactory.create(ds); Cache cache = CacheFactory.create(ds);
// Create region. // Create region.
AttributesFactory factory = new AttributesFactory(); com.gemstone.gemfire.cache.AttributesFactory factory = new com.gemstone.gemfire.cache.AttributesFactory();
factory.setDataPolicy(DataPolicy.REPLICATE); factory.setDataPolicy(DataPolicy.REPLICATE);
factory.setScope(Scope.DISTRIBUTED_ACK); factory.setScope(Scope.DISTRIBUTED_ACK);
Region testRegion = cache.createRegion("test", factory.create()); Region testRegion = cache.createRegion("test", factory.create());

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -75,6 +75,7 @@ import org.springframework.web.client.RestTemplate;
* @author Mark Fisher * @author Mark Fisher
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Gary Russell * @author Gary Russell
* @author Gunnar Hillert
* @since 2.0 * @since 2.0
*/ */
public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMessageHandler { public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMessageHandler {
@@ -289,17 +290,36 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
} }
Assert.isInstanceOf(GenericConversionService.class, conversionService); Assert.isInstanceOf(GenericConversionService.class, conversionService);
GenericConversionService gConversionService = (GenericConversionService) conversionService; GenericConversionService gConversionService = (GenericConversionService) conversionService;
gConversionService.addConverter(new Converter<Class<?>, String>() {
public String convert(Class<?> source) { gConversionService.addConverter(new ClassToStringConverter());
return source.getName(); gConversionService.addConverter(new ObjectToStringConverter());
}
});
if (conversionService != null) { if (conversionService != null) {
this.evaluationContext.setTypeConverter(new StandardTypeConverter(gConversionService)); this.evaluationContext.setTypeConverter(new StandardTypeConverter(gConversionService));
} }
} }
private class ClassToStringConverter implements Converter<Class<?>, String> {
public String convert(Class<?> source) {
return source.getName();
}
}
/**
* Spring 3.0.7.RELEASE unfortunately does not trigger the ClassToStringConverter.
* Therefore, this converter will also test for Class instances and do a
* respective type conversion.
*
*/
private class ObjectToStringConverter implements Converter<Object, String> {
public String convert(Object source) {
if (source instanceof Class) {
return ((Class<?>) source).getName();
}
return source.toString();
}
}
@Override @Override
protected Object handleRequestMessage(Message<?> requestMessage) { protected Object handleRequestMessage(Message<?> requestMessage) {
String uri = this.uriExpression.getValue(this.evaluationContext, requestMessage, String.class); String uri = this.uriExpression.getValue(this.evaluationContext, requestMessage, String.class);

View File

@@ -57,6 +57,7 @@ import org.springframework.util.MultiValueMap;
* @author Mark Fisher * @author Mark Fisher
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Gary Russell * @author Gary Russell
* @author Gunnar Hillert
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration @ContextConfiguration
@@ -215,7 +216,11 @@ public class HttpInboundChannelAdapterParserTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContent("test".getBytes()); request.setContent("test".getBytes());
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but not in Spring 3.0.7.RELEASE
//Instead use:
request.addHeader("Content-Type", "text/plain");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
postOnlyAdapter.handleRequest(request, response); postOnlyAdapter.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus()); assertEquals(HttpServletResponse.SC_OK, response.getStatus());
@@ -237,7 +242,11 @@ public class HttpInboundChannelAdapterParserTests {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
new ObjectOutputStream(byteStream).writeObject(obj); new ObjectOutputStream(byteStream).writeObject(obj);
request.setContent(byteStream.toByteArray()); request.setContent(byteStream.toByteArray());
request.setContentType("application/x-java-serialized-object");
// //request.setContentType("application/x-java-serialized-object"); //Works in Spring 3.1.2.RELEASE but not in Spring 3.0.7.RELEASE
// //Instead use:
request.addHeader("Content-Type", "application/x-java-serialized-object");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
postOnlyAdapter.handleRequest(request, response); postOnlyAdapter.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus()); assertEquals(HttpServletResponse.SC_OK, response.getStatus());

View File

@@ -59,6 +59,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Iwein Fuld * @author Iwein Fuld
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Gary Russell * @author Gary Russell
* @author Gunnar Hillert
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration @ContextConfiguration
@@ -109,10 +110,14 @@ public class HttpInboundGatewayParserTests {
request.setMethod("GET"); request.setMethod("GET");
request.addHeader("Accept", "application/x-java-serialized-object"); request.addHeader("Accept", "application/x-java-serialized-object");
request.setParameter("foo", "bar"); request.setParameter("foo", "bar");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response); gateway.handleRequest(request, response);
assertThat(response.getStatus(), is(HttpServletResponse.SC_OK)); assertThat(response.getStatus(), is(HttpServletResponse.SC_OK));
assertThat(response.getContentType(), is("application/x-java-serialized-object"));
//MockHttpServletResponse#getContentType() works in Spring 3.1.2.RELEASE but not in 3.0.7.RELEASE
//For 3.0.7.RELEASE we have to rely on MockHttpServletResponse#getHeader instead
assertEquals(response.getHeader("Content-Type"), "application/x-java-serialized-object");
} }
@Test @Test

View File

@@ -113,7 +113,9 @@ public class HttpOutboundGatewayWithMethodExpression {
String response = null; String response = null;
if (requestMethod.equalsIgnoreCase(this.httpMethod)){ if (requestMethod.equalsIgnoreCase(this.httpMethod)){
response = httpMethod; response = httpMethod;
t.getResponseHeaders().add("Content-Type", "text/plain"); //Required for Spring 3.0.x
t.sendResponseHeaders(200, response.length()); t.sendResponseHeaders(200, response.length());
} }
else { else {
response = "Request is NOT valid"; response = "Request is NOT valid";

View File

@@ -28,6 +28,7 @@ import org.junit.Test;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.integration.Message; import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel; import org.springframework.integration.MessageChannel;
@@ -139,6 +140,7 @@ public class OutboundResponseTypeTests {
String response = null; String response = null;
if (requestMethod.equalsIgnoreCase(this.httpMethod)){ if (requestMethod.equalsIgnoreCase(this.httpMethod)){
response = httpMethod; response = httpMethod;
t.getResponseHeaders().add("Content-Type", MediaType.TEXT_PLAIN.toString()); //Required for Spring 3.0.x
t.sendResponseHeaders(200, response.length()); t.sendResponseHeaders(200, response.length());
} }
else { else {

View File

@@ -48,6 +48,7 @@ import org.springframework.web.servlet.View;
/** /**
* @author Mark Fisher * @author Mark Fisher
* @author Gary Russell * @author Gary Russell
* @author Gunnar Hillert
* @since 2.0 * @since 2.0
*/ */
public class HttpRequestHandlingControllerTests { public class HttpRequestHandlingControllerTests {
@@ -61,7 +62,11 @@ public class HttpRequestHandlingControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContent("hello".getBytes()); request.setContent("hello".getBytes());
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView modelAndView = controller.handleRequest(request, response); ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("foo", modelAndView.getViewName()); assertEquals("foo", modelAndView.getViewName());
@@ -81,7 +86,11 @@ public class HttpRequestHandlingControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContent("hello".getBytes()); request.setContent("hello".getBytes());
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView modelAndView = controller.handleRequest(request, response); ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("baz", modelAndView.getViewName()); assertEquals("baz", modelAndView.getViewName());
@@ -106,8 +115,12 @@ public class HttpRequestHandlingControllerTests {
controller.setViewName("foo"); controller.setViewName("foo");
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContent("hello".getBytes());
request.setContentType("text/plain"); //request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
request.setContent("hello".getBytes()); //For Spring 3.0.7.RELEASE the Content must be set,
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView modelAndView = controller.handleRequest(request, response); ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("foo", modelAndView.getViewName()); assertEquals("foo", modelAndView.getViewName());
@@ -191,7 +204,11 @@ public class HttpRequestHandlingControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContent("howdy".getBytes()); request.setContent("howdy".getBytes());
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView modelAndView = controller.handleRequest(request, response); ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("foo", modelAndView.getViewName()); assertEquals("foo", modelAndView.getViewName());
@@ -218,7 +235,11 @@ public class HttpRequestHandlingControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContent("abc".getBytes()); request.setContent("abc".getBytes());
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView modelAndView = controller.handleRequest(request, response); ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("foo", modelAndView.getViewName()); assertEquals("foo", modelAndView.getViewName());
@@ -279,7 +300,11 @@ public class HttpRequestHandlingControllerTests {
final MockHttpServletRequest request = new MockHttpServletRequest(); final MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContent("hello".getBytes()); request.setContent("hello".getBytes());
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
final AtomicInteger active = new AtomicInteger(); final AtomicInteger active = new AtomicInteger();
final AtomicBoolean expected503 = new AtomicBoolean(); final AtomicBoolean expected503 = new AtomicBoolean();

View File

@@ -45,6 +45,7 @@ import org.springframework.util.SerializationUtils;
/** /**
* @author Mark Fisher * @author Mark Fisher
* @author Gary Russell * @author Gary Russell
* @author Gunnar Hillert
* @since 2.0 * @since 2.0
*/ */
public class HttpRequestHandlingMessagingGatewayTests { public class HttpRequestHandlingMessagingGatewayTests {
@@ -76,7 +77,11 @@ public class HttpRequestHandlingMessagingGatewayTests {
gateway.setRequestChannel(requestChannel); gateway.setRequestChannel(requestChannel);
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
request.setContent("hello".getBytes()); request.setContent("hello".getBytes());
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response); gateway.handleRequest(request, response);
@@ -101,7 +106,11 @@ public class HttpRequestHandlingMessagingGatewayTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.addHeader("Accept", "x-application/octet-stream"); request.addHeader("Accept", "x-application/octet-stream");
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
request.setContent("hello".getBytes()); request.setContent("hello".getBytes());
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response); gateway.handleRequest(request, response);
@@ -122,7 +131,11 @@ public class HttpRequestHandlingMessagingGatewayTests {
gateway.setRequestChannel(requestChannel); gateway.setRequestChannel(requestChannel);
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContentType("text/plain");
//request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
request.setContent("hello".getBytes()); request.setContent("hello".getBytes());
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response); gateway.handleRequest(request, response);
@@ -183,7 +196,11 @@ public class HttpRequestHandlingMessagingGatewayTests {
gateway.setRequestPayloadType(TestBean.class); gateway.setRequestPayloadType(TestBean.class);
gateway.setRequestChannel(channel); gateway.setRequestChannel(channel);
MockHttpServletRequest request = new MockHttpServletRequest("POST", "/test"); MockHttpServletRequest request = new MockHttpServletRequest("POST", "/test");
request.setContentType("application/x-java-serialized-object");
//request.setContentType("application/x-java-serialized-object"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "application/x-java-serialized-object");
TestBean testBean = new TestBean(); TestBean testBean = new TestBean();
testBean.setName("T. Bean"); testBean.setName("T. Bean");
testBean.setAge(42); testBean.setAge(42);

View File

@@ -35,6 +35,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
/** /**
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Gary Russell * @author Gary Russell
* @author Gunnar Hillert
*/ */
public class HttpRequestHandlingMessagingGatewayWithPathMappingTests { public class HttpRequestHandlingMessagingGatewayWithPathMappingTests {
@@ -53,7 +54,10 @@ public class HttpRequestHandlingMessagingGatewayWithPathMappingTests {
}); });
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST"); request.setMethod("POST");
request.setContentType("text/plain"); //request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE
//Instead do:
request.addHeader("Content-Type", "text/plain");
request.setParameter("foo", "bar"); request.setParameter("foo", "bar");
request.setContent("hello".getBytes()); request.setContent("hello".getBytes());
request.setRequestURI("/fname/bill/lname/clinton"); request.setRequestURI("/fname/bill/lname/clinton");

View File

@@ -34,7 +34,7 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
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.core.convert.support.DefaultConversionService; import org.springframework.core.convert.support.ConversionServiceFactory;
import org.springframework.core.convert.support.GenericConversionService; import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
@@ -455,11 +455,13 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
assertNull(headers.get("X-customHeaderB")); assertNull(headers.get("X-customHeaderB"));
} }
@Test @Test
@SuppressWarnings("deprecation")
public void validateCustomHeadersWithNonStringValuesAndDefaultConverterOnly() throws Exception{ public void validateCustomHeadersWithNonStringValuesAndDefaultConverterOnly() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper(); DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
mapper.setOutboundHeaderNames(new String[] {"customHeader*"}); mapper.setOutboundHeaderNames(new String[] {"customHeader*"});
ConversionService cs = new DefaultConversionService(); ConversionService cs = ConversionServiceFactory.createDefaultConversionService();
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerSingleton("integrationConversionService", cs); beanFactory.registerSingleton("integrationConversionService", cs);
mapper.setBeanFactory(beanFactory); mapper.setBeanFactory(beanFactory);
@@ -477,10 +479,11 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void validateCustomHeadersWithNonStringValuesAndDefaultConverterWithCustomConverter() throws Exception{ public void validateCustomHeadersWithNonStringValuesAndDefaultConverterWithCustomConverter() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper(); DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
mapper.setOutboundHeaderNames(new String[] {"customHeader*"}); mapper.setOutboundHeaderNames(new String[] {"customHeader*"});
GenericConversionService cs = new DefaultConversionService(); GenericConversionService cs = ConversionServiceFactory.createDefaultConversionService();
cs.addConverter(new TestClassConverter()); cs.addConverter(new TestClassConverter());
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerSingleton("integrationConversionService", cs); beanFactory.registerSingleton("integrationConversionService", cs);

View File

@@ -67,11 +67,13 @@ public class CachingClientConnectionFactory extends AbstractClientConnectionFact
} }
@Override @Override
@SuppressWarnings("deprecation")
public synchronized void setPoolSize(int poolSize) { public synchronized void setPoolSize(int poolSize) {
this.pool.setPoolSize(poolSize); this.pool.setPoolSize(poolSize);
} }
@Override @Override
@SuppressWarnings("deprecation")
public int getPoolSize() { public int getPoolSize() {
return this.pool.getPoolSize(); return this.pool.getPoolSize();
} }

View File

@@ -112,6 +112,7 @@ public class TcpNioSSLConnection extends TcpNioConnection {
* is handled by the thread running in the {@link SSLChannelOutputStream#doWrite(ByteBuffer)} * is handled by the thread running in the {@link SSLChannelOutputStream#doWrite(ByteBuffer)}
* method, which is awoken here, as a result of reaching that stage in the handshaking. * method, which is awoken here, as a result of reaching that stage in the handshaking.
*/ */
@SuppressWarnings("fallthrough")
private SSLEngineResult decode(ByteBuffer networkBuffer) throws IOException { private SSLEngineResult decode(ByteBuffer networkBuffer) throws IOException {
SSLEngineResult result = new SSLEngineResult(Status.OK, this.sslEngine.getHandshakeStatus(), 0, 0); SSLEngineResult result = new SSLEngineResult(Status.OK, this.sslEngine.getHandshakeStatus(), 0, 0);
HandshakeStatus handshakeStatus = this.sslEngine.getHandshakeStatus(); HandshakeStatus handshakeStatus = this.sslEngine.getHandshakeStatus();

View File

@@ -67,14 +67,19 @@
The CI build runs with the default profile. The CI build runs with the default profile.
--> -->
<beans profile="remote"> <!-- Commented out for Spring 3.0.x backwards compatibility
<bean id="clientConnector" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
<property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:11099/jmxrmi"/>
</bean>
</beans>
<beans profile="default"> <beans profile="remote">
<context:mbean-server id="clientConnector"/> <bean id="clientConnector" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
</beans> <property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:11099/jmxrmi"/>
</bean>
</beans>
<beans profile="default">
<context:mbean-server id="clientConnector"/>
</beans>
-->
<context:mbean-server id="clientConnector"/>
</beans> </beans>

View File

@@ -20,7 +20,6 @@ import javax.sql.DataSource;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -51,14 +50,13 @@ public class HibernateJpaOperationsTests extends AbstractJpaOperationsTests {
@Test @Test
public void generateDdl() { public void generateDdl() {
final Ejb3Configuration cfg = new Ejb3Configuration(); final org.hibernate.ejb.Ejb3Configuration cfg = new org.hibernate.ejb.Ejb3Configuration();
Map properties = fb.getJpaPropertyMap();
Map<String, Object> properties = fb.getJpaPropertyMap();
properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
final Ejb3Configuration configured = cfg.configure( fb.getPersistenceUnitInfo(), fb.getJpaPropertyMap() ); final org.hibernate.ejb.Ejb3Configuration configured = cfg.configure( fb.getPersistenceUnitInfo(), fb.getJpaPropertyMap() );
final Configuration configuration = configured.getHibernateConfiguration(); final Configuration configuration = configured.getHibernateConfiguration();
final SchemaExport schemaExport; final SchemaExport schemaExport;

View File

@@ -24,7 +24,6 @@ import org.springframework.integration.MessagingException;
import org.springframework.integration.jpa.test.JpaTestUtils; import org.springframework.integration.jpa.test.JpaTestUtils;
import org.springframework.integration.jpa.test.entity.StudentDomain; import org.springframework.integration.jpa.test.entity.StudentDomain;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.test.context.transaction.TransactionConfiguration;
@@ -53,7 +52,6 @@ public class JpaOutboundGatewayTests {
this.jdbcTemplate.execute("delete from Student where rollNumber > 1003"); this.jdbcTemplate.execute("delete from Student where rollNumber > 1003");
} }
@Test @Test
public void getStudent() { public void getStudent() {
final StudentDomain student = studentService.getStudent(1001L); final StudentDomain student = studentService.getStudent(1001L);
@@ -61,7 +59,6 @@ public class JpaOutboundGatewayTests {
} }
@Test @Test
@Transactional
public void deleteNonExistingStudent() { public void deleteNonExistingStudent() {
StudentDomain student = JpaTestUtils.getTestStudent(); StudentDomain student = JpaTestUtils.getTestStudent();

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:jpa="http://www.springframework.org/schema/integration/jpa" xmlns:jpa="http://www.springframework.org/schema/integration/jpa"
xmlns:task="http://www.springframework.org/schema/task" xmlns:task="http://www.springframework.org/schema/task"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
@@ -24,7 +23,9 @@
<jdbc:script location="classpath:H2-PopulateData.sql" /> <jdbc:script location="classpath:H2-PopulateData.sql" />
</jdbc:initialize-database> </jdbc:initialize-database>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" c:dataSource-ref="dataSource"/> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/> <tx:annotation-driven transaction-manager="transactionManager"/>

View File

@@ -98,6 +98,7 @@ public class XPathExpressionParser extends AbstractSingleBeanDefinitionParser {
} }
} }
@SuppressWarnings("deprecation")
protected Map<?,?> parseNamespaceMapElement(Element element, ParserContext parserContext, BeanDefinition parentDefinition) { protected Map<?,?> parseNamespaceMapElement(Element element, ParserContext parserContext, BeanDefinition parentDefinition) {
BeanDefinitionParserDelegate beanParser = new BeanDefinitionParserDelegate(parserContext.getReaderContext()); BeanDefinitionParserDelegate beanParser = new BeanDefinitionParserDelegate(parserContext.getReaderContext());
beanParser.initDefaults(element.getOwnerDocument().getDocumentElement()); beanParser.initDefaults(element.getOwnerDocument().getDocumentElement());