1 18 package org.apache.activemq.command; 19 20 import java.io.IOException ; 21 import java.util.ArrayList ; 22 import java.util.Arrays ; 23 import java.util.List ; 24 import java.util.Map ; 25 import java.util.SortedSet ; 26 import java.util.TreeMap ; 27 import java.util.TreeSet ; 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 []{ 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 { 57 assertBeanMarshalls(destination); 58 } 59 60 public void initCombosForTestDesintaionOptions() { 61 addCombinationValues("destination", new Object []{ 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 { 70 Map 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 { 77 SortedSet set = new TreeSet (); 78 ActiveMQDestination[] destinations = { new ActiveMQQueue("A"), new ActiveMQQueue("B"), new ActiveMQTopic("A"), new ActiveMQTopic("B") }; 79 List expected = Arrays.asList(destinations); 80 set.addAll(expected); 81 List actual = new ArrayList (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 [] args) { 91 junit.textui.TestRunner.run(suite()); 92 } 93 94 } 95 | Popular Tags |