KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > MessageTransformationTest


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.activemq;
20
21 import javax.jms.BytesMessage JavaDoc;
22 import javax.jms.MapMessage JavaDoc;
23 import javax.jms.ObjectMessage JavaDoc;
24 import javax.jms.Queue JavaDoc;
25 import javax.jms.StreamMessage JavaDoc;
26 import javax.jms.TemporaryQueue JavaDoc;
27 import javax.jms.TemporaryTopic JavaDoc;
28 import javax.jms.TextMessage JavaDoc;
29 import javax.jms.Topic JavaDoc;
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     /**
49      * Sets up the resources of the unit test.
50      *
51      * @throws Exception
52      */

53     protected void setUp() throws Exception JavaDoc {
54     }
55
56     /**
57      * Clears up the resources used in the unit test.
58      */

59     protected void tearDown() throws Exception JavaDoc {
60     }
61     
62     /**
63      * Tests transforming destinations into ActiveMQ's destination implementation.
64      */

65     public void testTransformDestination() throws Exception JavaDoc {
66         assertTrue("Transforming a TempQueue destination to an ActiveMQTempQueue", ActiveMQMessageTransformation.transformDestination((TemporaryQueue JavaDoc)new ActiveMQTempQueue()) instanceof ActiveMQTempQueue);
67         
68         assertTrue("Transforming a TempTopic destination to an ActiveMQTempTopic", ActiveMQMessageTransformation.transformDestination((TemporaryTopic JavaDoc)new ActiveMQTempTopic()) instanceof ActiveMQTempTopic);
69         
70         assertTrue("Transforming a Queue destination to an ActiveMQQueue", ActiveMQMessageTransformation.transformDestination((Queue JavaDoc)new ActiveMQQueue()) instanceof ActiveMQQueue);
71         
72         assertTrue("Transforming a Topic destination to an ActiveMQTopic", ActiveMQMessageTransformation.transformDestination((Topic JavaDoc)new ActiveMQTopic()) instanceof ActiveMQTopic);
73         
74         assertTrue("Transforming a Destination to an ActiveMQDestination", ActiveMQMessageTransformation.transformDestination((ActiveMQDestination)new ActiveMQTopic()) instanceof ActiveMQDestination);
75     }
76     
77     /**
78      * Tests transforming messages into ActiveMQ's message implementation.
79      */

80     public void testTransformMessage() throws Exception JavaDoc {
81         assertTrue("Transforming a BytesMessage message into an ActiveMQBytesMessage",ActiveMQMessageTransformation.transformMessage((BytesMessage JavaDoc)new ActiveMQBytesMessage(), null) instanceof ActiveMQBytesMessage);
82         
83         assertTrue("Transforming a MapMessage message to an ActiveMQMapMessage",ActiveMQMessageTransformation.transformMessage((MapMessage JavaDoc)new ActiveMQMapMessage(), null) instanceof ActiveMQMapMessage);
84         
85         assertTrue("Transforming an ObjectMessage message to an ActiveMQObjectMessage",ActiveMQMessageTransformation.transformMessage((ObjectMessage JavaDoc)new ActiveMQObjectMessage(), null) instanceof ActiveMQObjectMessage);
86         
87         assertTrue("Transforming a StreamMessage message to an ActiveMQStreamMessage",ActiveMQMessageTransformation.transformMessage((StreamMessage JavaDoc)new ActiveMQStreamMessage(), null) instanceof ActiveMQStreamMessage);
88         
89         assertTrue("Transforming a TextMessage message to an ActiveMQTextMessage",ActiveMQMessageTransformation.transformMessage((TextMessage JavaDoc)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