INT-1569 added inboundPrefix and outboundPrefix to DefaultJmsHeaderMapper. For now, the defaults are blank.

This commit is contained in:
Mark Fisher
2010-11-12 13:01:41 -05:00
parent 79eb43f293
commit dbbcde22cd
2 changed files with 98 additions and 20 deletions

View File

@@ -129,6 +129,21 @@ public class DefaultJmsHeaderMapperTests {
assertEquals(123, ((Integer) value).intValue());
}
@Test
public void testUserDefinedPropertyMappedFromHeaderWithCustomPrefix() throws JMSException {
Message<String> message = MessageBuilder.withPayload("test")
.setHeader("foo", new Integer(123))
.build();
DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
mapper.setOutboundPrefix("custom_");
javax.jms.Message jmsMessage = new StubTextMessage();
mapper.fromHeaders(message.getHeaders(), jmsMessage);
Object value = jmsMessage.getObjectProperty("custom_foo");
assertNotNull(value);
assertEquals(Integer.class, value.getClass());
assertEquals(123, ((Integer) value).intValue());
}
@Test
public void testUserDefinedPropertyWithUnsupportedType() throws JMSException {
Destination destination = new Destination() {};
@@ -202,6 +217,19 @@ public class DefaultJmsHeaderMapperTests {
assertEquals(123, ((Integer) attrib).intValue());
}
@Test
public void testUserDefinedPropertyMappedToHeaderWithCustomPrefix() throws JMSException {
javax.jms.Message jmsMessage = new StubTextMessage();
jmsMessage.setIntProperty("foo", 123);
DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
mapper.setInboundPrefix("custom_");
Map<String, Object> headers = mapper.toHeaders(jmsMessage);
Object header = headers.get("custom_foo");
assertNotNull(header);
assertEquals(Integer.class, header.getClass());
assertEquals(123, ((Integer) header).intValue());
}
@Test
public void testPropertyMappingExceptionIsNotFatal() throws JMSException {
Message<String> message = MessageBuilder.withPayload("test")