activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r647862 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java
Date Mon, 14 Apr 2008 15:51:09 GMT
Author: rajdavies
Date: Mon Apr 14 08:51:06 2008
New Revision: 647862

URL: http://svn.apache.org/viewvc?rev=647862&view=rev
Log:
Test case for https://issues.apache.org/activemq/browse/AMQ-1255

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java
  (with props)

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java?rev=647862&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java
Mon Apr 14 08:51:06 2008
@@ -0,0 +1,111 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.advisory;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+import org.apache.activemq.EmbeddedBrokerTestSupport;
+import org.apache.activemq.broker.region.RegionBroker;
+import org.apache.activemq.command.ActiveMQQueue;
+
+/**
+ * @version $Revision: 397249 $
+ */
+public class TempQueueMemoryTest extends EmbeddedBrokerTestSupport {
+    private Connection serverConnection;
+    private Session serverSession;
+    private Connection clientConnection;
+    private Session clientSession;
+    private Destination serverDestination;
+    private static final int COUNT = 1000;
+
+    public void testLoadRequestReply() throws Exception {
+        MessageConsumer serverConsumer = serverSession.createConsumer(serverDestination);
+        serverConsumer.setMessageListener(new MessageListener() {
+            public void onMessage(Message msg) {
+                try {
+                    Destination replyTo = msg.getJMSReplyTo();
+                    MessageProducer producer = serverSession.createProducer(replyTo);
+                    producer.send(replyTo, msg);
+                    producer.close();
+                } catch (Exception e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        });
+        
+        MessageProducer producer = clientSession.createProducer(serverDestination);
+        for (int i =0; i< COUNT; i++) {
+            TemporaryQueue replyTo = clientSession.createTemporaryQueue();
+            MessageConsumer consumer = clientSession.createConsumer(replyTo);
+            Message msg = clientSession.createMessage();
+            msg.setJMSReplyTo(replyTo);
+            producer.send(msg);
+            Message reply = consumer.receive();
+            consumer.close();
+            replyTo.delete();
+        }
+        
+        clientSession.close();
+        serverSession.close();
+        clientConnection.close();
+        serverConnection.close();
+        
+        AdvisoryBroker ab = (AdvisoryBroker) broker.getBroker().getAdaptor(
+                AdvisoryBroker.class);
+              
+        ///The server destination will be left
+        assertTrue(ab.getAdvisoryDestinations().size() == 1);
+        
+        assertTrue("should be zero but is "+ab.getAdvisoryConsumers().size(),ab.getAdvisoryConsumers().size()
== 0);
+        assertTrue("should be zero but is "+ab.getAdvisoryProducers().size(),ab.getAdvisoryProducers().size()
== 0);
+               
+        RegionBroker rb = (RegionBroker) broker.getBroker().getAdaptor(
+                RegionBroker.class);
+        
+               
+        //serverDestination + 
+        assertTrue(rb.getDestinationMap().size()==7);          
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        serverConnection = createConnection();
+        serverConnection.start();
+        serverSession = serverConnection.createSession(false, 0);
+        clientConnection = createConnection();
+        clientConnection.start();
+        clientSession = clientConnection.createSession(false, 0);
+        serverDestination = createDestination();
+    }
+
+    protected void tearDown() throws Exception {
+        
+        super.tearDown();
+    }
+    
+    protected Destination createDestination() {
+        return new ActiveMQQueue(getClass().getName());
+    }
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message