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'
log4jVersion = '1.2.12'
mockitoVersion = '1.9.0'
// 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'
springDataMongoVersion = '1.1.0.M1'
springDataRedisVersion = '1.0.1.RELEASE'
@@ -355,7 +356,7 @@ project('spring-integration-http') {
dependencies {
compile project(":spring-integration-core")
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 ->
optional dep
exclude group: 'junit', module: 'junit'
@@ -517,12 +518,15 @@ project('spring-integration-jpa') {
testCompile "org.aspectj:aspectjrt:$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.apache.openjpa:openjpa:2.2.0"
javaAgentSpringInstrument "org.springframework:spring-instrument:$springVersion"
javaAgentOpenJpa "org.apache.openjpa:openjpa:2.2.0"
//Suppress openjpa annotation processor warnings
compileTestJava.options.compilerArgs = ["${xLintArg},-processing"]
}
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");
* you may not use this file except in compliance with the License.
@@ -27,9 +27,10 @@ import org.springframework.util.ReflectionUtils.MethodCallback;
/**
* Helper to provide common features for inspecting objects and locating annotated methods.
*
*
* @author Dave Syer
*
* @author Gunnar Hillert
*
*/
abstract class AnnotationFinder {
@@ -45,6 +46,7 @@ abstract class AnnotationFinder {
return reference.get();
}
@SuppressWarnings("deprecation")
private static Class<?> getTargetClass(Object targetObject) {
Class<?> targetClass = targetObject.getClass();
if (AopUtils.isAopProxy(targetObject)) {

View File

@@ -32,7 +32,7 @@ import org.springframework.jmx.export.annotation.ManagedResource;
/**
* Base class for all Message Routers.
*
*
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Gunnar Hillert
@@ -50,12 +50,12 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
/**
* Set the default channel where Messages should be sent if channel resolution
* fails to return any channels. If no default channel is provided and channel
* resolution fails to return any channels, the router will throw an
* {@link MessageDeliveryException}.
*
* If messages shall be ignored (dropped) instead, please provide a {@link NullChannel}.
* Set the default channel where Messages should be sent if channel resolution
* fails to return any channels. If no default channel is provided and channel
* resolution fails to return any channels, the router will throw an
* {@link MessageDeliveryException}.
*
* If messages shall be ignored (dropped) instead, please provide a {@link NullChannel}.
*/
public void setDefaultOutputChannel(MessageChannel defaultOutputChannel) {
this.defaultOutputChannel = defaultOutputChannel;
@@ -100,6 +100,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
return this.messagingTemplate;
}
@SuppressWarnings("deprecation")
protected ConversionService getRequiredConversionService() {
if (this.getConversionService() == null) {
this.setConversionService(ConversionServiceFactory.createDefaultConversionService());

View File

@@ -29,12 +29,12 @@ import org.springframework.validation.DataBinder;
/**
* Will transform Map to an instance of Object. There are two ways to specify the type of the transformed Object.
* You can use one of two constructors. The constructor that takes the Class&lt;?&gt; as an argument will construct the Object of
* You can use one of two constructors. The constructor that takes the Class&lt;?&gt; as an argument will construct the Object of
* that type. There is another constructor that takes a 'beanName' as an argument and will populate this bean with transformed data.
* Such bean must be of 'prototype' scope otherwise {@link MessageTransformationException} will be thrown.
* This transformer is integrated with the {@link ConversionService} allowing values in the Map to be converted
* This transformer is integrated with the {@link ConversionService} allowing values in the Map to be converted
* to types that represent the properties of the Object.
*
*
* @author Oleg Zhurakousky
* @since 2.0
*/
@@ -63,11 +63,12 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer<Map<?,?>,
* (non-Javadoc)
* @see org.springframework.integration.transformer.AbstractPayloadTransformer#transformPayload(java.lang.Object)
*/
@SuppressWarnings("deprecation")
protected Object transformPayload(Map<?,?> payload) throws Exception {
Object target = (this.targetClass != null)
? BeanUtils.instantiate(this.targetClass)
: this.getBeanFactory().getBean(this.targetBeanName);
DataBinder binder = new DataBinder(target);
DataBinder binder = new DataBinder(target);
ConversionService conversionService = null;
if (this.getBeanFactory() instanceof ConfigurableBeanFactory){
conversionService = ((ConfigurableBeanFactory)this.getBeanFactory()).getConversionService();
@@ -79,7 +80,7 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer<Map<?,?>,
binder.bind(new MutablePropertyValues(payload));
return target;
}
protected void onInit(){
if (StringUtils.hasText(this.targetBeanName)) {
Assert.isTrue(this.getBeanFactory().isPrototype(this.targetBeanName),

View File

@@ -43,6 +43,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
private volatile ConversionService conversionService;
@SuppressWarnings("deprecation")
public BeanFactoryTypeConverter() {
synchronized (BeanFactoryTypeConverter.class) {
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");
* you may not use this file except in compliance with the License.
@@ -68,10 +68,12 @@ import org.springframework.util.StringUtils;
* is provided, and more than one declared method has that name, the method-selection will be dynamic, based on the
* underlying SpEL method resolution. Alternatively, an annotation type may be provided so that the candidates for
* SpEL's method resolution are determined by the presence of that annotation rather than the method name.
*
*
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Dave Syer
* @author Gunnar Hillert
*
* @since 2.0
*/
public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator {
@@ -280,7 +282,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
if (isMethodDefinedOnObjectClass(method)) {
return;
}
if (method.getDeclaringClass().equals(Proxy.class)) {
if (method.getDeclaringClass().equals(Proxy.class)) {
return;
}
if (!Modifier.isPublic(method.getModifiers())) {
@@ -354,6 +356,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
return fallbackMethods;
}
@SuppressWarnings("deprecation")
private Class<?> getTargetClass(Object targetObject) {
Class<?> targetClass = targetObject.getClass();
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");
* 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));
}
@Test
@SuppressWarnings("deprecation")
public void shouldFindSimpleAggregatorMethodWithIterator() throws Exception {
@SuppressWarnings("unused")
@@ -280,7 +282,7 @@ public class MethodInvokingMessageGroupProcessorTests {
Object result = processor.processMessageGroup(messageGroupMock);
assertThat((Integer) ((Message<?>) result).getPayload(), is(7));
}
@Test
public void shouldFindFittingMethodForIteratorOfMessages() {

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");
* you may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@ public class DatatypeChannelTests {
}
@Test
@SuppressWarnings("deprecation")
public void unsupportedTypeButConversionServiceSupports() {
QueueChannel channel = createChannel(Integer.class);
ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
@@ -65,6 +66,7 @@ public class DatatypeChannelTests {
}
@Test(expected = MessageDeliveryException.class)
@SuppressWarnings("deprecation")
public void unsupportedTypeAndConversionServiceDoesNotSupport() {
QueueChannel channel = createChannel(Integer.class);
ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
@@ -73,6 +75,7 @@ public class DatatypeChannelTests {
}
@Test
@SuppressWarnings("deprecation")
public void unsupportedTypeButCustomConversionServiceSupports() {
QueueChannel channel = createChannel(Integer.class);
GenericConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
@@ -104,10 +107,11 @@ public class DatatypeChannelTests {
context.registerBeanDefinition("testChannel", channelBuilder.getBeanDefinition());
QueueChannel channel = context.getBean("testChannel", QueueChannel.class);
assertTrue(channel.send(new GenericMessage<Boolean>(Boolean.TRUE)));
assertEquals(new Integer(1), channel.receive().getPayload());
assertEquals(new Integer(1), channel.receive().getPayload());
}
@Test
@SuppressWarnings("deprecation")
public void conversionServiceReferenceOverridesDefault() {
GenericApplicationContext context = new GenericApplicationContext();
Converter<Boolean, Integer> defaultConverter = new Converter<Boolean, Integer>() {
@@ -131,7 +135,7 @@ public class DatatypeChannelTests {
context.registerBeanDefinition("testChannel", channelBuilder.getBeanDefinition());
QueueChannel channel = context.getBean("testChannel", QueueChannel.class);
assertTrue(channel.send(new GenericMessage<Boolean>(Boolean.TRUE)));
assertEquals(new Integer(99), channel.receive().getPayload());
assertEquals(new Integer(99), channel.receive().getPayload());
}
@Test

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");
* you may not use this file except in compliance with the License.
@@ -65,8 +65,9 @@ public class GatewayProxyFactoryBeanTests {
String result = service.requestReply("foo");
assertEquals("foobar", result);
}
@Test
@SuppressWarnings("deprecation")
public void testRequestReplyWithAnonymousChannelConvertedTypeViaConversionService() throws Exception {
QueueChannel requestChannel = new QueueChannel();
startResponder(requestChannel);
@@ -75,13 +76,13 @@ public class GatewayProxyFactoryBeanTests {
public byte[] convert(String source) {
return source.getBytes();
}
};
};
stringToByteConverter = Mockito.spy(stringToByteConverter);
cs.addConverter(stringToByteConverter);
GatewayProxyFactoryBean proxyFactory = new GatewayProxyFactoryBean();
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerSingleton(IntegrationContextUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME, cs);
proxyFactory.setBeanFactory(bf);
proxyFactory.setDefaultRequestChannel(requestChannel);
proxyFactory.setServiceInterface(TestService.class);
@@ -334,7 +335,7 @@ public class GatewayProxyFactoryBeanTests {
// MessageHistoryEvent event1 = historyIterator.next();
// MessageHistoryEvent event2 = historyIterator.next();
// MessageHistoryEvent event3 = historyIterator.next();
//
//
// //assertEquals("echo", event1.getAttribute("method", String.class));
// assertEquals("gateway", event1.getType());
// assertEquals("testGateway", event1.getName());

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");
* you may not use this file except in compliance with the License.
@@ -36,12 +36,14 @@ import static junit.framework.Assert.assertNull;
/**
* @author Oleg Zhurakousky
* @author Gunnar Hillert
*
* @since 2.0
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public class MapToObjectTransformerTests {
@Test
public void testMapToObjectTransformation(){
Map map = new HashMap();
@@ -50,9 +52,9 @@ public class MapToObjectTransformerTests {
Address address = new Address();
address.setStreet("1123 Main st");
map.put("address", address);
Message message = MessageBuilder.withPayload(map).build();
MapToObjectTransformer transformer = new MapToObjectTransformer(Person.class);
transformer.setBeanFactory(this.getBeanFactory());
Message newMessage = transformer.transform(message);
@@ -64,7 +66,7 @@ public class MapToObjectTransformerTests {
assertNotNull(person.getAddress());
assertEquals("1123 Main st", person.getAddress().getStreet());
}
@Test
public void testMapToObjectTransformationWithPrototype(){
Map map = new HashMap();
@@ -73,7 +75,7 @@ public class MapToObjectTransformerTests {
Address address = new Address();
address.setStreet("1123 Main st");
map.put("address", address);
Message message = MessageBuilder.withPayload(map).build();
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerPrototype("person", Person.class);
@@ -95,14 +97,14 @@ public class MapToObjectTransformerTests {
map.put("fname", "Justin");
map.put("lname", "Case");
map.put("address", "1123 Main st");
Message message = MessageBuilder.withPayload(map).build();
MapToObjectTransformer transformer = new MapToObjectTransformer(Person.class);
ConfigurableBeanFactory beanFactory = this.getBeanFactory();
((GenericConversionService)beanFactory.getConversionService()).addConverter(new StringToAddressConverter());
transformer.setBeanFactory(beanFactory);
Message newMessage = transformer.transform(message);
Person person = (Person) newMessage.getPayload();
assertNotNull(person);
@@ -111,7 +113,8 @@ public class MapToObjectTransformerTests {
assertNotNull(person.getAddress());
assertEquals("1123 Main st", person.getAddress().getStreet());
}
@SuppressWarnings("deprecation")
private ConfigurableBeanFactory getBeanFactory(){
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
GenericConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
@@ -129,7 +132,7 @@ public class MapToObjectTransformerTests {
}
public void setSsn(String ssn) {
this.ssn = ssn;
}
}
public String getFname() {
return fname;
}
@@ -149,7 +152,7 @@ public class MapToObjectTransformerTests {
this.address = address;
}
}
public static class Address {
private String street;
@@ -161,7 +164,7 @@ public class MapToObjectTransformerTests {
this.street = street;
}
}
public class StringToAddressConverter implements Converter<String, Address>{
public Address convert(String source) {
Address address = new Address();

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");
* 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.util.Properties;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.DataPolicy;
@@ -32,13 +31,15 @@ import com.gemstone.gemfire.distributed.DistributedSystem;
/**
* @author Costin Leau
* @author David Turanski
*
* @author Gunnar Hillert
*
* Runs as a standalone Java app.
* Modified from SGF implementation for testing client/server CQ features
*/
@SuppressWarnings("deprecation")
public class CacheServerProcess {
@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" })
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) throws Exception {
Properties props = new Properties();
@@ -46,12 +47,12 @@ public class CacheServerProcess {
props.setProperty("log-level", "info");
System.out.println("\nConnecting to the distributed system and creating the cache.");
DistributedSystem ds = DistributedSystem.connect(props);
Cache cache = CacheFactory.create(ds);
// Create region.
AttributesFactory factory = new AttributesFactory();
com.gemstone.gemfire.cache.AttributesFactory factory = new com.gemstone.gemfire.cache.AttributesFactory();
factory.setDataPolicy(DataPolicy.REPLICATE);
factory.setScope(Scope.DISTRIBUTED_ACK);
Region testRegion = cache.createRegion("test", factory.create());
@@ -65,7 +66,7 @@ public class CacheServerProcess {
server.start();
ForkUtil.createControlFile(CacheServerProcess.class.getName());
System.out.println("Waiting for shutdown");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
bufferedReader.readLine();

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");
* 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 Oleg Zhurakousky
* @author Gary Russell
* @author Gunnar Hillert
* @since 2.0
*/
public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMessageHandler {
@@ -289,17 +290,36 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
}
Assert.isInstanceOf(GenericConversionService.class, conversionService);
GenericConversionService gConversionService = (GenericConversionService) conversionService;
gConversionService.addConverter(new Converter<Class<?>, String>() {
public String convert(Class<?> source) {
return source.getName();
}
});
gConversionService.addConverter(new ClassToStringConverter());
gConversionService.addConverter(new ObjectToStringConverter());
if (conversionService != null) {
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
protected Object handleRequestMessage(Message<?> requestMessage) {
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 Oleg Zhurakousky
* @author Gary Russell
* @author Gunnar Hillert
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@@ -73,21 +74,21 @@ public class HttpInboundChannelAdapterParserTests {
@Autowired
private HttpRequestHandlingMessagingGateway putOrDeleteAdapter;
@Autowired
private HttpRequestHandlingMessagingGateway withMappedHeaders;
@Autowired
private HttpRequestHandlingMessagingGateway inboundAdapterWithExpressions;
@Autowired
@Qualifier("/fname/{blah}/lname/{boo}")
private HttpRequestHandlingMessagingGateway inboundAdapterWithNameAndExpressions;
@Autowired
@Qualifier("/fname/{f}/lname/{l}")
private HttpRequestHandlingMessagingGateway inboundAdapterWithNameNoPath;
@Autowired
private HttpRequestHandlingController inboundController;
@@ -117,12 +118,12 @@ public class HttpInboundChannelAdapterParserTests {
assertEquals("bar", map.getFirst("foo"));
assertNotNull(TestUtils.getPropertyValue(defaultAdapter, "errorChannel"));
}
@Test
public void getRequestWithHeaders() throws Exception {
DefaultHttpHeaderMapper headerMapper =
DefaultHttpHeaderMapper headerMapper =
(DefaultHttpHeaderMapper) TestUtils.getPropertyValue(withMappedHeaders, "headerMapper");
HttpHeaders headers = new HttpHeaders();
headers.set("foo", "foo");
headers.set("bar", "bar");
@@ -132,7 +133,7 @@ public class HttpInboundChannelAdapterParserTests {
assertEquals("foo", map.get("foo"));
assertEquals("bar", map.get("bar"));
}
@Test
// INT-1677
public void withExpressions() throws Exception {
@@ -142,7 +143,7 @@ public class HttpInboundChannelAdapterParserTests {
request.setParameter("foo", "bar");
request.setContent("hello".getBytes());
request.setRequestURI("/fname/bill/lname/clinton");
MockHttpServletResponse response = new MockHttpServletResponse();
inboundAdapterWithExpressions.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
@@ -163,7 +164,7 @@ public class HttpInboundChannelAdapterParserTests {
request.setParameter("foo", "bar");
request.setContent("hello".getBytes());
request.setRequestURI("/fname/bill/lname/clinton");
MockHttpServletResponse response = new MockHttpServletResponse();
inboundAdapterWithNameAndExpressions.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
@@ -174,7 +175,7 @@ public class HttpInboundChannelAdapterParserTests {
assertEquals("bill", payload);
assertEquals("clinton", message.getHeaders().get("lname"));
}
@Test(expected=SpelEvaluationException.class)
// INT-1677
public void withNameAndExpressionsNoPath() throws Exception {
@@ -184,7 +185,7 @@ public class HttpInboundChannelAdapterParserTests {
request.setParameter("foo", "bar");
request.setContent("hello".getBytes());
request.setRequestURI("/fname/bill/lname/clinton");
MockHttpServletResponse response = new MockHttpServletResponse();
inboundAdapterWithNameNoPath.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
@@ -195,8 +196,8 @@ public class HttpInboundChannelAdapterParserTests {
assertEquals("hello", payload); // default payload
assertNull(message.getHeaders().get("lname"));
}
@Test
public void getRequestNotAllowed() throws Exception {
@@ -215,7 +216,11 @@ public class HttpInboundChannelAdapterParserTests {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
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();
postOnlyAdapter.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
@@ -237,7 +242,11 @@ public class HttpInboundChannelAdapterParserTests {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
new ObjectOutputStream(byteStream).writeObject(obj);
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();
postOnlyAdapter.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());

View File

@@ -59,6 +59,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Iwein Fuld
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Gunnar Hillert
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@@ -109,10 +110,14 @@ public class HttpInboundGatewayParserTests {
request.setMethod("GET");
request.addHeader("Accept", "application/x-java-serialized-object");
request.setParameter("foo", "bar");
MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response);
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

View File

@@ -113,7 +113,9 @@ public class HttpOutboundGatewayWithMethodExpression {
String response = null;
if (requestMethod.equalsIgnoreCase(this.httpMethod)){
response = httpMethod;
t.getResponseHeaders().add("Content-Type", "text/plain"); //Required for Spring 3.0.x
t.sendResponseHeaders(200, response.length());
}
else {
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.context.support.ClassPathXmlApplicationContext;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
@@ -139,6 +140,7 @@ public class OutboundResponseTypeTests {
String response = null;
if (requestMethod.equalsIgnoreCase(this.httpMethod)){
response = httpMethod;
t.getResponseHeaders().add("Content-Type", MediaType.TEXT_PLAIN.toString()); //Required for Spring 3.0.x
t.sendResponseHeaders(200, response.length());
}
else {

View File

@@ -48,6 +48,7 @@ import org.springframework.web.servlet.View;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Gunnar Hillert
* @since 2.0
*/
public class HttpRequestHandlingControllerTests {
@@ -61,7 +62,11 @@ public class HttpRequestHandlingControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest();
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");
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("foo", modelAndView.getViewName());
@@ -81,7 +86,11 @@ public class HttpRequestHandlingControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest();
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");
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("baz", modelAndView.getViewName());
@@ -106,8 +115,12 @@ public class HttpRequestHandlingControllerTests {
controller.setViewName("foo");
MockHttpServletRequest request = new MockHttpServletRequest();
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();
ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("foo", modelAndView.getViewName());
@@ -191,7 +204,11 @@ public class HttpRequestHandlingControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
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();
ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("foo", modelAndView.getViewName());
@@ -218,7 +235,11 @@ public class HttpRequestHandlingControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
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();
ModelAndView modelAndView = controller.handleRequest(request, response);
assertEquals("foo", modelAndView.getViewName());
@@ -279,7 +300,11 @@ public class HttpRequestHandlingControllerTests {
final MockHttpServletRequest request = new MockHttpServletRequest();
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");
MockHttpServletResponse response = new MockHttpServletResponse();
final AtomicInteger active = new AtomicInteger();
final AtomicBoolean expected503 = new AtomicBoolean();

View File

@@ -45,6 +45,7 @@ import org.springframework.util.SerializationUtils;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Gunnar Hillert
* @since 2.0
*/
public class HttpRequestHandlingMessagingGatewayTests {
@@ -76,7 +77,11 @@ public class HttpRequestHandlingMessagingGatewayTests {
gateway.setRequestChannel(requestChannel);
MockHttpServletRequest request = new MockHttpServletRequest();
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());
MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response);
@@ -101,7 +106,11 @@ public class HttpRequestHandlingMessagingGatewayTests {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
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());
MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response);
@@ -122,7 +131,11 @@ public class HttpRequestHandlingMessagingGatewayTests {
gateway.setRequestChannel(requestChannel);
MockHttpServletRequest request = new MockHttpServletRequest();
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());
MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response);
@@ -183,7 +196,11 @@ public class HttpRequestHandlingMessagingGatewayTests {
gateway.setRequestPayloadType(TestBean.class);
gateway.setRequestChannel(channel);
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.setName("T. Bean");
testBean.setAge(42);

View File

@@ -35,6 +35,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Gunnar Hillert
*/
public class HttpRequestHandlingMessagingGatewayWithPathMappingTests {
@@ -53,7 +54,10 @@ public class HttpRequestHandlingMessagingGatewayWithPathMappingTests {
});
MockHttpServletRequest request = new MockHttpServletRequest();
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.setContent("hello".getBytes());
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.core.convert.ConversionService;
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.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -57,131 +57,131 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("Allow", "bar");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
}
@Test
public void validateAllowAsString(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("Allow", "GET");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(1, headers.getAllow().size());
assertEquals(HttpMethod.GET, headers.getAllow().iterator().next());
}
@Test
public void validateAllowAsStringCaseInsensitive(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("allow", "GET");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(1, headers.getAllow().size());
assertEquals(HttpMethod.GET, headers.getAllow().iterator().next());
}
@Test
public void validateAllowAsHttpMethod(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("Allow", HttpMethod.GET);
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(1, headers.getAllow().size());
assertEquals(HttpMethod.GET, headers.getAllow().iterator().next());
}
@Test
public void validateAllowAsDelimitedString(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("Allow", "GET, POST");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(2, headers.getAllow().size());
assertTrue(headers.getAllow().contains(HttpMethod.GET));
assertTrue(headers.getAllow().contains(HttpMethod.POST));
}
@Test
public void validateAllowAsStringArray(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("Allow", new String[]{"GET", "POST"});
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(2, headers.getAllow().size());
assertTrue(headers.getAllow().contains(HttpMethod.GET));
assertTrue(headers.getAllow().contains(HttpMethod.POST));
}
@Test
public void validateAllowAsHttpMethodArray(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("Allow", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST});
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(2, headers.getAllow().size());
assertTrue(headers.getAllow().contains(HttpMethod.GET));
assertTrue(headers.getAllow().contains(HttpMethod.POST));
}
@Test
public void validateAllowAsCollectionOfString(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("Allow", CollectionUtils.arrayToList(new String[]{"GET", "POST"}));
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(2, headers.getAllow().size());
assertTrue(headers.getAllow().contains(HttpMethod.GET));
assertTrue(headers.getAllow().contains(HttpMethod.POST));
}
@Test
public void validateAllowAsCollectionOfHttpMethods(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("Allow", CollectionUtils.arrayToList(new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}));
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(2, headers.getAllow().size());
assertTrue(headers.getAllow().contains(HttpMethod.GET));
assertTrue(headers.getAllow().contains(HttpMethod.POST));
}
// Cache-Control tested as part of DefaultHttpHeaderMapperFromMessageOutboundTests
// Content-Length tested as part of DefaultHttpHeaderMapperFromMessageOutboundTests
// Content-Type tested as part of DefaultHttpHeaderMapperFromMessageOutboundTests
// Date tested as part of DefaultHttpHeaderMapperFromMessageOutboundTests
// ETag tests
@Test
public void validateETag(){
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("ETag", "\"1234\"");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals("\"1234\"", headers.getETag());
}
// Expires tests
@Test
public void validateExpiresAsNumber() throws ParseException{
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
@@ -189,12 +189,12 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
messageHeaders.put("Expires", 12345678);
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
assertEquals(simpleDateFormat.parse("Thu, 01 Jan 1970 03:25:45 GMT").getTime(), headers.getExpires());
}
@Test
public void validateExpiresAsString() throws ParseException{
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
@@ -202,9 +202,9 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
messageHeaders.put("Expires", "12345678");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
assertEquals(simpleDateFormat.parse("Thu, 01 Jan 1970 03:25:45 GMT").getTime(), headers.getExpires());
}
@Test
@@ -214,14 +214,14 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
messageHeaders.put("Expires", new Date(12345678));
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
assertEquals(simpleDateFormat.parse("Thu, 01 Jan 1970 03:25:45 GMT").getTime(), headers.getExpires());
}
// Last-Modified tests
@Test
public void validateLastModifiedAsNumber() throws ParseException{
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
@@ -229,12 +229,12 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
messageHeaders.put("Last-Modified", 12345678);
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
assertEquals(simpleDateFormat.parse("Thu, 01 Jan 1970 03:25:45 GMT").getTime(), headers.getLastModified());
}
@Test
public void validateLastModifiedAsString() throws ParseException{
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
@@ -242,9 +242,9 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
messageHeaders.put("Last-Modified", "12345678");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
assertEquals(simpleDateFormat.parse("Thu, 01 Jan 1970 03:25:45 GMT").getTime(), headers.getLastModified());
}
@Test
@@ -254,14 +254,14 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
messageHeaders.put("Last-Modified", new Date(12345678));
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
assertEquals(simpleDateFormat.parse("Thu, 01 Jan 1970 03:25:45 GMT").getTime(), headers.getLastModified());
}
// Location tests
@Test
public void validateLocation() throws Exception{
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
@@ -269,10 +269,10 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
messageHeaders.put("Location", "http://foo.com");
HttpHeaders headers = new HttpHeaders();
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertEquals(new URI("http://foo.com").toString(), headers.getLocation().toString());
}
// Pragma tested as part of DefaultHttpHeaderMapperFromMessageOutboundTests
@Test
@@ -315,7 +315,7 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
assertEquals(1, headers.get("X-1z").size());
assertEquals("1z-value", headers.getFirst("X-1z"));
assertEquals(1, headers.get("X-abcdef").size());
assertEquals("abcdef-value", headers.getFirst("X-abcdef"));
assertEquals("abcdef-value", headers.getFirst("X-abcdef"));
}
@Test
@@ -334,7 +334,7 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
assertEquals(1, headers.get("X-foobar").size());
assertEquals("abc", headers.getFirst("X-foobar"));
}
@Test
public void validateCustomHeaderNamePatternsAndStandardResponseHeadersMappedToHttpHeadersWithCustomPrefix() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
@@ -352,7 +352,7 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
assertEquals(1, headers.get("Z-foobar").size());
assertEquals("abc", headers.getFirst("Z-foobar"));
}
@Test
public void validateCustomHeaderNamePatternsAndStandardResponseHeadersMappedToHttpHeadersWithCustomPrefixEmptyString() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
@@ -370,7 +370,7 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
assertEquals(1, headers.get("foobar").size());
assertEquals("abc", headers.getFirst("foobar"));
}
@Test
public void validateCustomHeaderNamePatternsAndStandardResponseHeadersMappedToHttpHeadersWithCustomPrefixNull() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
@@ -439,76 +439,79 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
assertEquals("abc", result.get("foobar"));
assertEquals(MediaType.TEXT_XML, result.get("Accept"));
}
@Test
public void validateCustomHeadersWithNonStringValuesAndNoConverter() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
mapper.setOutboundHeaderNames(new String[] {"customHeader*"});
HttpHeaders headers = new HttpHeaders();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("customHeaderA", 123);
messageHeaders.put("customHeaderB", new TestClass());
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertNull(headers.get("X-customHeaderA"));
assertNull(headers.get("X-customHeaderB"));
}
@Test
@SuppressWarnings("deprecation")
public void validateCustomHeadersWithNonStringValuesAndDefaultConverterOnly() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
mapper.setOutboundHeaderNames(new String[] {"customHeader*"});
ConversionService cs = new DefaultConversionService();
ConversionService cs = ConversionServiceFactory.createDefaultConversionService();
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerSingleton("integrationConversionService", cs);
mapper.setBeanFactory(beanFactory);
mapper.afterPropertiesSet();
HttpHeaders headers = new HttpHeaders();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("customHeaderA", 123);
messageHeaders.put("customHeaderB", new TestClass());
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertNotNull(headers.get("X-customHeaderA"));
assertEquals("123", headers.get("X-customHeaderA").get(0));
assertNull(headers.get("X-customHeaderB"));
}
@Test
@SuppressWarnings("deprecation")
public void validateCustomHeadersWithNonStringValuesAndDefaultConverterWithCustomConverter() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
mapper.setOutboundHeaderNames(new String[] {"customHeader*"});
GenericConversionService cs = new DefaultConversionService();
GenericConversionService cs = ConversionServiceFactory.createDefaultConversionService();
cs.addConverter(new TestClassConverter());
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerSingleton("integrationConversionService", cs);
mapper.setBeanFactory(beanFactory);
mapper.afterPropertiesSet();
HttpHeaders headers = new HttpHeaders();
Map<String, Object> messageHeaders = new HashMap<String, Object>();
messageHeaders.put("customHeaderA", 123);
messageHeaders.put("customHeaderB", new TestClass());
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertNotNull(headers.get("X-customHeaderA"));
assertEquals("123", headers.get("X-customHeaderA").get(0));
assertNotNull(headers.get("X-customHeaderB"));
assertEquals("TestClass.class", headers.get("X-customHeaderB").get(0));
}
public static class TestClass {
}
public static class TestClassConverter implements Converter<TestClass, String>{
public String convert(TestClass source) {
return "TestClass.class";
}
}
}

View File

@@ -67,11 +67,13 @@ public class CachingClientConnectionFactory extends AbstractClientConnectionFact
}
@Override
@SuppressWarnings("deprecation")
public synchronized void setPoolSize(int poolSize) {
this.pool.setPoolSize(poolSize);
}
@Override
@SuppressWarnings("deprecation")
public int 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)}
* method, which is awoken here, as a result of reaching that stage in the handshaking.
*/
@SuppressWarnings("fallthrough")
private SSLEngineResult decode(ByteBuffer networkBuffer) throws IOException {
SSLEngineResult result = new SSLEngineResult(Status.OK, this.sslEngine.getHandshakeStatus(), 0, 0);
HandshakeStatus handshakeStatus = this.sslEngine.getHandshakeStatus();

View File

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

View File

@@ -20,7 +20,6 @@ import javax.sql.DataSource;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,14 +50,13 @@ public class HibernateJpaOperationsTests extends AbstractJpaOperationsTests {
@Test
public void generateDdl() {
final Ejb3Configuration cfg = new Ejb3Configuration();
Map properties = fb.getJpaPropertyMap();
final org.hibernate.ejb.Ejb3Configuration cfg = new org.hibernate.ejb.Ejb3Configuration();
Map<String, Object> properties = fb.getJpaPropertyMap();
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 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.entity.StudentDomain;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
@@ -53,7 +52,6 @@ public class JpaOutboundGatewayTests {
this.jdbcTemplate.execute("delete from Student where rollNumber > 1003");
}
@Test
public void getStudent() {
final StudentDomain student = studentService.getStudent(1001L);
@@ -61,7 +59,6 @@ public class JpaOutboundGatewayTests {
}
@Test
@Transactional
public void deleteNonExistingStudent() {
StudentDomain student = JpaTestUtils.getTestStudent();

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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:task="http://www.springframework.org/schema/task"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
@@ -24,7 +23,9 @@
<jdbc:script location="classpath:H2-PopulateData.sql" />
</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"/>

View File

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