Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/objectweb/jtests/jms/conform/queue/TemporaryQueueTest.java


1   /*
2    * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3    * Copyright (C) 2002 INRIA
4    * Contact: joram-team@objectweb.org
5    * 
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2.1 of the License, or any later version.
10   * 
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   * USA
20   * 
21   * Initial developer(s): Jeff Mesnil (jmesnil@inrialpes.fr)
22   * Contributor(s): ______________________________________.
23   */
24  
25  package org.objectweb.jtests.jms.conform.queue;
26  
27  import org.objectweb.jtests.jms.framework.*;
28  import junit.framework.*;
29  
30  import javax.jms.*;
31  
32  
33  /**
34   * Test the <code>javax.jms.TemporaryQueue</code> features.
35   *
36   * @author Jeff Mesnil (jmesnil@inrialpes.fr)
37   * @version $Id: TemporaryQueueTest.java,v 1.1 2002/04/21 21:15:19 chirino Exp $
38   */
39  public class TemporaryQueueTest extends PTPTestCase {
40  
41    private TemporaryQueue tempQueue;
42    private QueueReceiver tempReceiver;
43  
44    /**
45     * Test a TemporaryQueue
46     */
47    public void testTemporaryQueue() {
48      try {
49        // we stop both sender and receiver connections
50        senderConnection.stop();
51        receiverConnection.stop();
52        // we create a temporary queue to receive messages
53        tempQueue = receiverSession.createTemporaryQueue();
54        // we recreate the sender because it has been 
55        // already created with a Destination as parameter
56        sender = senderSession.createSender(null);
57        // we create a receiver on the temporary queue
58        tempReceiver = receiverSession.createReceiver(tempQueue);
59        receiverConnection.start();
60        senderConnection.start();
61  
62        TextMessage message = senderSession.createTextMessage();
63        message.setText("testTemporaryQueue");
64        sender.send(tempQueue, message);
65  
66        Message m = tempReceiver.receive();
67        assertTrue(m instanceof TextMessage);
68        TextMessage msg = (TextMessage)m;
69        assertEquals("testTemporaryQueue", msg.getText());
70      } catch (JMSException e) {
71        fail(e);
72      }
73    }
74  
75    /** 
76     * Method to use this class in a Test suite
77     */
78    public static Test suite() {
79      return new TestSuite(TemporaryQueueTest.class);
80    }
81    
82    public TemporaryQueueTest(String name) {
83      super(name);
84    }
85  }