[jboss-cvs] JBoss Messaging SVN: r2330 - in trunk: src/main/org/jboss/jms/server and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 15 18:38:33 EST 2007


Author: timfox
Date: 2007-02-15 18:38:32 -0500 (Thu, 15 Feb 2007)
New Revision: 2330

Modified:
   trunk/src/etc/xmdesc/ServerPeer-xmbean.xml
   trunk/src/main/org/jboss/jms/server/ServerPeer.java
   trunk/src/main/org/jboss/jms/server/ServerPeerMBean.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
   trunk/src/main/org/jboss/jms/server/destination/TopicService.java
   trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java
   trunk/tests/build.xml
   trunk/tests/src/org/jboss/test/messaging/jms/server/destination/base/DestinationManagementTestBase.java
   trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-727


Modified: trunk/src/etc/xmdesc/ServerPeer-xmbean.xml
===================================================================
--- trunk/src/etc/xmdesc/ServerPeer-xmbean.xml	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/src/etc/xmdesc/ServerPeer-xmbean.xml	2007-02-15 23:38:32 UTC (rev 2330)
@@ -224,9 +224,9 @@
 
    <operation>
       <description>
-         Creates a queue with the specified name/JNDI name. The corresponding destination service will be instantiated, created and started.
+         Deploys a queue with the specified name/JNDI name. The corresponding destination service will be instantiated, created and started.
       </description>
-      <name>createQueue</name>
+      <name>deployQueue</name>
       <parameter>
          <name>name</name>
          <type>java.lang.String</type>
@@ -240,9 +240,9 @@
    
    <operation>
       <description>
-         Creates a queue with the specified name/JNDI name and paging parameters. The corresponding destination service will be instantiated, created and started.
+         Deploys a queue with the specified name/JNDI name and paging parameters. The corresponding destination service will be instantiated, created and started.
       </description>
-      <name>createQueue</name>
+      <name>deployQueue</name>
       <parameter>
          <name>name</name>
          <type>java.lang.String</type>
@@ -268,21 +268,33 @@
 
    <operation>
       <description>
-         Stops, destroys and unregisters from the MBean server the corresponding destination service, but only if the destination in question was created programatically with createQueue(). Returns true on success. Returns false if the destination does not exist or was not created programatically. A deployed destination must be undeployed to achieve the same effect.
+         Undeploys the queue, but does not delete its data from storage.
       </description>
+      <name>undeployQueue</name>
+      <parameter>
+         <name>name</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <return-type>boolean</return-type>
+   </operation>
+   
+   <operation>
+      <description>
+         Undeploys the queue, and deletes its data from storage
+      </description>
       <name>destroyQueue</name>
       <parameter>
          <name>name</name>
          <type>java.lang.String</type>
       </parameter>
-       <return-type>boolean</return-type>
-   </operation>
+      <return-type>boolean</return-type>
+   </operation>   
 
    <operation>
       <description>
-         Creates a topic with the specified name/JNDI name. The corresponding destination service will be instantiated, created and started.
+         Deploys a topic with the specified name/JNDI name. The corresponding destination service will be instantiated, created and started.
       </description>
-      <name>createTopic</name>
+      <name>deployTopic</name>
       <parameter>
          <name>name</name>
          <type>java.lang.String</type>
@@ -308,9 +320,9 @@
    
    <operation>
       <description>
-         Creates a topic with the specified name/JNDI name and paging parameters. The corresponding destination service will be instantiated, created and started.
+         Deploys a topic with the specified name/JNDI name and paging parameters. The corresponding destination service will be instantiated, created and started.
       </description>
-      <name>createTopic</name>
+      <name>deployTopic</name>
       <parameter>
          <name>name</name>
          <type>java.lang.String</type>
@@ -324,9 +336,9 @@
 
    <operation>
       <description>
-         Stops, destroys and unregisters from the MBean server the corresponding destination service, but only if the destination in question was created programatically with createTopic(). Returns true on success. Returns false if the destination does not exist or was not created programatically. A deployed destination must be undeployed to achieve the same effect.
+         Undeploys the topic, but does not delete all its data from storage
       </description>
-      <name>destroyTopic</name>
+      <name>undeployTopic</name>
       <parameter>
          <name>name</name>
          <type>java.lang.String</type>
@@ -336,6 +348,18 @@
    
    <operation>
       <description>
+      	Undeploys the topic and deletes all its data
+      </description>
+      <name>destroyTopic</name>
+      <parameter>
+         <name>name</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <return-type>boolean</return-type>
+   </operation>   
+   
+   <operation>
+      <description>
          List all message counters in HTML
       </description>
       <name>listMessageCountersAsHTML</name>

Modified: trunk/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeer.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/src/main/org/jboss/jms/server/ServerPeer.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -609,11 +609,11 @@
    
    // JMX Operations -------------------------------------------------------------------------------
 
-   public String createQueue(String name, String jndiName) throws Exception
+   public String deployQueue(String name, String jndiName) throws Exception
    {
       try
       {
-         return createDestinationDefault(true, name, jndiName);
+         return deployDestinationDefault(true, name, jndiName);
       }
       catch (Throwable t)
       {
@@ -621,11 +621,11 @@
       }
    }
 
-   public String createQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
+   public String deployQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
    {
       try
       {
-         return createDestination(true, name, jndiName, fullSize, pageSize, downCacheSize);
+         return deployDestination(true, name, jndiName, fullSize, pageSize, downCacheSize);
       }
       catch (Throwable t)
       {
@@ -637,19 +637,31 @@
    {
       try
       {
-         return destroyDestination(true, name);
+         return destroyDestination(true, name);        
       }
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMXInvocation(t, this + " destroyQueue");
       }
    }
+   
+   public boolean undeployQueue(String name) throws Exception
+   {
+      try
+      {
+         return undeployDestination(true, name);
+      }
+      catch (Throwable t)
+      {
+         throw ExceptionUtil.handleJMXInvocation(t, this + " destroyQueue");
+      }
+   }
 
-   public String createTopic(String name, String jndiName) throws Exception
+   public String deployTopic(String name, String jndiName) throws Exception
    {
       try
       {
-         return createDestinationDefault(false, name, jndiName);
+         return deployDestinationDefault(false, name, jndiName);
       }
       catch (Throwable t)
       {
@@ -657,11 +669,11 @@
       }
    }
 
-   public String createTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
+   public String deployTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
    {
       try
       {
-         return createDestination(false, name, jndiName, fullSize, pageSize, downCacheSize);
+         return deployDestination(false, name, jndiName, fullSize, pageSize, downCacheSize);
       }
       catch (Throwable t)
       {
@@ -680,6 +692,18 @@
          throw ExceptionUtil.handleJMXInvocation(t, this + " destroyTopic");
       }
    }
+   
+   public boolean undeployTopic(String name) throws Exception
+   {
+      try
+      {
+         return undeployDestination(false, name);
+      }
+      catch (Throwable t)
+      {
+         throw ExceptionUtil.handleJMXInvocation(t, this + " destroyTopic");
+      }
+   }
 
    public Set getDestinations() throws Exception
    {
@@ -1330,7 +1354,7 @@
       }
    }
 
-   private String createDestinationDefault(boolean isQueue, String name, String jndiName)
+   private String deployDestinationDefault(boolean isQueue, String name, String jndiName)
       throws Exception
    {
       //
@@ -1357,10 +1381,41 @@
          "    </constructor>" +
          "</mbean>";
 
-      return createDestinationInternal(destinationMBeanConfig, on, jndiName, false, -1, -1, -1);
+      return deployDestinationInternal(destinationMBeanConfig, on, jndiName, false, -1, -1, -1);
    }
+   
+   private String deployDestination(boolean isQueue, String name, String jndiName, int fullSize,
+            int pageSize, int downCacheSize) throws Exception
+   {
+      //    
+      //    TODO - THIS IS A TEMPORARY IMPLEMENTATION; WILL BE REPLACED WITH INTEGRATION-CONSISTENT ONE
+      //    TODO - if I find a way not using UnifiedClassLoader3 directly, then get rid of
+      //    <path refid="jboss.jmx.classpath"/> from jms/build.xml dependentmodule.classpath
+      //    
+      
+      String destType = isQueue ? "Queue" : "Topic";
+      String className = "org.jboss.jms.server.destination." + destType + "Service";
+      
+      String ons ="jboss.messaging.destination:service="+ destType + ",name=" + name;
+      ObjectName on = new ObjectName(ons);
+      
+      String destinationMBeanConfig =
+         "<mbean code=\"" + className + "\" " +
+         "       name=\"" + ons + "\" " +
+         "       xmbean-dd=\"xmdesc/" + destType + "-xmbean.xml\">\n" +
+         "    <constructor>" +
+         "        <arg type=\"boolean\" value=\"true\"/>" +
+         "    </constructor>" +
+         "    <attribute name=\"FullSize\">" + fullSize + "</attribute>" +
+         "    <attribute name=\"PageSize\">" + pageSize + "</attribute>" +
+         "    <attribute name=\"DownCacheSize\">" + downCacheSize + "</attribute>" +
+         "</mbean>";
+      
+      return deployDestinationInternal(destinationMBeanConfig, on, jndiName, true, fullSize,
+               pageSize, downCacheSize);
+   }
 
-   private String createDestinationInternal(String destinationMBeanConfig, ObjectName on,
+   private String deployDestinationInternal(String destinationMBeanConfig, ObjectName on,
                                             String jndiName, boolean params, int fullSize,
                                             int pageSize, int downCacheSize) throws Exception
    {
@@ -1398,37 +1453,39 @@
       //
    }
 
-   private String createDestination(boolean isQueue, String name, String jndiName, int fullSize,
-                                    int pageSize, int downCacheSize) throws Exception
+   
+
+   /*
+    * Undeploy the MBean but don't delete the underlying data
+    */
+   private boolean undeployDestination(boolean isQueue, String name) throws Exception
    {
-      //
-      // TODO - THIS IS A TEMPORARY IMPLEMENTATION; WILL BE REPLACED WITH INTEGRATION-CONSISTENT ONE
-      // TODO - if I find a way not using UnifiedClassLoader3 directly, then get rid of
-      //        <path refid="jboss.jmx.classpath"/> from jms/build.xml dependentmodule.classpath
-      //
-
       String destType = isQueue ? "Queue" : "Topic";
-      String className = "org.jboss.jms.server.destination." + destType + "Service";
-
-      String ons ="jboss.messaging.destination:service="+ destType + ",name=" + name;
+      String ons ="jboss.messaging.destination:service=" + destType + ",name=" + name;
       ObjectName on = new ObjectName(ons);
 
-      String destinationMBeanConfig =
-         "<mbean code=\"" + className + "\" " +
-         "       name=\"" + ons + "\" " +
-         "       xmbean-dd=\"xmdesc/" + destType + "-xmbean.xml\">\n" +
-         "    <constructor>" +
-         "        <arg type=\"boolean\" value=\"true\"/>" +
-         "    </constructor>" +
-         "    <attribute name=\"FullSize\">" + fullSize + "</attribute>" +
-         "    <attribute name=\"PageSize\">" + pageSize + "</attribute>" +
-         "    <attribute name=\"DownCacheSize\">" + downCacheSize + "</attribute>" +
-         "</mbean>";
+      MBeanServer mbeanServer = getServer();
 
-      return createDestinationInternal(destinationMBeanConfig, on, jndiName, true, fullSize,
-                                       pageSize, downCacheSize);
+      // we can only undeploy destinations that exist AND that have been created programatically
+      if (!mbeanServer.isRegistered(on))
+      {
+         return false;
+      }
+      Boolean b = (Boolean)mbeanServer.getAttribute(on, "CreatedProgrammatically");
+      if (!b.booleanValue())
+      {
+         log.warn("Cannot undeploy a destination that has not been created programatically");
+         return false;
+      }
+      mbeanServer.invoke(on, "stop", new Object[0], new String[0]);
+      mbeanServer.invoke(on, "destroy", new Object[0], new String[0]);
+      mbeanServer.unregisterMBean(on);
+      return true;
    }
-
+   
+   /*
+    * Undeploy the MBean and delete the underlying data
+    */
    private boolean destroyDestination(boolean isQueue, String name) throws Exception
    {
       String destType = isQueue ? "Queue" : "Topic";
@@ -1442,17 +1499,85 @@
       {
          return false;
       }
-      Boolean b = (Boolean)mbeanServer.getAttribute(on, "CreatedProgrammatically");
-      if (!b.booleanValue())
+                  
+      //First deactivate
+      
+      if (isQueue)
       {
-         log.warn("Cannot destroy a destination that has not been created programatically");
+         Binding binding = postOffice.getBindingForQueueName(name);
+         
+         if (binding != null)
+         {
+            binding.getQueue().deactivate();
+         }
+      }
+      else
+      {
+         JMSCondition topicCond = new JMSCondition(false, name);    
+         
+         Collection bindings = postOffice.getBindingsForCondition(topicCond);
+         
+         Iterator iter = bindings.iterator();
+         while (iter.hasNext())            
+         {
+            Binding binding = (Binding)iter.next();
+            
+            binding.getQueue().deactivate();
+         }
+      }
+            
+      //Delete any message data
+      
+      mbeanServer.invoke(on, "removeAllMessages", null, null);
+      
+      //undeploy the mbean
+      if (!undeployDestination(isQueue, name))
+      {
          return false;
       }
-      mbeanServer.invoke(on, "stop", new Object[0], new String[0]);
-      mbeanServer.invoke(on, "destroy", new Object[0], new String[0]);
-      mbeanServer.unregisterMBean(on);
+            
+      //Unbind from the post office
+      
+      if (isQueue)
+      {
+         Binding binding = postOffice.getBindingForQueueName(name);
+         
+         if (binding != null)
+         {
+            try
+            {
+               postOffice.unbindQueue(binding.getQueue().getName());
+            }
+            catch (Throwable t)
+            {
+               throw new Exception("Failed to unbind queue", t);
+            }
+         }
+      }
+      else
+      {
+         JMSCondition topicCond = new JMSCondition(false, name);    
+         
+         Collection bindings = postOffice.getBindingsForCondition(topicCond);
+         
+         Iterator iter = bindings.iterator();
+         while (iter.hasNext())            
+         {
+            Binding binding = (Binding)iter.next();
+            
+            try
+            {
+               postOffice.unbindQueue(binding.getQueue().getName());
+            }
+            catch (Throwable t)
+            {
+               throw new Exception("Failed to unbind queue", t);
+            }
+         }
+      }
       return true;
    }
+   
 
    // Inner classes --------------------------------------------------------------------------------
    

Modified: trunk/src/main/org/jboss/jms/server/ServerPeerMBean.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeerMBean.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/src/main/org/jboss/jms/server/ServerPeerMBean.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -126,19 +126,23 @@
    
    // JMX operations
    
-   String createQueue(String name, String jndiName) throws Exception;
+   String deployQueue(String name, String jndiName) throws Exception;
 
-   String createQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize)
+   String deployQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize)
       throws Exception;
 
    boolean destroyQueue(String name) throws Exception;
+   
+   boolean undeployQueue(String name) throws Exception;
 
-   String createTopic(String name, String jndiName) throws Exception;
+   String deployTopic(String name, String jndiName) throws Exception;
 
-   String createTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize)
+   String deployTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize)
       throws Exception;
 
    boolean destroyTopic(String name) throws Exception;
+   
+   boolean undeployTopic(String name) throws Exception;
 
    String listMessageCountersAsHTML() throws Exception;
    

Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -255,7 +255,7 @@
 
       }
 
-      Dispatcher.instance.unregisterTarget(endpoint.getID(), delegate);
+      Dispatcher.instance.unregisterTarget(endpoint.getID(), endpoint);
    }
 
    // MessagingComponent implementation ------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/server/destination/TopicService.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/destination/TopicService.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/src/main/org/jboss/jms/server/destination/TopicService.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -152,6 +152,9 @@
             if (!queue.isRecoverable())
             {
                queue.removeAllReferences();
+               
+               // Unbind
+               postOffice.unbindQueue(queue.getName());
             }
                         
             queue.deactivate();
@@ -160,7 +163,7 @@
             //unregister counter
             String counterName = SUBSCRIPTION_MESSAGECOUNTER_PREFIX + queue.getName();
             
-            serverPeer.getMessageCounterManager().unregisterMessageCounter(counterName);
+            serverPeer.getMessageCounterManager().unregisterMessageCounter(counterName);                        
          }
           
          started = false;

Modified: trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -60,12 +60,12 @@
       return targets.get(id);
    }
    
-   public void registerTarget(Integer id, Object obj)
+   public void registerTarget(Integer id, AdvisedSupport obj)
    {
       targets.put(id, obj);
    }
    
-   public void registerTarget(int id, Object obj)
+   public void registerTarget(int id, AdvisedSupport obj)
    {
       registerTarget(new Integer(id), obj);
    }
@@ -80,7 +80,7 @@
       // object. Remoting then times out the old connection and dereigsters the new object which is
       // registered under the same id.
       // See http://jira.jboss.com/jira/browse/JBMESSAGING-812
-      
+          
       AdvisedSupport advised = (AdvisedSupport)(targets.get(id));
       
       if (advised == null)

Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/tests/build.xml	2007-02-15 23:38:32 UTC (rev 2330)
@@ -635,6 +635,9 @@
 
             <fileset dir="${build.tests.classes}">
                <include name="**/jms/**/*Test.class"/>
+
+               <exclude name="**/jms/bridge/**/*Test.class"/>
+
                <include name="**/thirdparty/**/*Test.class"/>
                <exclude name="**/messaging/graveyard/**/*Test.class"/>
                <exclude name="**/jms/WireFormatTest.class"/>

Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/destination/base/DestinationManagementTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/destination/base/DestinationManagementTestBase.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/destination/base/DestinationManagementTestBase.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -27,8 +27,12 @@
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
+import javax.jms.TextMessage;
 import javax.jms.Topic;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
@@ -302,8 +306,8 @@
       ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
 
       String destinationType = isQueue() ? "Queue" : "Topic";
-      String createMethod = "create" + destinationType;
-      String destroyMethod = "destroy" + destinationType;
+      String deployMethod = "deploy" + destinationType;
+      String undeployMethod = "undeploy" + destinationType;
       String destinationName = "BlahBlah";
       String expectedJNDIName = (isQueue() ? "/queue/" : "/topic/") + destinationName;
       ObjectName destObjectName = new ObjectName("jboss.messaging.destination:service=" +
@@ -312,7 +316,7 @@
       // deploy it
 
       String jndiName = (String)ServerManagement.
-         invoke(serverPeerObjectName, createMethod,
+         invoke(serverPeerObjectName, deployMethod,
                 new Object[] { destinationName, null },
                 new String[] { "java.lang.String", "java.lang.String" });
 
@@ -337,7 +341,7 @@
 
       // undeploy it
 
-      Boolean b = (Boolean)ServerManagement.invoke(serverPeerObjectName, destroyMethod,
+      Boolean b = (Boolean)ServerManagement.invoke(serverPeerObjectName, undeployMethod,
                                                    new Object[] { destinationName },
                                                    new String[] { "java.lang.String" });
 
@@ -370,8 +374,8 @@
       ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
 
       String destinationType = isQueue() ? "Queue" : "Topic";
-      String createMethod = "create" + destinationType;
-      String destroyMethod = "destroy" + destinationType;
+      String deployMethod = "deploy" + destinationType;
+      String undeployMethod = "undeploy" + destinationType;
       String destinationName = "BlahBlah";
       String expectedJNDIName = (isQueue() ? "/queue/" : "/topic/") + destinationName;
       ObjectName destObjectName = new ObjectName("jboss.messaging.destination:service=" +
@@ -386,7 +390,7 @@
       // deploy it
 
       String jndiName = (String)ServerManagement.
-         invoke(serverPeerObjectName, createMethod,
+         invoke(serverPeerObjectName, deployMethod,
                 new Object[] { destinationName, null, new Integer(fullSize), new Integer(pageSize), new Integer(downCacheSize)},
                 new String[] { "java.lang.String", "java.lang.String", "int", "int", "int"});
 
@@ -416,6 +420,108 @@
 
       // undeploy it
 
+      Boolean b = (Boolean)ServerManagement.invoke(serverPeerObjectName, undeployMethod,
+                                                   new Object[] { destinationName },
+                                                   new String[] { "java.lang.String" });
+
+      assertTrue(b.booleanValue());
+
+      try
+      {
+         ic.lookup(expectedJNDIName);
+         fail("should throw exception");
+      }
+      catch(NamingException e)
+      {
+         // OK
+      }
+
+      Set set = ServerManagement.query(destObjectName);
+      assertTrue(set.isEmpty());
+ 
+      set = (Set)ServerManagement.getAttribute(serverPeerObjectName, "Destinations");
+
+
+      assertTrue(set.isEmpty());
+
+      ic.close();
+
+   }
+   
+   public void testDestroyDestinationProgrammatically() throws Exception
+   {
+      ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
+
+      String destinationType = isQueue() ? "Queue" : "Topic";
+      String deployMethod = "deploy" + destinationType;
+      String destroyMethod = "destroy" + destinationType;
+      String destinationName = "BlahBlah";
+      String expectedJNDIName = (isQueue() ? "/queue/" : "/topic/") + destinationName;
+      ObjectName destObjectName = new ObjectName("jboss.messaging.destination:service=" +
+                                                 destinationType +",name=" + destinationName);
+
+      // deploy it
+
+      String jndiName = (String)ServerManagement.
+         invoke(serverPeerObjectName, deployMethod,
+                new Object[] { destinationName, null },
+                new String[] { "java.lang.String", "java.lang.String" });
+
+      assertEquals(expectedJNDIName, jndiName);
+
+      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+
+      if (isQueue())
+      {
+         Queue q = (Queue)ic.lookup(jndiName);
+         assertEquals(destinationName, q.getQueueName());
+      }
+      else
+      {
+         Topic t = (Topic)ic.lookup(jndiName);
+         assertEquals(destinationName, t.getTopicName());
+      }
+
+      assertEquals(destinationName, ServerManagement.getAttribute(destObjectName, "Name"));
+      assertEquals(expectedJNDIName,
+                   (String)ServerManagement.getAttribute(destObjectName, "JNDIName"));
+      
+      ConnectionFactory cf = (ConnectionFactory)this.initialContext.lookup("/ConnectionFactory");
+      
+      Connection conn = cf.createConnection();
+      
+      conn.setClientID("wibble456");
+      
+      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      
+      conn.start();
+      
+      Destination dest;
+      
+      if (!isQueue())
+      {
+         dest = (Destination)ic.lookup("/topic/" + destinationName);
+         
+         //Create a durable sub
+         sess.createDurableSubscriber((Topic)dest, "sub1");
+      }
+      else
+      {
+         dest = (Destination)ic.lookup("/queue/" + destinationName);
+      }
+      
+      //Send a message
+      
+      TextMessage tm = sess.createTextMessage("uuuuuuuuurrrrrrrrgggggggggghhhhh");
+      
+      MessageProducer prod = sess.createProducer(dest);
+      
+      prod.send(tm);
+      
+      conn.close();
+            
+      // destroy it
+
       Boolean b = (Boolean)ServerManagement.invoke(serverPeerObjectName, destroyMethod,
                                                    new Object[] { destinationName },
                                                    new String[] { "java.lang.String" });
@@ -431,6 +537,9 @@
       {
          // OK
       }
+      
+      //Make sure no bindings exist
+      //ServerManagement.gets
 
       Set set = ServerManagement.query(destObjectName);
       assertTrue(set.isEmpty());
@@ -439,6 +548,38 @@
 
 
       assertTrue(set.isEmpty());
+      
+      // Deploy it again
+      jndiName = (String)ServerManagement.
+      invoke(serverPeerObjectName, deployMethod,
+             new Object[] { destinationName, null },
+             new String[] { "java.lang.String", "java.lang.String" });
+      
+      conn = cf.createConnection();
+      
+      conn.setClientID("wibble456");
+      
+      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      
+      conn.start();
+      
+      MessageConsumer cons;
+      
+      if (isQueue())
+      {
+         cons = sess.createConsumer((Queue)dest);
+      }
+      else
+      {
+         cons = sess.createDurableSubscriber((Topic)dest, "sub1");
+      }
+      
+      Message m = cons.receive(2000);
+      
+      assertNull(m);
+      
+      conn.close();
+      
 
       ic.close();
 

Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -884,7 +884,7 @@
    public static void createTopic(String name, String jndiName) throws Exception
    {
       insureStarted();
-      servers[0].getServer().createTopic(name, jndiName);
+      servers[0].getServer().deployTopicProgrammatically(name, jndiName);
    }
 
    /**
@@ -892,7 +892,7 @@
     */
    public static boolean destroyTopic(String name) throws Exception
    {
-      return servers[0].getServer().destroyDestination(false, name);
+      return servers[0].getServer().undeployDestinationProgrammatically(false, name);
    }
 
    /**
@@ -962,7 +962,7 @@
    public static void createQueue(String name, String jndiName) throws Exception
    {
       insureStarted();
-      servers[0].getServer().createQueue(name, jndiName);
+      servers[0].getServer().deployQueueProgrammatically(name, jndiName);
    }
 
    /**
@@ -970,7 +970,7 @@
     */
    public static boolean destroyQueue(String name) throws Exception
    {
-      return servers[0].getServer().destroyDestination(true, name);
+      return servers[0].getServer().undeployDestinationProgrammatically(true, name);
    }
 
    /**

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -605,9 +605,9 @@
       deployDestination(false, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
    }
 
-   public void createTopic(String name, String jndiName) throws Exception
+   public void deployTopicProgrammatically(String name, String jndiName) throws Exception
    {
-      sc.invoke(serverPeerObjectName, "createTopic",
+      sc.invoke(serverPeerObjectName, "deployTopic",
                 new Object[] { name, jndiName },
                 new String[] { "java.lang.String", "java.lang.String"} );
    }
@@ -623,9 +623,9 @@
       deployDestination(true, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
    }
 
-   public void createQueue(String name, String jndiName) throws Exception
+   public void deployQueueProgrammatically(String name, String jndiName) throws Exception
    {
-      sc.invoke(serverPeerObjectName, "createQueue",
+      sc.invoke(serverPeerObjectName, "deployQueue",
                 new Object[] { name, jndiName },
                 new String[] { "java.lang.String", "java.lang.String"} );
    }
@@ -698,17 +698,17 @@
       sc.unregisterService(destinationObjectName);
    }
 
-   public boolean destroyDestination(boolean isQueue, String name) throws Exception
+   public boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception
    {
       if (isQueue)
       {
-         return  ((Boolean)sc.invoke(serverPeerObjectName, "destroyQueue",
+         return  ((Boolean)sc.invoke(serverPeerObjectName, "undeployQueue",
                                     new Object[] { name },
                                     new String[] { "java.lang.String"})).booleanValue();
       }
       else
       {
-         return  ((Boolean)sc.invoke(serverPeerObjectName, "destroyTopic",
+         return  ((Boolean)sc.invoke(serverPeerObjectName, "undeployTopic",
                                     new Object[] { name },
                                     new String[] { "java.lang.String"})).booleanValue();
       }

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -346,9 +346,9 @@
       server.deployTopic(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
    }
 
-   public void createTopic(String name, String jndiName) throws Exception
+   public void deployTopicProgrammatically(String name, String jndiName) throws Exception
    {
-      server.createTopic(name, jndiName);
+      server.deployTopicProgrammatically(name, jndiName);
    }
 
    public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
@@ -366,9 +366,9 @@
       server.deployQueue(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
    }
 
-   public void createQueue(String name, String jndiName) throws Exception
+   public void deployQueueProgrammatically(String name, String jndiName) throws Exception
    {
-      server.createQueue(name, jndiName);
+      server.deployQueueProgrammatically(name, jndiName);
    }
 
    public void undeployDestination(boolean isQueue, String name) throws Exception
@@ -376,9 +376,9 @@
       server.undeployDestination(isQueue, name);
    }
 
-   public boolean destroyDestination(boolean isQueue, String name) throws Exception
+   public boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception
    {
-      return server.destroyDestination(isQueue, name);
+      return server.undeployDestinationProgrammatically(isQueue, name);
    }
 
    public void deployConnectionFactory(String objectName, String[] jndiBindings)

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java	2007-02-15 22:15:30 UTC (rev 2329)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java	2007-02-15 23:38:32 UTC (rev 2330)
@@ -186,7 +186,7 @@
    /**
     * Creates a topic programatically.
     */
-   void createTopic(String name, String jndiName) throws Exception;
+   void deployTopicProgrammatically(String name, String jndiName) throws Exception;
 
    /**
     * Simulates a queue deployment (copying the queue descriptor in the deploy directory).
@@ -202,7 +202,7 @@
    /**
     * Creates a queue programatically.
     */
-   void createQueue(String name, String jndiName) throws Exception;
+   void deployQueueProgrammatically(String name, String jndiName) throws Exception;
 
    /**
     * Simulates a destination un-deployment (deleting the destination descriptor from the deploy
@@ -213,7 +213,7 @@
    /**
     * Destroys a programatically created destination.
     */
-   boolean destroyDestination(boolean isQueue, String name) throws Exception;
+   boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception;
 
    void deployConnectionFactory(String objectName,
                                 String[] jndiBindings,




More information about the jboss-cvs-commits mailing list