use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class BlobMessageTranslatorTest method testMoveMetadataAdaptrisMessageToJmsMessage.
@Test
public void testMoveMetadataAdaptrisMessageToJmsMessage() throws Exception {
MessageTypeTranslatorImp trans = new BlobMessageTranslator();
JmsConnection conn = null;
try {
conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
start(conn);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
addMetadata(msg);
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
trans.registerSession(session);
trans.registerMessageFactory(new DefaultMessageFactory());
start(trans);
Message jmsMsg = trans.translate(msg);
assertJmsProperties(jmsMsg);
} finally {
stop(trans);
stop(conn);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class BlobMessageTranslatorTest method testMoveJmsHeadersJmsMessageToAdaptrisMessage.
@Test
public void testMoveJmsHeadersJmsMessageToAdaptrisMessage() throws Exception {
MessageTypeTranslatorImp trans = new BlobMessageTranslator();
JmsConnection conn = null;
try {
conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
start(conn);
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Message jmsMsg = createMessage(session);
jmsMsg.setJMSCorrelationID("ABC");
jmsMsg.setJMSDeliveryMode(1);
jmsMsg.setJMSPriority(4);
addProperties(jmsMsg);
long timestamp = System.currentTimeMillis();
jmsMsg.setJMSTimestamp(timestamp);
trans.registerSession(session);
trans.registerMessageFactory(new DefaultMessageFactory());
trans.setMoveJmsHeaders(true);
start(trans);
AdaptrisMessage msg = trans.translate(jmsMsg);
assertMetadata(msg);
assertEquals("ABC", msg.getMetadataValue(JmsConstants.JMS_CORRELATION_ID));
assertEquals("1", msg.getMetadataValue(JmsConstants.JMS_DELIVERY_MODE));
assertEquals("4", msg.getMetadataValue(JmsConstants.JMS_PRIORITY));
assertEquals(String.valueOf(timestamp), msg.getMetadataValue(JmsConstants.JMS_TIMESTAMP));
} finally {
stop(trans);
stop(conn);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testRoundTrip.
@Test
public void testRoundTrip() throws Exception {
MessageTypeTranslatorImp translator = createTranslator().withMoveJmsHeaders(true).withMetadataFilter(new NoOpMetadataFilter()).withReportAllErrors(true);
StandaloneProducer p1 = createProducer(translator);
StandaloneProducer p2 = roundTrip(p1);
BaseCase.assertRoundtripEquality(p1, p2);
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testMoveMetadata_AdaptrisMessageToJmsMessage_WithFilter.
@Test
public void testMoveMetadata_AdaptrisMessageToJmsMessage_WithFilter() throws Exception {
MessageTypeTranslatorImp trans = createTranslator();
RegexMetadataFilter regexp = new RegexMetadataFilter();
regexp.addExcludePattern("IntegerMetadataKey");
trans.setMetadataFilter(regexp);
try {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
addMetadata(msg);
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
start(trans, session);
Message jmsMsg = trans.translate(msg);
assertEquals(STRING_VALUE, jmsMsg.getStringProperty(STRING_METADATA));
assertEquals(BOOLEAN_VALUE, jmsMsg.getStringProperty(BOOLEAN_METADATA));
assertEquals(Boolean.valueOf(BOOLEAN_VALUE).booleanValue(), jmsMsg.getBooleanProperty(BOOLEAN_METADATA));
assertNull(jmsMsg.getStringProperty(INTEGER_METADATA));
} finally {
stop(trans);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testMoveMetadataJmsMessageToAdaptrisMessage_RemoveAllFilter.
@Test
public void testMoveMetadataJmsMessageToAdaptrisMessage_RemoveAllFilter() throws Exception {
MessageTypeTranslatorImp trans = createTranslator();
trans.setMetadataFilter(new RemoveAllMetadataFilter());
try {
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
Message jmsMsg = createMessage(session);
addProperties(jmsMsg);
start(trans, session);
AdaptrisMessage msg = trans.translate(jmsMsg);
assertFalse(msg.containsKey(INTEGER_METADATA));
assertFalse(msg.containsKey(STRING_METADATA));
assertFalse(msg.containsKey(BOOLEAN_METADATA));
} finally {
stop(trans);
}
}
Aggregations