1 18 19 package org.apache.activemq; 20 21 import javax.jms.BytesMessage ; 22 import javax.jms.MapMessage ; 23 import javax.jms.ObjectMessage ; 24 import javax.jms.Queue ; 25 import javax.jms.StreamMessage ; 26 import javax.jms.TemporaryQueue ; 27 import javax.jms.TemporaryTopic ; 28 import javax.jms.TextMessage ; 29 import javax.jms.Topic ; 30 31 import junit.framework.TestCase; 32 33 import org.apache.activemq.ActiveMQMessageTransformation; 34 import org.apache.activemq.command.ActiveMQBytesMessage; 35 import org.apache.activemq.command.ActiveMQDestination; 36 import org.apache.activemq.command.ActiveMQMapMessage; 37 import org.apache.activemq.command.ActiveMQMessage; 38 import org.apache.activemq.command.ActiveMQObjectMessage; 39 import org.apache.activemq.command.ActiveMQQueue; 40 import org.apache.activemq.command.ActiveMQStreamMessage; 41 import org.apache.activemq.command.ActiveMQTempQueue; 42 import org.apache.activemq.command.ActiveMQTempTopic; 43 import org.apache.activemq.command.ActiveMQTextMessage; 44 import org.apache.activemq.command.ActiveMQTopic; 45 46 public class MessageTransformationTest extends TestCase { 47 48 53 protected void setUp() throws Exception { 54 } 55 56 59 protected void tearDown() throws Exception { 60 } 61 62 65 public void testTransformDestination() throws Exception { 66 assertTrue("Transforming a TempQueue destination to an ActiveMQTempQueue", ActiveMQMessageTransformation.transformDestination((TemporaryQueue )new ActiveMQTempQueue()) instanceof ActiveMQTempQueue); 67 68 assertTrue("Transforming a TempTopic destination to an ActiveMQTempTopic", ActiveMQMessageTransformation.transformDestination((TemporaryTopic )new ActiveMQTempTopic()) instanceof ActiveMQTempTopic); 69 70 assertTrue("Transforming a Queue destination to an ActiveMQQueue", ActiveMQMessageTransformation.transformDestination((Queue )new ActiveMQQueue()) instanceof ActiveMQQueue); 71 72 assertTrue("Transforming a Topic destination to an ActiveMQTopic", ActiveMQMessageTransformation.transformDestination((Topic )new ActiveMQTopic()) instanceof ActiveMQTopic); 73 74 assertTrue("Transforming a Destination to an ActiveMQDestination", ActiveMQMessageTransformation.transformDestination((ActiveMQDestination)new ActiveMQTopic()) instanceof ActiveMQDestination); 75 } 76 77 80 public void testTransformMessage() throws Exception { 81 assertTrue("Transforming a BytesMessage message into an ActiveMQBytesMessage",ActiveMQMessageTransformation.transformMessage((BytesMessage )new ActiveMQBytesMessage(), null) instanceof ActiveMQBytesMessage); 82 83 assertTrue("Transforming a MapMessage message to an ActiveMQMapMessage",ActiveMQMessageTransformation.transformMessage((MapMessage )new ActiveMQMapMessage(), null) instanceof ActiveMQMapMessage); 84 85 assertTrue("Transforming an ObjectMessage message to an ActiveMQObjectMessage",ActiveMQMessageTransformation.transformMessage((ObjectMessage )new ActiveMQObjectMessage(), null) instanceof ActiveMQObjectMessage); 86 87 assertTrue("Transforming a StreamMessage message to an ActiveMQStreamMessage",ActiveMQMessageTransformation.transformMessage((StreamMessage )new ActiveMQStreamMessage(), null) instanceof ActiveMQStreamMessage); 88 89 assertTrue("Transforming a TextMessage message to an ActiveMQTextMessage",ActiveMQMessageTransformation.transformMessage((TextMessage )new ActiveMQTextMessage(), null) instanceof ActiveMQTextMessage); 90 91 assertTrue("Transforming an ActiveMQMessage message to an ActiveMQMessage",ActiveMQMessageTransformation.transformMessage(new ActiveMQMessage(), null) instanceof ActiveMQMessage); 92 } 93 } 94 | Popular Tags |