KickJava   Java API By Example, From Geeks To Geeks.

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


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 JmsQueueCompositeSendReceiveTest extends JmsTopicSendReceiveTest {
32     private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
33             .getLog(JmsQueueCompositeSendReceiveTest.class);
34     
35     /**
36      * Sets a test to have a queue destination and non-persistent delivery mode.
37      *
38      * @see junit.framework.TestCase#setUp()
39      */

40     protected void setUp() throws Exception JavaDoc {
41         topic = false;
42         deliveryMode = DeliveryMode.NON_PERSISTENT;
43         super.setUp();
44     }
45
46     /**
47      * Returns the consumer subject.
48      *
49      * @return String - consumer subject
50      * @see org.apache.activemq.test.TestSupport#getConsumerSubject()
51      */

52     protected String JavaDoc getConsumerSubject() {
53         return "FOO.BAR.HUMBUG";
54     }
55
56     /**
57      * Returns the producer subject.
58      *
59      * @return String - producer subject
60      * @see org.apache.activemq.test.TestSupport#getProducerSubject()
61      */

62     protected String JavaDoc getProducerSubject() {
63         return "FOO.BAR.HUMBUG,FOO.BAR.HUMBUG2";
64     }
65    
66     /**
67      * Test if all the messages sent are being received.
68      *
69      * @throws Exception
70      */

71     public void testSendReceive() throws Exception JavaDoc {
72         super.testSendReceive();
73         messages.clear();
74         Destination JavaDoc consumerDestination = consumeSession.createQueue("FOO.BAR.HUMBUG2");
75         log.info("Created consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass());
76         MessageConsumer JavaDoc consumer = null;
77         if (durable) {
78             log.info("Creating durable consumer");
79             consumer = consumeSession.createDurableSubscriber((Topic JavaDoc) consumerDestination, getName());
80         } else {
81             consumer = consumeSession.createConsumer(consumerDestination);
82         }
83         consumer.setMessageListener(this);
84
85         assertMessagesAreReceived();
86         log.info("" + data.length + " messages(s) received, closing down connections");
87     }
88 }
89
Popular Tags