1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.jms;
12
13 import org.mule.api.endpoint.ImmutableEndpoint;
14 import org.mule.tck.FunctionalTestCase;
15 import org.mule.transport.jms.DefaultJmsTopicResolver;
16 import org.mule.transport.jms.JmsConnector;
17
18 import com.mockobjects.dynamic.Mock;
19
20 import javax.jms.Queue;
21 import javax.jms.Topic;
22
23 public class DefaultJmsTopicResolverTestCase extends FunctionalTestCase
24 {
25 private JmsConnector connector;
26 private DefaultJmsTopicResolver resolver;
27
28 protected void doSetUp() throws Exception
29 {
30 super.doSetUp();
31 connector = (JmsConnector) muleContext.getRegistry().lookupConnector("jmsConnector");
32 resolver = (DefaultJmsTopicResolver) connector.getTopicResolver();
33 }
34
35 protected String getConfigResources()
36 {
37 return "jms-topic-resolver.xml";
38 }
39
40 public void testSameConnector()
41 {
42 assertSame(connector, resolver.getConnector());
43 }
44
45 public void testEndpointNotTopicWithFallback() throws Exception
46 {
47 ImmutableEndpoint endpoint = muleContext.getRegistry()
48 .lookupEndpointFactory()
49 .getInboundEndpoint("ep1");
50 assertFalse(resolver.isTopic(endpoint));
51 }
52
53 public void testEndpointNotTopicWithFallback2() throws Exception
54 {
55 ImmutableEndpoint endpoint = muleContext.getRegistry()
56 .lookupEndpointFactory()
57 .getInboundEndpoint("ep1");
58 assertFalse(resolver.isTopic(endpoint, true));
59 }
60
61 public void testEndpointNotTopicNoFallback() throws Exception
62 {
63 ImmutableEndpoint endpoint = muleContext.getRegistry()
64 .lookupEndpointFactory()
65 .getInboundEndpoint("ep1");
66 assertFalse(resolver.isTopic(endpoint, false));
67 }
68
69 public void testEndpointTopicPropertyWithFallback() throws Exception
70 {
71 ImmutableEndpoint endpoint = muleContext.getRegistry()
72 .lookupEndpointFactory()
73 .getInboundEndpoint("ep2");
74 assertTrue(resolver.isTopic(endpoint));
75 }
76
77 public void testEndpointTopicPropertyWithFallback2() throws Exception
78 {
79 ImmutableEndpoint endpoint = muleContext.getRegistry()
80 .lookupEndpointFactory()
81 .getInboundEndpoint("ep2");
82 assertTrue(resolver.isTopic(endpoint, true));
83 }
84
85 public void testEndpointTopicPropertyNoFallback() throws Exception
86 {
87 ImmutableEndpoint endpoint = muleContext.getRegistry()
88 .lookupEndpointFactory()
89 .getInboundEndpoint("ep2");
90 assertFalse(resolver.isTopic(endpoint, false));
91 }
92
93 public void testEndpointTopicPrefixWithFallback() throws Exception
94 {
95 ImmutableEndpoint endpoint = muleContext.getRegistry()
96 .lookupEndpointFactory()
97 .getInboundEndpoint("ep3");
98 assertTrue(resolver.isTopic(endpoint));
99 }
100
101 public void testEndpointTopicPrefixWithFallback2() throws Exception
102 {
103 ImmutableEndpoint endpoint = muleContext.getRegistry()
104 .lookupEndpointFactory()
105 .getInboundEndpoint("ep3");
106 assertTrue(resolver.isTopic(endpoint, true));
107 }
108
109 public void testEndpointTopicPrefixNoFallback() throws Exception
110 {
111 ImmutableEndpoint endpoint = muleContext.getRegistry()
112 .lookupEndpointFactory()
113 .getInboundEndpoint("ep3");
114 assertTrue(resolver.isTopic(endpoint, false));
115 }
116
117 public void testEndpointTopicPrefixAndPropertyWithFallback() throws Exception
118 {
119 ImmutableEndpoint endpoint = muleContext.getRegistry()
120 .lookupEndpointFactory()
121 .getInboundEndpoint("ep4");
122 assertTrue(resolver.isTopic(endpoint));
123 }
124
125 public void testEndpointTopicPrefixAndPropertyWithFallback2() throws Exception
126 {
127 ImmutableEndpoint endpoint = muleContext.getRegistry()
128 .lookupEndpointFactory()
129 .getInboundEndpoint("ep4");
130 assertTrue(resolver.isTopic(endpoint, true));
131 }
132
133 public void testEndpointTopicPrefixAndPropertyNoFallback() throws Exception
134 {
135 ImmutableEndpoint endpoint = muleContext.getRegistry()
136 .lookupEndpointFactory()
137 .getInboundEndpoint("ep4");
138 assertTrue(resolver.isTopic(endpoint, false));
139 }
140
141 public void testEndpointTopicUsesEndpointProperties() throws Exception
142 {
143 ImmutableEndpoint endpoint = muleContext.getRegistry()
144 .lookupEndpointFactory()
145 .getInboundEndpoint("ep5");
146 assertTrue(resolver.isTopic(endpoint));
147 }
148
149
150 public void testDestinationNotTopic() throws Exception
151 {
152
153 Mock mock = new Mock(Queue.class);
154 Queue queue = (Queue) mock.proxy();
155
156 assertFalse(resolver.isTopic(queue));
157 mock.verify();
158 }
159
160 public void testDestinationTopic() throws Exception
161 {
162
163 Mock mock = new Mock(Topic.class);
164 Topic topic = (Topic) mock.proxy();
165
166 assertTrue(resolver.isTopic(topic));
167 mock.verify();
168 }
169
170 }