KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > command > MessageTest


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 package org.apache.activemq.command;
19
20 import java.io.IOException JavaDoc;
21
22 import junit.framework.Test;
23 import junit.textui.TestRunner;
24
25 public class MessageTest extends DataStructureTestSupport {
26
27     public boolean cacheEnabled;
28
29     public static Test suite() {
30         return suite(MessageTest.class);
31     }
32
33     public static void main(String JavaDoc[] args) {
34         TestRunner.run(suite());
35     }
36
37     public void initCombosForTestActiveMQMessageMarshaling() {
38         addCombinationValues("cacheEnabled", new Object JavaDoc[] { Boolean.TRUE, Boolean.FALSE });
39     }
40
41     public void testActiveMQMessageMarshaling() throws IOException JavaDoc {
42         ActiveMQMessage message = new ActiveMQMessage();
43         message.setCommandId((short) 1);
44         message.setOriginalDestination(new ActiveMQQueue("queue"));
45         message.setGroupID("group");
46         message.setGroupSequence(4);
47         message.setCorrelationId("correlation");
48         message.setMessageId(new MessageId("c1:1:1", 1));
49         assertBeanMarshalls(message);
50     }
51
52     public void testActiveMQMessageMarshalingBigMessageId() throws IOException JavaDoc {
53         ActiveMQMessage message = new ActiveMQMessage();
54         message.setCommandId((short) 1);
55         message.setOriginalDestination(new ActiveMQQueue("queue"));
56         message.setGroupID("group");
57         message.setGroupSequence(4);
58         message.setCorrelationId("correlation");
59         message.setMessageId(new MessageId("c1:1:1", Short.MAX_VALUE));
60         assertBeanMarshalls(message);
61     }
62
63     public void testActiveMQMessageMarshalingBiggerMessageId() throws IOException JavaDoc {
64         ActiveMQMessage message = new ActiveMQMessage();
65         message.setCommandId((short) 1);
66         message.setOriginalDestination(new ActiveMQQueue("queue"));
67         message.setGroupID("group");
68         message.setGroupSequence(4);
69         message.setCorrelationId("correlation");
70         message.setMessageId(new MessageId("c1:1:1", Integer.MAX_VALUE));
71         assertBeanMarshalls(message);
72     }
73
74     public void testActiveMQMessageMarshalingBiggestMessageId() throws IOException JavaDoc {
75         ActiveMQMessage message = new ActiveMQMessage();
76         message.setCommandId((short) 1);
77         message.setOriginalDestination(new ActiveMQQueue("queue"));
78         message.setGroupID("group");
79         message.setGroupSequence(4);
80         message.setCorrelationId("correlation");
81         message.setMessageId(new MessageId("c1:1:1", Long.MAX_VALUE));
82         assertBeanMarshalls(message);
83     }
84
85     public void testMessageIdMarshaling() throws IOException JavaDoc {
86         assertBeanMarshalls(new MessageId("c1:1:1", 1));
87     }
88
89 }
90
Popular Tags