[jboss-cvs] JBoss Messaging SVN: r3633 - in branches/Branch_JBossMessaging_1_4_0_SP3_CP: tests/src/org/jboss/test/messaging/jms/server and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jan 27 23:01:13 EST 2008
Author: miclark
Date: 2008-01-27 23:01:13 -0500 (Sun, 27 Jan 2008)
New Revision: 3633
Added:
branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/server/endpoint/
branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/server/endpoint/ServerConnectionEndpointTest.java
Modified:
branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
Log:
ServerConnectionEndpoint removes temporary destination references from the DestinationManager on close() [JBMESSAGING-1215].
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java 2008-01-26 15:06:30 UTC (rev 3632)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java 2008-01-28 04:01:13 UTC (rev 3633)
@@ -32,6 +32,7 @@
import javax.jms.Destination;
import javax.jms.IllegalStateException;
+import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
import javax.jms.Session;
@@ -44,9 +45,11 @@
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.server.ConnectionManager;
+import org.jboss.jms.server.DestinationManager;
import org.jboss.jms.server.JMSCondition;
import org.jboss.jms.server.SecurityStore;
import org.jboss.jms.server.ServerPeer;
+import org.jboss.jms.server.destination.ManagedDestination;
import org.jboss.jms.server.endpoint.advised.SessionAdvised;
import org.jboss.jms.tx.ClientTransaction;
import org.jboss.jms.tx.MessagingXid;
@@ -411,11 +414,24 @@
Collection queues = serverPeer.getPostOfficeInstance().getQueuesForCondition(new JMSCondition(false, dest.getName()), true);
if (!queues.isEmpty())
- {
- //This should never happen
- throw new IllegalStateException("Cannot delete temporary destination if it has consumer(s)");
- }
+ {
+ // This should never happen
+ throw new IllegalStateException("Cannot delete temporary destination if it has consumer(s)");
+ }
}
+
+ //
+ // Remove temporary destination from the DestinationManager (JBMESSAGING-1215)
+ //
+ DestinationManager dm = serverPeer.getDestinationManager();
+
+ ManagedDestination mDest = dm.getDestination(dest.getName(), dest.isQueue());
+ if (dm == null)
+ {
+ throw new InvalidDestinationException("No such destination: " + dest);
+ }
+
+ dm.unregisterDestination(mDest);
}
temporaryDestinations.clear();
Added: branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/server/endpoint/ServerConnectionEndpointTest.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/server/endpoint/ServerConnectionEndpointTest.java (rev 0)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/server/endpoint/ServerConnectionEndpointTest.java 2008-01-28 04:01:13 UTC (rev 3633)
@@ -0,0 +1,78 @@
+package org.jboss.test.messaging.jms.server.endpoint;
+
+import java.util.Set;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+
+import org.jboss.jms.server.DestinationManager;
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.jms.JMSTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+/**
+ * Tests a ServerConnectionEndpoint.
+ *
+ * @author <a href="mailto:miclark at redhat.com">Mike M. Clark</a>
+ * @version <tt>$Revision: $</tt>
+ *
+ * $Id: $
+ */
+public class ServerConnectionEndpointTest extends JMSTestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ protected Logger log = Logger.getLogger(getClass());
+
+ // Constructors --------------------------------------------------
+
+ public ServerConnectionEndpointTest(String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Verifies that a created TemporaryQueue is deleted when the associated
+ * connection is closed (JBMESSAGING-1215).
+ */
+ public void testDeleteTemporaryQueueOnClose() throws Exception
+ {
+ ConnectionFactory factory = (ConnectionFactory) ic.lookup("ConnectionFactory");
+ Connection connection = factory.createConnection();
+
+ Session responseSession = connection.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ TemporaryQueue tempQueue = responseSession.createTemporaryQueue();
+ log.info("Created TemporaryQueue: " + tempQueue);
+
+ DestinationManager dm = ServerManagement.getDestinationManager();
+ Set destinations = dm.getDestinations();
+ log.info("Destinations after temp queue creation: " + destinations);
+
+ assertTrue("Temporary destination is not registered in destination manager.", destinations.contains(tempQueue));
+
+ connection.close();
+
+ destinations = dm.getDestinations();
+ log.info("Destinations after connection.close(): " + destinations);
+ assertTrue("Temporary destination is registered in destination manager.", ! destinations.contains(tempQueue));
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
+
More information about the jboss-cvs-commits
mailing list