IN PROGRESS - issue INT-656: MethodParameterMessageMapper - javadoc vs code
http://jira.springframework.org/browse/INT-656 Made unannotated Properties and Map work, refactored MethodParameterMessageMapper a bit
This commit is contained in:
@@ -84,7 +84,7 @@ public class MethodInvokingMessageHandlerTests {
|
||||
endpoint.setTrigger(new IntervalTrigger(10));
|
||||
context.registerEndpoint("testEndpoint", endpoint);
|
||||
context.refresh();
|
||||
String result = queue.poll(1000, TimeUnit.MILLISECONDS);
|
||||
String result = queue.poll(2000, TimeUnit.MILLISECONDS);
|
||||
assertNotNull(result);
|
||||
assertEquals("testing", result);
|
||||
context.stop();
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.message;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
@@ -32,6 +31,7 @@ import org.springframework.integration.core.Message;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Iwein Fuld
|
||||
*/
|
||||
public class MethodParameterMessageMapperFromMessageTests {
|
||||
|
||||
@@ -109,6 +109,36 @@ public class MethodParameterMessageMapperFromMessageTests {
|
||||
assertEquals("foo", result.getProperty("prop1"));
|
||||
assertEquals("bar", result.getProperty("prop2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageWithPropertiesAndObjectMethod() throws Exception {
|
||||
Method method = TestService.class.getMethod("propertiesHeadersAndPayload", Properties.class, Object.class);
|
||||
MethodParameterMessageMapper mapper = new MethodParameterMessageMapper(method);
|
||||
Message<String> message = MessageBuilder.withPayload("test")
|
||||
.setHeader("prop1", "foo").setHeader("prop2", "bar").build();
|
||||
Object[] args = mapper.fromMessage(message);
|
||||
Properties result = (Properties) args[0];
|
||||
assertEquals(2, result.size());
|
||||
assertEquals("foo", result.getProperty("prop1"));
|
||||
assertEquals("bar", result.getProperty("prop2"));
|
||||
assertEquals("test", args[1]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void fromMessageWithMapAndObjectMethod() throws Exception {
|
||||
Method method = TestService.class.getMethod("mapHeadersAndPayload", Map.class, Object.class);
|
||||
MethodParameterMessageMapper mapper = new MethodParameterMessageMapper(method);
|
||||
Message<String> message = MessageBuilder.withPayload("test")
|
||||
.setHeader("prop1", "foo").setHeader("prop2", "bar").build();
|
||||
Object[] args = mapper.fromMessage(message);
|
||||
Map result = (Map) args[0];
|
||||
//Map also contains id and timestamp
|
||||
assertEquals(4, result.size());
|
||||
assertEquals("foo", result.get("prop1"));
|
||||
assertEquals("bar", result.get("prop2"));
|
||||
assertEquals("test", args[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageWithPropertiesMethodAndPropertiesPayload() throws Exception {
|
||||
@@ -192,6 +222,10 @@ public class MethodParameterMessageMapperFromMessageTests {
|
||||
public Properties propertiesHeaders(@Headers Properties properties) {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public Object propertiesHeadersAndPayload(Properties headers, Object payload) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map mapPayload(Map map) {
|
||||
@@ -202,11 +236,14 @@ public class MethodParameterMessageMapperFromMessageTests {
|
||||
public Map mapHeaders(@Headers Map map) {
|
||||
return map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object mapHeadersAndPayload(Map headers, Object payload) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public Integer integerMethod(Integer i) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user