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