Source code: org/activemq/broker/impl/AdvisorySupportTest.java
1 /**
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18
19 package org.activemq.broker.impl;
20 import junit.framework.TestCase;
21
22 import org.activemq.message.ActiveMQDestination;
23 import org.activemq.message.ActiveMQTopic;
24 import org.activemq.message.ConnectionInfo;
25 import org.activemq.message.ConsumerInfo;
26 import org.activemq.message.ProducerInfo;
27
28 /**
29 *
30 * AdvisorySupportTest
31 */
32 public class AdvisorySupportTest extends TestCase {
33 /*
34 * @see TestCase#setUp()
35 */
36 protected void setUp() throws Exception {
37 super.setUp();
38 }
39
40 /*
41 * @see TestCase#tearDown()
42 */
43 protected void tearDown() throws Exception {
44 super.tearDown();
45 }
46
47 /**
48 * Constructor for AdvisorySupportTest.
49 * @param arg0
50 */
51 public AdvisorySupportTest(String arg0) {
52 super(arg0);
53 }
54
55 public void testMatchConsumer(){
56 String destName = "foo.bar";
57 ActiveMQTopic topic = new ActiveMQTopic(destName);
58 ConsumerInfo info = new ConsumerInfo();
59 info.setDestination(topic);
60
61 ActiveMQTopic advisoryDest = topic.getTopicForConsumerAdvisory();
62 ConsumerInfo advisory = new ConsumerInfo();
63 advisory.setDestination(advisoryDest);
64 AdvisorySupport test = new AdvisorySupport(null);
65 assertTrue(test.matchConsumer(advisory, info));
66 }
67
68 public void testMatchProducer(){
69 String destName = "foo.bar";
70 ActiveMQTopic topic = new ActiveMQTopic(destName);
71 ProducerInfo info = new ProducerInfo();
72 info.setDestination(topic);
73
74 ActiveMQTopic advisoryDest = topic.getTopicForProducerAdvisory();
75 ConsumerInfo advisory = new ConsumerInfo();
76 advisory.setDestination(advisoryDest);
77 AdvisorySupport test = new AdvisorySupport(null);
78 assertTrue(test.matchProducer(advisory, info));
79 }
80
81 public void testMatchConnection(){
82
83 ConnectionInfo info = new ConnectionInfo();
84
85
86 ActiveMQTopic advisoryDest = new ActiveMQTopic(ActiveMQDestination.CONNECTION_ADVISORY_PREFIX);
87 ConsumerInfo advisory = new ConsumerInfo();
88 advisory.setDestination(advisoryDest);
89 AdvisorySupport test = new AdvisorySupport(null);
90 assertTrue(test.matchConnection(advisory, info));
91 }
92 }