From 57bc67b8fb8f93ea45b92d341b5f4852bcda9cd2 Mon Sep 17 00:00:00 2001 From: Gunnar Hillert Date: Mon, 30 Jul 2012 15:34:47 -0400 Subject: [PATCH] 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 --- build.gradle | 10 +- .../integration/config/AnnotationFinder.java | 8 +- .../router/AbstractMessageRouter.java | 15 +- .../transformer/MapToObjectTransformer.java | 11 +- .../util/BeanFactoryTypeConverter.java | 1 + .../util/MessagingMethodInvokerHelper.java | 9 +- ...hodInvokingMessageGroupProcessorTests.java | 6 +- .../channel/DatatypeChannelTests.java | 10 +- .../gateway/GatewayProxyFactoryBeanTests.java | 11 +- .../MapToObjectTransformerTests.java | 29 ++-- .../gemfire/fork/CacheServerProcess.java | 15 +- .../HttpRequestExecutingMessageHandler.java | 32 ++++- .../HttpInboundChannelAdapterParserTests.java | 43 +++--- .../config/HttpInboundGatewayParserTests.java | 7 +- ...tpOutboundGatewayWithMethodExpression.java | 2 + .../config/OutboundResponseTypeTests.java | 2 + .../HttpRequestHandlingControllerTests.java | 39 +++++- ...pRequestHandlingMessagingGatewayTests.java | 25 +++- ...gMessagingGatewayWithPathMappingTests.java | 6 +- ...tpHeaderMapperFromMessageInboundTests.java | 129 +++++++++--------- .../CachingClientConnectionFactory.java | 2 + .../tcp/connection/TcpNioSSLConnection.java | 1 + .../RemoteMBeanServerTests-context.xml | 21 +-- .../jpa/core/HibernateJpaOperationsTests.java | 8 +- .../jpa/outbound/JpaOutboundGatewayTests.java | 3 - .../src/test/resources/commonJpa-context.xml | 5 +- .../xml/config/XPathExpressionParser.java | 1 + 27 files changed, 283 insertions(+), 168 deletions(-) diff --git a/build.gradle b/build.gradle index b0419b5222..0a01834b25 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/AnnotationFinder.java b/spring-integration-core/src/main/java/org/springframework/integration/config/AnnotationFinder.java index 934d119dbd..e3e3a8514f 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/AnnotationFinder.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/AnnotationFinder.java @@ -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)) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java index e4406e6c8d..ba90f0e984 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java @@ -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()); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java index 4c504cff5f..a6074cdb7e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java @@ -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<?> as an argument will construct the Object of + * You can use one of two constructors. The constructor that takes the Class<?> 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, * (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, binder.bind(new MutablePropertyValues(payload)); return target; } - + protected void onInit(){ if (StringUtils.hasText(this.targetBeanName)) { Assert.isTrue(this.getBeanFactory().isPrototype(this.targetBeanName), diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java index e6e8dd6e9b..bc6308123d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java @@ -43,6 +43,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware private volatile ConversionService conversionService; + @SuppressWarnings("deprecation") public BeanFactoryTypeConverter() { synchronized (BeanFactoryTypeConverter.class) { if (defaultConversionService == null) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java index 77d6b0edcb..22ea6ca674 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java @@ -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 extends AbstractExpressionEvaluator { @@ -280,7 +282,7 @@ public class MessagingMethodInvokerHelper 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 extends AbstractExpressionEvaluator return fallbackMethods; } + @SuppressWarnings("deprecation") private Class getTargetClass(Object targetObject) { Class targetClass = targetObject.getClass(); if (AopUtils.isAopProxy(targetObject)) { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java index 1751755686..6c4eb87bec 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java @@ -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() { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/DatatypeChannelTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/DatatypeChannelTests.java index 334d101a78..0307e50a38 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/DatatypeChannelTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/DatatypeChannelTests.java @@ -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.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 defaultConverter = new Converter() { @@ -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.TRUE))); - assertEquals(new Integer(99), channel.receive().getPayload()); + assertEquals(new Integer(99), channel.receive().getPayload()); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java index 1de3f25e6e..f23f9602ce 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java @@ -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()); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/MapToObjectTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/MapToObjectTransformerTests.java index f02af338d4..f2a3e1dcbb 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/MapToObjectTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/MapToObjectTransformerTests.java @@ -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{ public Address convert(String source) { Address address = new Address(); diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/CacheServerProcess.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/CacheServerProcess.java index eaea33a99f..fbdc761ba4 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/CacheServerProcess.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/CacheServerProcess.java @@ -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(); diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java b/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java index 62f79383ed..408e018999 100755 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java @@ -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, 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, 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 { + 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); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpInboundChannelAdapterParserTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpInboundChannelAdapterParserTests.java index f51468d1ee..1626d990e3 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpInboundChannelAdapterParserTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpInboundChannelAdapterParserTests.java @@ -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()); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpInboundGatewayParserTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpInboundGatewayParserTests.java index 7dbbdb89ac..0e9159642b 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpInboundGatewayParserTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpInboundGatewayParserTests.java @@ -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 diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayWithMethodExpression.java b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayWithMethodExpression.java index 9850694af6..2717942a48 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayWithMethodExpression.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayWithMethodExpression.java @@ -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"; diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/OutboundResponseTypeTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/config/OutboundResponseTypeTests.java index a40b10cf1e..e5572d6996 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/OutboundResponseTypeTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/OutboundResponseTypeTests.java @@ -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 { diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingControllerTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingControllerTests.java index 122b07b3cc..df935be8d2 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingControllerTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingControllerTests.java @@ -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(); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayTests.java index c6bf40d00b..e66984be20 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayTests.java @@ -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); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayWithPathMappingTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayWithPathMappingTests.java index 07fdc4c9c1..0b81582d12 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayWithPathMappingTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayWithPathMappingTests.java @@ -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"); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/support/DefaultHttpHeaderMapperFromMessageInboundTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/support/DefaultHttpHeaderMapperFromMessageInboundTests.java index 5e753ba1b7..f66861b0f3 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/support/DefaultHttpHeaderMapperFromMessageInboundTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/support/DefaultHttpHeaderMapperFromMessageInboundTests.java @@ -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 messageHeaders = new HashMap(); messageHeaders.put("Allow", "bar"); HttpHeaders headers = new HttpHeaders(); - + mapper.fromHeaders(new MessageHeaders(messageHeaders), headers); } - + @Test public void validateAllowAsString(){ HeaderMapper mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 mapper = DefaultHttpHeaderMapper.inboundMapper(); Map messageHeaders = new HashMap(); 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 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 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 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 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 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 messageHeaders = new HashMap(); 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 messageHeaders = new HashMap(); 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 messageHeaders = new HashMap(); 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{ public String convert(TestClass source) { return "TestClass.class"; } - + } } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java index ccf5aec3fe..744c29d393 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java @@ -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(); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioSSLConnection.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioSSLConnection.java index 895246525b..f0d2974a4d 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioSSLConnection.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioSSLConnection.java @@ -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(); diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/RemoteMBeanServerTests-context.xml b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/RemoteMBeanServerTests-context.xml index 7ae6d9a740..d79873f4de 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/RemoteMBeanServerTests-context.xml +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/RemoteMBeanServerTests-context.xml @@ -67,14 +67,19 @@ The CI build runs with the default profile. --> - - - - - + + + diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/core/HibernateJpaOperationsTests.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/core/HibernateJpaOperationsTests.java index b0db35e35c..d110687109 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/core/HibernateJpaOperationsTests.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/core/HibernateJpaOperationsTests.java @@ -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 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; diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests.java index 3d7b6542ac..cce6ec3dda 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests.java @@ -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(); diff --git a/spring-integration-jpa/src/test/resources/commonJpa-context.xml b/spring-integration-jpa/src/test/resources/commonJpa-context.xml index c5f8b2210b..63b350f9df 100644 --- a/spring-integration-jpa/src/test/resources/commonJpa-context.xml +++ b/spring-integration-jpa/src/test/resources/commonJpa-context.xml @@ -1,7 +1,6 @@ - + + + diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/XPathExpressionParser.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/XPathExpressionParser.java index 044c24b7b4..6b92483640 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/XPathExpressionParser.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/config/XPathExpressionParser.java @@ -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());