JmsReplyToCacheValueTranslator implements CacheValueTranslator<Destination> { @Override public void addValueToMessage(AdaptrisMessage msg, Destination value) throws CoreException { msg.addObjectHeader(JmsConstants.OBJ_JMS_REPLY_TO_KEY, value); }  @Override Destination getValueFromMessage(AdaptrisMessage msg); @Override void addValueToMessage(AdaptrisMessage msg, Destination value);  }
@Test public void testAddValueToMessage() throws Exception { AdaptrisMessage message = createMessage(); JmsReplyToCacheValueTranslator translator = new JmsReplyToCacheValueTranslator(); translator.addValueToMessage(message, new Queue() { @Override public String getQueueName() throws JMSException { return "HelloWorld"; } }); assertEquals("HelloWorld", ((Queue) message.getObjectHeaders().get(JmsConstants.OBJ_JMS_REPLY_TO_KEY)).getQueueName()); }
@Test public void testAddInvalidValueToMessage() throws Exception { AdaptrisMessage message = createMessage(); CacheValueTranslator translator = new JmsReplyToCacheValueTranslator(); try { translator.addValueToMessage(message, new Object()); fail("Successfully added an object that isn't a javax.jms.Destination"); } catch (ClassCastException expected) { ; } }