use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testMoveJmsHeadersAdaptrisMessageToJmsMessage.
@Test
public void testMoveJmsHeadersAdaptrisMessageToJmsMessage() throws Exception {
MessageTypeTranslatorImp trans = createTranslator().withMoveJmsHeaders(true);
try {
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
addMetadata(msg);
addRedundantJmsHeaders(msg);
start(trans, session);
Message jmsMsg = trans.translate(msg);
assertEquals(msg.getMetadataValue(JMS_TYPE), jmsMsg.getJMSType());
assertNotSame(msg.getMetadataValue(JMS_CORRELATION_ID), jmsMsg.getJMSCorrelationID());
assertNotSame(msg.getMetadataValue(JMS_TIMESTAMP), jmsMsg.getJMSTimestamp());
assertNotSame(msg.getMetadataValue(JMS_REDELIVERED), jmsMsg.getJMSPriority());
assertNotSame(msg.getMetadataValue(JMS_MESSAGE_ID), jmsMsg.getJMSMessageID());
assertNotSame(msg.getMetadataValue(JMS_EXPIRATION), jmsMsg.getJMSExpiration());
assertNotSame(msg.getMetadataValue(JMS_DELIVERY_MODE), jmsMsg.getJMSDeliveryMode());
assertJmsProperties(jmsMsg);
} finally {
stop(trans);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testMoveMetadataAdaptrisMessageToJmsMessage.
@Test
public void testMoveMetadataAdaptrisMessageToJmsMessage() throws Exception {
MessageTypeTranslatorImp trans = createTranslator();
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);
assertJmsProperties(jmsMsg);
} finally {
stop(trans);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testMoveMetadata_JmsMessageToAdaptrisMessage_WithFilter.
@Test
public void testMoveMetadata_JmsMessageToAdaptrisMessage_WithFilter() throws Exception {
MessageTypeTranslatorImp trans = createTranslator();
RegexMetadataFilter regexp = new RegexMetadataFilter();
regexp.addExcludePattern("IntegerMetadataKey");
trans.setMetadataFilter(regexp);
try {
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
Message jmsMsg = createMessage(session);
addProperties(jmsMsg);
start(trans, session);
AdaptrisMessage msg = trans.translate(jmsMsg);
assertMetadata(msg, new MetadataElement(STRING_METADATA, STRING_VALUE));
assertMetadata(msg, new MetadataElement(BOOLEAN_METADATA, BOOLEAN_VALUE));
assertFalse(msg.containsKey(INTEGER_METADATA));
} finally {
stop(trans);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class BlobMessageTranslatorTest method testBug895.
@Test
public void testBug895() throws Exception {
MessageTypeTranslatorImp trans = new BlobMessageTranslator();
JmsConnection conn = null;
try {
conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
start(conn);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(JmsConstants.JMS_PRIORITY, "9");
msg.addMetadata(JmsConstants.JMS_TYPE, "idaho");
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
trans.setMoveJmsHeaders(true);
trans.registerSession(session);
trans.registerMessageFactory(new DefaultMessageFactory());
start(trans);
Message jmsMsg = trans.translate(msg);
assertNotSame("JMS Priorities should be different", jmsMsg.getJMSPriority(), 9);
assertEquals("JMSType should be equal", "idaho", jmsMsg.getJMSType());
} finally {
stop(trans);
stop(conn);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class BlobMessageTranslatorTest method testMoveMetadataJmsMessageToAdaptrisMessage.
@Test
public void testMoveMetadataJmsMessageToAdaptrisMessage() 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);
addProperties(jmsMsg);
trans.registerSession(session);
trans.registerMessageFactory(new DefaultMessageFactory());
start(trans);
AdaptrisMessage msg = trans.translate(jmsMsg);
assertMetadata(msg);
} finally {
stop(trans);
stop(conn);
}
}
Aggregations