KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > JmsTopicCompositeSendReceiveTest


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;
19
20 import org.apache.activemq.test.JmsTopicSendReceiveTest;
21
22 import javax.jms.DeliveryMode JavaDoc;
23 import javax.jms.Destination JavaDoc;
24 import javax.jms.MessageConsumer JavaDoc;
25 import javax.jms.Topic JavaDoc;
26
27
28 /**
29  * @version $Revision: 1.3 $
30  */

31 public class JmsTopicCompositeSendReceiveTest extends JmsTopicSendReceiveTest {
32     private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
33             .getLog(JmsTopicCompositeSendReceiveTest.class);
34     
35     Destination JavaDoc consumerDestination2;
36     MessageConsumer JavaDoc consumer2;
37
38     /**
39      * Sets a test to have a queue destination and non-persistent delivery mode.
40      *
41      * @see junit.framework.TestCase#setUp()
42      */

43     protected void setUp() throws Exception JavaDoc {
44         deliveryMode = DeliveryMode.NON_PERSISTENT;
45         super.setUp();
46         consumerDestination2 = consumeSession.createTopic("FOO.BAR.HUMBUG2");
47         log.info("Created consumer destination: " + consumerDestination2 + " of type: " + consumerDestination2.getClass());
48         if (durable) {
49             log.info("Creating durable consumer");
50             consumer2 = consumeSession.createDurableSubscriber((Topic JavaDoc) consumerDestination2, getName());
51         } else {
52             consumer2 = consumeSession.createConsumer(consumerDestination2);
53         }
54
55     }
56
57     /**
58      * Returns the consumer subject.
59      *
60      * @return String - consumer subject
61      * @see org.apache.activemq.test.TestSupport#getConsumerSubject()
62      */

63     protected String JavaDoc getConsumerSubject() {
64         return "FOO.BAR.HUMBUG";
65     }
66
67     /**
68      * Returns the producer subject.
69      *
70      * @return String - producer subject
71      * @see org.apache.activemq.test.TestSupport#getProducerSubject()
72      */

73     protected String JavaDoc getProducerSubject() {
74         return "FOO.BAR.HUMBUG,FOO.BAR.HUMBUG2";
75     }
76
77     /**
78      * Test if all the messages sent are being received.
79      *
80      * @throws Exception
81      */

82     public void testSendReceive() throws Exception JavaDoc {
83         super.testSendReceive();
84         messages.clear();
85         consumer2.setMessageListener(this);
86         assertMessagesAreReceived();
87         log.info("" + data.length + " messages(s) received, closing down connections");
88     }
89 }
90
Popular Tags