INT-3492: Deprecate @Payload and @Header(s)

JIRA: https://jira.spring.io/browse/INT-3492

Since `@Paylod` and `@Header(s)` annotations are in the Spring Framework,
there is no more need to support them in Spring Integration.

Deprecate them and leave for backward compatibility.
Will be removed in future releases.

Remove deprecated Gatewa's `#method` expression evaluation context variable

Tested `gradlew clean testall` with and without changed to the tests.

INT-3492: Add `MessagingAnnotationUtils#findMassagePartAnnotation`

Move `MessagingAnnotationUtils` to the `org.springframework.integration.util` package
This commit is contained in:
Artem Bilan
2014-08-21 22:32:47 +03:00
committed by Gary Russell
parent 162ef1f227
commit 00c404f383
57 changed files with 411 additions and 274 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -13,20 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aggregator;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.util.ReflectionUtils;
/**
* @author Dave Syer
*
*
*/
public class CorrelationStrategyAdapterTests {
@@ -39,7 +41,8 @@ public class CorrelationStrategyAdapterTests {
@Test
public void testMethodName() {
MethodInvokingCorrelationStrategy adapter = new MethodInvokingCorrelationStrategy(new SimpleMessageCorrelator(), "getKey");
MethodInvokingCorrelationStrategy adapter =
new MethodInvokingCorrelationStrategy(new SimpleMessageCorrelator(), "getKey");
assertEquals("b", adapter.getCorrelationKey(message));
}
@@ -52,13 +55,15 @@ public class CorrelationStrategyAdapterTests {
@Test
public void testCorrelationStrategyAdapterPojoMethod() {
MethodInvokingCorrelationStrategy adapter = new MethodInvokingCorrelationStrategy(new SimplePojoCorrelator(), "getKey");
MethodInvokingCorrelationStrategy adapter =
new MethodInvokingCorrelationStrategy(new SimplePojoCorrelator(), "getKey");
assertEquals("foo", adapter.getCorrelationKey(message));
}
@Test
public void testHeaderPojoMethod() {
MethodInvokingCorrelationStrategy adapter = new MethodInvokingCorrelationStrategy(new SimpleHeaderCorrelator(), "getKey");
MethodInvokingCorrelationStrategy adapter =
new MethodInvokingCorrelationStrategy(new SimpleHeaderCorrelator(), "getKey");
assertEquals("b", adapter.getCorrelationKey(message));
}
@@ -74,6 +79,7 @@ public class CorrelationStrategyAdapterTests {
public String getKey(@Header("a") String header, @Header("c") String other) {
return header + other;
}
}
private static class SimpleHeaderCorrelator {
@@ -81,6 +87,7 @@ public class CorrelationStrategyAdapterTests {
public String getKey(@Header("a") String header) {
return header;
}
}
private static class SimplePojoCorrelator {
@@ -88,6 +95,7 @@ public class CorrelationStrategyAdapterTests {
public String getKey(String message) {
return message;
}
}
private static class SimpleMessageCorrelator {
@@ -95,6 +103,7 @@ public class CorrelationStrategyAdapterTests {
public String getKey(Message<?> message) {
return (String) message.getHeaders().get("a");
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -16,6 +16,13 @@
package org.springframework.integration.aggregator;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -28,31 +35,23 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payloads;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.support.MessageBuilder;
import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.support.GenericMessage;
@RunWith(MockitoJUnitRunner.class)
public class MethodInvokingMessageGroupProcessorTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -23,8 +23,8 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.annotation.Publisher;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.test.context.ContextConfiguration;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -24,8 +24,8 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.annotation.Publisher;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.test.context.ContextConfiguration;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -24,8 +24,8 @@ import java.util.Map;
import org.junit.Test;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.annotation.Publisher;
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2014 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.
@@ -30,7 +30,7 @@ import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.annotation.Publisher;
import org.springframework.integration.channel.QueueChannel;

View File

@@ -25,8 +25,8 @@ import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.expression.EvaluationContext;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.annotation.Publisher;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.config.IntegrationEvaluationContextFactoryBean;

View File

@@ -72,7 +72,7 @@ import org.springframework.integration.annotation.InboundChannelAdapter;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.annotation.Poller;
import org.springframework.integration.annotation.Publisher;
import org.springframework.integration.annotation.ServiceActivator;

View File

@@ -46,10 +46,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.annotation.BridgeTo;
import org.springframework.integration.annotation.Gateway;
import org.springframework.integration.annotation.Header;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.support.MessageBuilder;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -31,9 +31,9 @@ import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.mapping.MessageMappingException;
import org.springframework.integration.support.MessageBuilder;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -28,18 +28,19 @@ import org.junit.Test;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.config.IntegrationEvaluationContextFactoryBean;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
* @since 2.0
*/
public class GatewayProxyMessageMappingTests {
@@ -214,6 +215,10 @@ public class GatewayProxyMessageMappingTests {
void payloadAndHeaderMapWithoutAnnotations(String s, Map<String, Object> map);
@SuppressWarnings("deprecation")
void payloadAndHeaderMapWithAnnotationsDeprecated(@org.springframework.integration.annotation.Payload String s,
@org.springframework.integration.annotation.Headers Map<String, Object> map);
void payloadAndHeaderMapWithAnnotations(@Payload String s, @Headers Map<String, Object> map);
void headerValuesAndPayloadWithAnnotations(@Header("k1") String x, @Payload String s, @Header("k2") String y);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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,10 +20,11 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.annotation.Header;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -49,7 +50,9 @@ public class GatewayWithHeaderAnnotations {
public static interface TestService {
// wrt INT-1205, priority no longer has a $ prefix, so here we are testing the $custom header as well
public String test(String str, @Header(IntegrationMessageHeaderAccessor.PRIORITY) int priority, @Header("$custom") String custom);
public String test(String str, @Header(IntegrationMessageHeaderAccessor.PRIORITY) int priority,
@Header("$custom") String custom);
}
}

View File

@@ -10,7 +10,7 @@
<int:gateway id="gateway" service-interface="org.springframework.integration.gateway.GatewayWithPayloadExpressionTests$SampleGateway">
<int:method name="send1" request-channel="input" payload-expression="#args[0] + 'bar'"/>
<int:method name="send2" request-channel="input" payload-expression="@testBean.sum(#args[0])"/>
<int:method name="send3" request-channel="input" payload-expression="#method"/>
<int:method name="send3" request-channel="input" payload-expression="#gatewayMethod.name"/>
</int:gateway>
<int:gateway id="annotatedGateway"

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -23,7 +23,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.PollableChannel;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -24,8 +24,8 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Header;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -114,6 +114,7 @@ public class HeaderEnrichedGatewayTests {
public void sendStringWithParameterHeaders(String value,
@Header("headerA") String headerA, @Header("headerB") String headerB);
}
}

View File

@@ -18,7 +18,7 @@ package org.springframework.integration.gateway;
import java.util.concurrent.Future;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.Message;
import reactor.core.composable.Promise;
@@ -44,7 +44,7 @@ public interface TestService {
Message<?> requestReplyWithMessageReturnValue(String input);
@Payload("#method + #args.length")
@Payload("#gatewayMethod.name + #args.length")
String requestReplyWithPayloadAnnotation();
Future<Message<?>> async(String s);

View File

@@ -24,12 +24,12 @@ import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.transformer.MessageTransformingHandler;
import org.springframework.integration.transformer.MethodInvokingTransformer;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Header;
/**
* @author Mark Fisher
@@ -110,17 +110,18 @@ public class HeaderAnnotationTransformerTests {
return payload.toString() + correlationId.toString();
}
public String appendFoo(Object payload, @Header(value = "foo") Object header) {
public String appendFoo(Object payload, @Header("foo") Object header) {
return payload.toString() + header.toString();
}
public String evalCorrelationId(@Header(value = IntegrationMessageHeaderAccessor.CORRELATION_ID + ".toUpperCase()") String result) {
return result.toString();
public String evalCorrelationId(@Header(IntegrationMessageHeaderAccessor.CORRELATION_ID + ".toUpperCase()") String result) {
return result;
}
public String evalFoo(@Header(value = "foo.toUpperCase()", required = true) String result) {
return result.toString();
return result;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -24,7 +24,7 @@ import java.util.Map;
import org.junit.Test;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.transformer.HeaderEnricher;
@@ -98,6 +98,7 @@ public class MethodInvokingHeaderEnricherTests {
map.put("bar", "ABC");
return map;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -40,9 +40,9 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
@@ -114,7 +114,7 @@ public class MethodInvokingMessageProcessorAnnotationTests {
.setHeader("num", new Integer(123)).build();
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testService, method);
Object result = processor.processMessage(message);
assertEquals(new Integer(123), result);
assertEquals(123, result);
}
@Test(expected = MessageHandlingException.class)
@@ -211,8 +211,8 @@ public class MethodInvokingMessageProcessorAnnotationTests {
.setHeader("attrib1", new Integer(123))
.setHeader("attrib2", new Integer(456)).build();
Map<String, Object> result = (Map<String, Object>) processor.processMessage(message);
assertEquals(new Integer(123), result.get("attrib1"));
assertEquals(new Integer(456), result.get("attrib2"));
assertEquals(123, result.get("attrib1"));
assertEquals(456, result.get("attrib2"));
}
@Test
@@ -220,8 +220,8 @@ public class MethodInvokingMessageProcessorAnnotationTests {
Method method = TestService.class.getMethod("mapPayload", Map.class);
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testService, method);
Map<String, Integer> payload = new HashMap<String, Integer>();
payload.put("attrib1", new Integer(88));
payload.put("attrib2", new Integer(99));
payload.put("attrib1", 88);
payload.put("attrib2", 99);
Message<Map<String, Integer>> message = MessageBuilder.withPayload(payload)
.setHeader("attrib1", new Integer(123))
.setHeader("attrib2", new Integer(456)).build();
@@ -447,8 +447,7 @@ public class MethodInvokingMessageProcessorAnnotationTests {
MessageBuilder<Employee> builder = MessageBuilder.withPayload(employee);
builder.setHeader("day", "monday");
builder.setHeader("month", "September");
Message<Employee> message = builder.build();
return message;
return builder.build();
}

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.integration.handler;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -39,7 +40,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.integration.annotation.Header;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
import org.springframework.integration.gateway.RequestReplyExchanger;
@@ -58,7 +59,7 @@ import org.springframework.messaging.support.GenericMessage;
* @author Gary Russell
* @author Gunnar Hillert
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public class MethodInvokingMessageProcessorTests {
private static final Log logger = LogFactory.getLog(MethodInvokingMessageProcessorTests.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2014 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.
@@ -31,9 +31,9 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.integration.support.MessageBuilder;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2014 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.
@@ -26,16 +26,17 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.channel.TestChannelResolver;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.core.DestinationResolver;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.support.GenericMessage;
/**
* @author Mark Fisher
@@ -137,13 +138,13 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
}
@Test
@@ -163,7 +164,8 @@ public class MethodInvokingRouterTests {
this.doTestChannelInstanceResolutionByPayload(router, channelResolver);
}
private void doTestChannelInstanceResolutionByPayload(MethodInvokingRouter router, TestChannelResolver channelResolver) {
private void doTestChannelInstanceResolutionByPayload(MethodInvokingRouter router,
TestChannelResolver channelResolver) {
Message<String> fooMessage = new GenericMessage<String>("foo");
Message<String> barMessage = new GenericMessage<String>("bar");
Message<String> badMessage = new GenericMessage<String>("bad");
@@ -182,9 +184,10 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
@@ -207,7 +210,8 @@ public class MethodInvokingRouterTests {
this.doTestChannelInstanceResolutionByMessage(router, channelResolver);
}
private void doTestChannelInstanceResolutionByMessage(MethodInvokingRouter router, TestChannelResolver channelResolver) {
private void doTestChannelInstanceResolutionByMessage(MethodInvokingRouter router,
TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
@@ -226,9 +230,10 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
@@ -251,7 +256,8 @@ public class MethodInvokingRouterTests {
this.doTestMultiChannelNameResolutionByPayload(router, channelResolver);
}
private void doTestMultiChannelNameResolutionByPayload(MethodInvokingRouter router, TestChannelResolver channelResolver) {
private void doTestMultiChannelNameResolutionByPayload(MethodInvokingRouter router,
TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
@@ -276,9 +282,10 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
}
@@ -300,7 +307,8 @@ public class MethodInvokingRouterTests {
this.doTestMultiChannelNameResolutionByMessage(router, channelResolver);
}
private void doTestMultiChannelNameResolutionByMessage(MethodInvokingRouter router, TestChannelResolver channelResolver) {
private void doTestMultiChannelNameResolutionByMessage(MethodInvokingRouter router,
TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
@@ -325,9 +333,10 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
}
@@ -349,7 +358,8 @@ public class MethodInvokingRouterTests {
this.doTestMultiChannelNameArrayResolutionByMessage(router, channelResolver);
}
private void doTestMultiChannelNameArrayResolutionByMessage(MethodInvokingRouter router, TestChannelResolver channelResolver) {
private void doTestMultiChannelNameArrayResolutionByMessage(MethodInvokingRouter router,
TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
@@ -374,9 +384,10 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
}
@@ -398,7 +409,8 @@ public class MethodInvokingRouterTests {
this.doTestMultiChannelListResolutionByPayload(router, channelResolver);
}
private void doTestMultiChannelListResolutionByPayload(MethodInvokingRouter router, TestChannelResolver channelResolver) {
private void doTestMultiChannelListResolutionByPayload(MethodInvokingRouter router,
TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
@@ -423,9 +435,10 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
@@ -448,7 +461,8 @@ public class MethodInvokingRouterTests {
this.doTestMultiChannelListResolutionByMessage(router, channelResolver);
}
private void doTestMultiChannelListResolutionByMessage(MethodInvokingRouter router, TestChannelResolver channelResolver) {
private void doTestMultiChannelListResolutionByMessage(MethodInvokingRouter router,
TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
@@ -473,9 +487,10 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
@@ -498,7 +513,8 @@ public class MethodInvokingRouterTests {
this.doTestMultiChannelArrayResolutionByMessage(router, channelResolver);
}
private void doTestMultiChannelArrayResolutionByMessage(MethodInvokingRouter router, TestChannelResolver channelResolver) {
private void doTestMultiChannelArrayResolutionByMessage(MethodInvokingRouter router,
TestChannelResolver channelResolver) {
QueueChannel fooChannel = new QueueChannel();
QueueChannel barChannel = new QueueChannel();
channelResolver.addChannel("foo-channel", fooChannel);
@@ -523,9 +539,10 @@ public class MethodInvokingRouterTests {
assertEquals("bar", result2b.getPayload());
try {
router.handleMessage(badMessage);
fail();
} catch (MessageDeliveryException e) {
router.handleMessage(badMessage);
fail();
}
catch (MessageDeliveryException e) {
/* Success */
}
@@ -551,6 +568,7 @@ public class MethodInvokingRouterTests {
}
return null;
}
}
@@ -583,6 +601,7 @@ public class MethodInvokingRouterTests {
}
return results;
}
}
@@ -607,6 +626,7 @@ public class MethodInvokingRouterTests {
}
return null;
}
}
@@ -645,6 +665,7 @@ public class MethodInvokingRouterTests {
}
return results;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -22,17 +22,18 @@ import static org.junit.Assert.assertNotNull;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.springframework.messaging.Message;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Splitter;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.support.GenericMessage;
/**
* @author Mark Fisher
@@ -305,7 +306,6 @@ public class MethodInvokingSplitterTests {
return list;
}
}
;
GenericMessage<List<?>> message = new GenericMessage<List<?>>(Arrays.asList("foo", "bar"));
MethodInvokingSplitter splitter = new MethodInvokingSplitter(new ListSplitter(), "split");
QueueChannel replyChannel = new QueueChannel();
@@ -511,14 +511,11 @@ public class MethodInvokingSplitterTests {
public List<String> splitPayloadAndHeader(String payload, @Header("testHeader") String header) {
String regex = "\\.";
List<String> results = new ArrayList<String>();
for (String s : payload.split(regex)) {
results.add(s);
}
for (String s : header.split(regex)) {
results.add(s);
}
Collections.addAll(results, payload.split(regex));
Collections.addAll(results, header.split(regex));
return results;
}
}
public static class SingleAnnotationTestBean {
@@ -531,6 +528,7 @@ public class MethodInvokingSplitterTests {
public String[] anotherMethod(String input) {
throw new UnsupportedOperationException("incorrect test invocation");
}
}
public static class AmbiguousTypeMatchTestBean {
@@ -544,6 +542,7 @@ public class MethodInvokingSplitterTests {
public String[] method2(String input) {
throw new UnsupportedOperationException("incorrect test invocation");
}
}
public static class SinglePublicMethodTestBean {
@@ -555,6 +554,7 @@ public class MethodInvokingSplitterTests {
String[] anotherMethod(String input) {
throw new UnsupportedOperationException("incorrect test invocation");
}
}
public static class MultiplePublicMethodTestBean {
@@ -566,6 +566,7 @@ public class MethodInvokingSplitterTests {
public String[] method2(String input) {
throw new UnsupportedOperationException("incorrect test invocation");
}
}
@@ -575,5 +576,6 @@ public class MethodInvokingSplitterTests {
private TestStringMessage(String payload) {
super(payload);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -22,9 +22,9 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payload;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.annotation.Transformer;
import org.springframework.messaging.PollableChannel;
import org.springframework.integration.history.MessageHistory;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -24,13 +24,13 @@ import java.util.Properties;
import org.junit.Test;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Transformer;
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.support.GenericMessage;
/**
* @author Mark Fisher
@@ -212,7 +212,7 @@ public class MethodInvokingTransformerTests {
assertNull(result);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Test // this changed in 2.0 see INT-785 and INT-1130
public void headerEnricherConfiguredWithMethodReference() throws Exception {
TestBean testBean = new TestBean();
@@ -231,7 +231,7 @@ public class MethodInvokingTransformerTests {
assertEquals("baz", result.getHeaders().get("prop3"));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Test // this changed in 2.0 see INT-785 and INT-1130
public void headerEnricherConfiguredWithMethodName() throws Exception {
TestBean testBean = new TestBean();
@@ -264,7 +264,7 @@ public class MethodInvokingTransformerTests {
}
@Transformer
public String optionalHeaderTest(String s, @Header(value="number", required=false) Integer num) {
public String optionalHeaderTest(String s, @Header(value = "number", required = false) Integer num) {
return s + num;
}
@@ -290,6 +290,7 @@ public class MethodInvokingTransformerTests {
public Object nullReturnValueTest(Message<?> message) {
return null;
}
}
}