KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.ArrayList JavaDoc;
22 import java.util.Arrays JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.SortedSet JavaDoc;
26 import java.util.TreeMap JavaDoc;
27 import java.util.TreeSet JavaDoc;
28
29 import org.apache.activemq.command.ActiveMQDestination;
30 import org.apache.activemq.command.ActiveMQQueue;
31 import org.apache.activemq.command.ActiveMQTempQueue;
32 import org.apache.activemq.command.ActiveMQTempTopic;
33 import org.apache.activemq.command.ActiveMQTopic;
34
35 import junit.framework.Test;
36
37 public class ActiveMQDestinationTest extends DataStructureTestSupport {
38
39     public ActiveMQDestination destination;
40     
41     public void initCombosForTestDesintaionMarshaling() {
42         addCombinationValues("destination", new Object JavaDoc[]{
43                 new ActiveMQQueue("TEST"),
44                 new ActiveMQTopic("TEST"),
45                 new ActiveMQTempQueue("TEST:1"),
46                 new ActiveMQTempTopic("TEST:1"),
47                 new ActiveMQTempQueue("TEST"),
48                 new ActiveMQTempTopic("TEST"),
49                 new ActiveMQQueue("TEST?option=value"),
50                 new ActiveMQTopic("TEST?option=value"),
51                 new ActiveMQTempQueue("TEST:1?option=value"),
52                 new ActiveMQTempTopic("TEST:1?option=value"),
53         });
54     }
55     
56     public void testDesintaionMarshaling() throws IOException JavaDoc {
57         assertBeanMarshalls(destination);
58     }
59     
60     public void initCombosForTestDesintaionOptions() {
61         addCombinationValues("destination", new Object JavaDoc[]{
62                 new ActiveMQQueue("TEST?k1=v1&k2=v2"),
63                 new ActiveMQTopic("TEST?k1=v1&k2=v2"),
64                 new ActiveMQTempQueue("TEST:1?k1=v1&k2=v2"),
65                 new ActiveMQTempTopic("TEST:1?k1=v1&k2=v2"),
66         });
67     }
68     
69     public void testDesintaionOptions() throws IOException JavaDoc {
70         Map JavaDoc options = destination.getOptions();
71         assertNotNull(options);
72         assertEquals("v1", options.get("k1"));
73         assertEquals("v2", options.get("k2"));
74     }
75     
76     public void testSorting() throws Exception JavaDoc {
77         SortedSet JavaDoc set = new TreeSet JavaDoc();
78         ActiveMQDestination[] destinations = { new ActiveMQQueue("A"), new ActiveMQQueue("B"), new ActiveMQTopic("A"), new ActiveMQTopic("B") };
79         List JavaDoc expected = Arrays.asList(destinations);
80         set.addAll(expected);
81         List JavaDoc actual = new ArrayList JavaDoc(set);
82         assertEquals("Sorted order", expected, actual);
83     }
84     
85    
86     public static Test suite() {
87         return suite(ActiveMQDestinationTest.class);
88     }
89     
90     public static void main(String JavaDoc[] args) {
91         junit.textui.TestRunner.run(suite());
92     }
93     
94 }
95
Popular Tags