INT-28 Added support for headers based on the evaluation of EL expressions provided on the @Publisher annotation.
This commit is contained in:
@@ -88,22 +88,25 @@ public class MessagePublishingInterceptorTests {
|
||||
return new String[] { "a1", "a2" };
|
||||
}
|
||||
|
||||
public String getChannelName(Method method) {
|
||||
return "c";
|
||||
public String getReturnValueName(Method method) {
|
||||
return "r";
|
||||
}
|
||||
|
||||
public String getExceptionName(Method method) {
|
||||
return "x";
|
||||
}
|
||||
|
||||
public String getExpressionString(Method method) {
|
||||
public String getPayloadExpression(Method method) {
|
||||
return "#r";
|
||||
}
|
||||
|
||||
public String getReturnValueName(Method method) {
|
||||
return "r";
|
||||
public String[] getHeaderExpressions(Method method) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getChannelName(Method method) {
|
||||
return "c";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.aop;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -33,11 +34,15 @@ public class MethodAnnotationExpressionSourceTests {
|
||||
@Test
|
||||
public void defaultBindings() {
|
||||
Method method = getMethod("methodWithExpressionAnnotationOnly", String.class, int.class);
|
||||
String expressionString = source.getExpressionString(method);
|
||||
String expressionString = source.getPayloadExpression(method);
|
||||
assertEquals("testExpression1", expressionString);
|
||||
assertEquals(2, source.getArgumentNames(method).length);
|
||||
assertEquals("arg1", source.getArgumentNames(method)[0]);
|
||||
assertEquals("arg2", source.getArgumentNames(method)[1]);
|
||||
String[] headerStrings = source.getHeaderExpressions(method);
|
||||
assertNotNull(headerStrings);
|
||||
assertEquals(1, headerStrings.length);
|
||||
assertEquals("", headerStrings[0]);
|
||||
assertEquals(ExpressionSource.DEFAULT_ARGUMENT_MAP_NAME, source.getArgumentMapName(method));
|
||||
assertEquals(ExpressionSource.DEFAULT_EXCEPTION_NAME, source.getExceptionName(method));
|
||||
assertEquals(ExpressionSource.DEFAULT_RETURN_VALUE_NAME, source.getReturnValueName(method));
|
||||
@@ -46,7 +51,7 @@ public class MethodAnnotationExpressionSourceTests {
|
||||
@Test
|
||||
public void annotationBindings() {
|
||||
Method method = getMethod("methodWithExpressionBinding", String.class, int.class);
|
||||
String expressionString = source.getExpressionString(method);
|
||||
String expressionString = source.getPayloadExpression(method);
|
||||
assertEquals("testExpression2", expressionString);
|
||||
assertEquals(2, source.getArgumentNames(method).length);
|
||||
assertEquals("s", source.getArgumentNames(method)[0]);
|
||||
@@ -78,7 +83,7 @@ public class MethodAnnotationExpressionSourceTests {
|
||||
public void methodWithExpressionAnnotationOnly(String arg1, int arg2) {
|
||||
}
|
||||
|
||||
@Publisher(value="#return", channel="foo")
|
||||
@Publisher(value="#return", channel="foo", headers="bar=123")
|
||||
public void methodWithChannelAndReturnAsPayload() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user