activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r546476 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/ main/java/org/apache/activemq/command/ test/java/org/apache/activemq/ test/java/org/apache/activemq/test/ test/java/org/apache/activemq/usecases/
Date Tue, 12 Jun 2007 13:24:36 GMT
Author: jstrachan
Date: Tue Jun 12 06:24:33 2007
New Revision: 546476

URL: http://svn.apache.org/viewvc?view=rev&rev=546476
Log:
added test case and fix for AMQ-1142

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.java
  (with props)
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.java
  (with props)
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java?view=diff&rev=546476&r1=546475&r2=546476
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java Tue
Jun 12 06:24:33 2007
@@ -57,27 +57,7 @@
 
 import org.apache.activemq.blob.BlobTransferPolicy;
 import org.apache.activemq.blob.BlobUploader;
-import org.apache.activemq.command.ActiveMQBlobMessage;
-import org.apache.activemq.command.ActiveMQBytesMessage;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQMapMessage;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQObjectMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQStreamMessage;
-import org.apache.activemq.command.ActiveMQTempDestination;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.command.Command;
-import org.apache.activemq.command.ConsumerId;
-import org.apache.activemq.command.MessageAck;
-import org.apache.activemq.command.MessageDispatch;
-import org.apache.activemq.command.MessageId;
-import org.apache.activemq.command.ProducerId;
-import org.apache.activemq.command.Response;
-import org.apache.activemq.command.SessionId;
-import org.apache.activemq.command.SessionInfo;
-import org.apache.activemq.command.TransactionId;
+import org.apache.activemq.command.*;
 import org.apache.activemq.management.JMSSessionStatsImpl;
 import org.apache.activemq.management.StatsCapable;
 import org.apache.activemq.management.StatsImpl;
@@ -1030,6 +1010,9 @@
      */
     public Queue createQueue(String queueName) throws JMSException {
         checkClosed();
+        if (queueName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
+            return new ActiveMQTempQueue(queueName);
+        }
         return new ActiveMQQueue(queueName);
     }
 
@@ -1057,6 +1040,9 @@
      */
     public Topic createTopic(String topicName) throws JMSException {
         checkClosed();
+        if (topicName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
+            return new ActiveMQTempTopic(topicName);
+        }
         return new ActiveMQTopic(topicName);
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java?view=diff&rev=546476&r1=546475&r2=546476
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQDestination.java
Tue Jun 12 06:24:33 2007
@@ -59,7 +59,9 @@
     public static final String TOPIC_QUALIFIED_PREFIX = "topic://"; 
     public static final String TEMP_QUEUE_QUALIFED_PREFIX= "temp-queue://"; 
     public static final String TEMP_TOPIC_QUALIFED_PREFIX = "temp-topic://";
-            
+
+    public static final String TEMP_DESTINATION_NAME_PREFIX = "ID:";
+
     protected String physicalName;
     
     transient protected ActiveMQDestination[] compositeDestinations;

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.java?view=auto&rev=546476
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/EmbeddedBrokerAndConnectionTestSupport.java
Tue Jun 12 06:24:33 2007
@@ -0,0 +1,45 @@
+/**
+ *
+ * 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;
+
+import javax.jms.Connection;
+
+/**
+ * A base class for a test case which creates an embedded broker and uses a connection and
session
+ *
+ * @version $Revision: 1.1 $
+ */
+public abstract class EmbeddedBrokerAndConnectionTestSupport extends EmbeddedBrokerTestSupport
{
+    protected Connection connection;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        connection = createConnection();
+        connection.start();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (connection != null) {
+            connection.close();
+        }
+        super.tearDown();
+    }
+}

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

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.java?view=auto&rev=546476
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/TemporaryDestinationToFromNameTest.java
Tue Jun 12 06:24:33 2007
@@ -0,0 +1,53 @@
+/**
+ *
+ * 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.test;
+
+import org.apache.activemq.EmbeddedBrokerAndConnectionTestSupport;
+
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class TemporaryDestinationToFromNameTest extends EmbeddedBrokerAndConnectionTestSupport
{
+    public void testCreateTemporaryQueueThenCreateAQueueFromItsName() throws Exception {
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        Queue tempQueue = session.createTemporaryQueue();
+        String name = tempQueue.getQueueName();
+        log.info("Created queue named: " + name);
+
+        Queue createdQueue = session.createQueue(name);
+
+        assertEquals("created queue not equal to temporary queue", tempQueue, createdQueue);
+    }
+
+    public void testCreateTemporaryTopicThenCreateATopicFromItsName() throws Exception {
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        Topic tempTopic = session.createTemporaryTopic();
+        String name = tempTopic.getTopicName();
+        log.info("Created topic named: " + name);
+
+        Topic createdTopic = session.createTopic(name);
+
+        assertEquals("created topic not equal to temporary topic", tempTopic, createdTopic);
+    }
+}

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

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java?view=diff&rev=546476&r1=546475&r2=546476
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/CreateLotsOfTemporaryQueuesTest.java
Tue Jun 12 06:24:33 2007
@@ -18,6 +18,7 @@
 package org.apache.activemq.usecases;
 
 import org.apache.activemq.EmbeddedBrokerTestSupport;
+import org.apache.activemq.EmbeddedBrokerAndConnectionTestSupport;
 
 import javax.jms.Connection;
 import javax.jms.Session;
@@ -31,7 +32,7 @@
  * 
  * @version $Revision: 1.1 $
  */
-public class CreateLotsOfTemporaryQueuesTest extends EmbeddedBrokerTestSupport {
+public class CreateLotsOfTemporaryQueuesTest extends EmbeddedBrokerAndConnectionTestSupport
{
 
     private static int numberToCreate = 500;
     private static long sleep = 20;
@@ -49,8 +50,6 @@
     public void testCreateLotsOfTemporaryQueues() throws Exception {
         log.info("Creating " + numberToCreate + " temporary queue(s)");
 
-        Connection connection = createConnection();
-        connection.start();
         Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
         for (int i = 0; i < numberToCreate; i++) {
             if (i % 1000 == 0) {
@@ -61,7 +60,6 @@
             Thread.sleep(sleep );
         }
         log.info("Created " + numberToCreate + " temporary queue(s)");
-        connection.close();
     }
 
     public static void configure(String[] args) {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java?view=diff&rev=546476&r1=546475&r2=546476
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java
Tue Jun 12 06:24:33 2007
@@ -17,6 +17,7 @@
 package org.apache.activemq.usecases;
 
 import org.apache.activemq.EmbeddedBrokerTestSupport;
+import org.apache.activemq.EmbeddedBrokerAndConnectionTestSupport;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 
@@ -30,13 +31,11 @@
  * 
  * @version $Revision: $
  */
-public class NewConsumerCreatesDestinationTest extends EmbeddedBrokerTestSupport {
+public class NewConsumerCreatesDestinationTest extends EmbeddedBrokerAndConnectionTestSupport
{
 
-    private Connection connection;
     private ActiveMQQueue wildcard;
     
     public void testNewConsumerCausesNewDestinationToBeAutoCreated() throws Exception {
-        connection = createConnection();
 
         // lets create a wildcard thats kinda like those used by Virtual Topics
         String wildcardText = "org.*" + getDestinationString().substring("org.apache".length());
@@ -53,13 +52,6 @@
 
         assertDestinationCreated(destination, true);
         assertDestinationCreated(wildcard, true);
-    }
-
-    protected void tearDown() throws Exception {
-        if (connection != null) {
-            connection.close();
-        }
-        super.tearDown();
     }
 
     protected void assertDestinationCreated(Destination destination, boolean expected) throws
Exception {



Mime
View raw message