use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testMoveMetadataJmsMessageToAdaptrisMessage.
@Test
public void testMoveMetadataJmsMessageToAdaptrisMessage() throws Exception {
MessageTypeTranslatorImp trans = createTranslator();
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);
} finally {
stop(trans);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testMoveJmsHeadersJmsMessageToAdaptrisMessage.
@Test
public void testMoveJmsHeadersJmsMessageToAdaptrisMessage() throws Exception {
MessageTypeTranslatorImp trans = createTranslator();
try {
Session session = activeMqBroker.createConnection().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.setMoveJmsHeaders(true);
start(trans, session);
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);
}
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testSetMoveJmsHeaders.
@Test
public void testSetMoveJmsHeaders() throws Exception {
MessageTypeTranslatorImp translator = createTranslator();
assertNull(translator.getMoveJmsHeaders());
assertFalse(translator.moveJmsHeaders());
translator.setMoveJmsHeaders(Boolean.TRUE);
assertEquals(Boolean.TRUE, translator.getMoveJmsHeaders());
assertTrue(translator.moveJmsHeaders());
translator.setMoveJmsHeaders(null);
assertNull(translator.getMoveJmsHeaders());
assertFalse(translator.moveJmsHeaders());
}
use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.
the class MessageTypeTranslatorCase method testMoveMetadata_AdaptrisMessageToJmsMessage_RemoveAll.
@Test
public void testMoveMetadata_AdaptrisMessageToJmsMessage_RemoveAll() throws Exception {
MessageTypeTranslatorImp trans = createTranslator().withMetadataFilter(new RemoveAllMetadataFilter());
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);
assertNull(jmsMsg.getStringProperty(STRING_METADATA));
assertNull(jmsMsg.getStringProperty(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 testBug895.
@Test
public void testBug895() throws Exception {
MessageTypeTranslatorImp trans = createTranslator();
try {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(JmsConstants.JMS_PRIORITY, "9");
msg.addMetadata(JmsConstants.JMS_TYPE, "idaho");
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
trans.setMoveJmsHeaders(true);
start(trans, session);
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);
}
}
Aggregations