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:
committed by
Oleg Zhurakousky
parent
19c53ed9e9
commit
57bc67b8fb
@@ -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)) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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<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),
|
||||
|
||||
@@ -43,6 +43,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
|
||||
private volatile ConversionService conversionService;
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public BeanFactoryTypeConverter() {
|
||||
synchronized (BeanFactoryTypeConverter.class) {
|
||||
if (defaultConversionService == null) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user