[jboss-cvs] JBossAS SVN: r57779 - in trunk/testsuite: . imports/sections src/main/org/jboss/test/jbossmessaging src/main/org/jboss/test/jbossmessaging/test src/resources/jbossmessaging

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 23 17:03:37 EDT 2006


Author: rachmatowicz at jboss.com
Date: 2006-10-23 17:03:35 -0400 (Mon, 23 Oct 2006)
New Revision: 57779

Added:
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/JBossMessagingAdmin.java
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/JMSTestCase.java
   trunk/testsuite/src/resources/jbossmessaging/provider.properties
Modified:
   trunk/testsuite/build.xml
   trunk/testsuite/imports/sections/jbossmessaging.xml
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/test/ConcurrentDeliveryUnitTestCase.java
Log:
Add base classes for generic JMS tests

Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml	2006-10-23 19:28:54 UTC (rev 57778)
+++ trunk/testsuite/build.xml	2006-10-23 21:03:35 UTC (rev 57779)
@@ -3247,6 +3247,7 @@
         <pathelement location="${build.resources}"/>
         <!-- need to prefix classpath to pick up correct versions of scoped client libs -->
         <pathelement location="${jboss.messaging.lib}/jboss-messaging-client.jar"/>
+        <pathelement location="${build.lib}/jbossmessagingtest.jar"/>
         <path refid="tests.classpath"/>
       </classpath>
 

Modified: trunk/testsuite/imports/sections/jbossmessaging.xml
===================================================================
--- trunk/testsuite/imports/sections/jbossmessaging.xml	2006-10-23 19:28:54 UTC (rev 57778)
+++ trunk/testsuite/imports/sections/jbossmessaging.xml	2006-10-23 21:03:35 UTC (rev 57779)
@@ -8,6 +8,9 @@
          <fileset dir="${build.classes}">
             <include name="org/jboss/test/jbossmessaging/**"/>
          </fileset>
+         <fileset dir="${build.resources}/jbossmessaging">
+            <include name="provider.properties"/>
+         </fileset>
       </jar>
       
       <!-- copy any required configuration files

Added: trunk/testsuite/src/main/org/jboss/test/jbossmessaging/JBossMessagingAdmin.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmessaging/JBossMessagingAdmin.java	2006-10-23 19:28:54 UTC (rev 57778)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmessaging/JBossMessagingAdmin.java	2006-10-23 21:03:35 UTC (rev 57779)
@@ -0,0 +1,215 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jbossmessaging;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.NestedRuntimeException;
+
+import org.objectweb.jtests.jms.admin.Admin;
+
+/**
+ * JBossMessagingAdmin.
+ * 
+ * @author <a href="richard.achmatowicz at jboss.com">Richard Achmatowicz</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 38213 $
+ */
+public class JBossMessagingAdmin implements Admin
+{
+   private Logger log = Logger.getLogger(JBossMessagingAdmin.class);
+
+   private InitialContext initialContext ;
+   private MBeanServerConnection server ;
+
+   protected static final String name ;
+   protected static final ObjectName serverPeer;
+   protected static final ObjectName namingService;
+   
+   static
+   {
+      try
+      {
+	 name =  JBossMessagingAdmin.class.getName() ;
+         serverPeer = new ObjectName("jboss.messaging:service=ServerPeer");
+         namingService = new ObjectName("jboss:service=Naming");
+      }
+      catch (Exception e)
+      {
+         throw new NestedRuntimeException(e);
+      }
+   }
+   
+   public JBossMessagingAdmin() throws Exception
+   {
+      try {
+	  log.info("Initializing...") ;
+
+          // set up the initial naming service context
+          initialContext = new InitialContext() ;
+
+          // set up the MBean server connection
+          String adaptorName = System.getProperty("jbosstest.server.name","jmx/invoker/RMIAdaptor") ;
+          server = (MBeanServerConnection) initialContext.lookup(adaptorName) ;
+	   
+      } catch (Exception e) {
+          e.printStackTrace() ;
+      }
+   }
+
+   public String getName() {
+      return name ;
+   }
+
+   private MBeanServerConnection getServer() {
+       return server ;
+   }
+
+   public InitialContext createInitialContext() throws NamingException {
+      return initialContext ;
+   }
+
+   public void createQueue(String name)
+   {
+      try
+      {
+         MBeanServerConnection server = getServer();
+         try
+         {
+            server.invoke(serverPeer, "createQueue", new Object[] { name, name },  new String[] { String.class.getName(), String.class.getName() } );
+         }
+         catch (Exception ignored)
+         {
+            log.trace("Ignored", ignored);
+         }
+         ObjectName queueName = new ObjectName("jboss.messaging.destination:service=Queue,name=" + name);
+         server.invoke(queueName, "removeAllMessages", null, null);
+      }
+      catch (Exception e)
+      {
+         throw new NestedRuntimeException(e);
+      }
+   }
+
+   public void deleteQueue(String name)
+   {
+      try
+      {
+         MBeanServerConnection server = getServer();
+         ObjectName queueName = new ObjectName("jboss.messaging.destination:service=Queue,name=" + name);
+         server.invoke(queueName, "removeAllMessages", null, null);
+         server.invoke(serverPeer, "destroyQueue", new Object[] { name },  new String[] { String.class.getName() } );
+      }
+      catch (Exception e)
+      {
+         throw new NestedRuntimeException(e);
+      }
+   }
+
+   public void createTopic(String name)
+   {
+      try
+      {
+         MBeanServerConnection server = getServer();
+         try
+         {
+            server.invoke(serverPeer, "createTopic", new Object[] { name, name },  new String[] { String.class.getName(), String.class.getName() } );
+         }
+         catch (Exception ignored)
+         {
+            log.trace("Ignored", ignored);
+         }
+         ObjectName topicName = new ObjectName("jboss.messaging.destination:service=Topic,name=" + name);
+         server.invoke(topicName, "removeAllMessages", null, null);
+      }
+      catch (Exception e)
+      {
+         throw new NestedRuntimeException(e);
+      }
+   }
+
+   public void deleteTopic(String name)
+   {
+      try
+      {
+         MBeanServerConnection server = getServer();
+         ObjectName topicName = new ObjectName("jboss.messaging.destination:service=Topic,name=" + name);
+         server.invoke(topicName, "removeAllMessages", null, null);
+         server.invoke(serverPeer, "destroyTopic", new Object[] { name },  new String[] { String.class.getName() } );
+      }
+      catch (Exception e)
+      {
+         throw new NestedRuntimeException(e);
+      }
+   }
+
+   public void createConnectionFactory(String name)
+   {
+      try
+      {
+         MBeanServerConnection server = getServer();
+         server.invoke(namingService, "createAlias", new Object[] { name, "ConnectionFactory" },  new String[] { String.class.getName(), String.class.getName() } );
+      }
+      catch (Exception e)
+      {
+         throw new NestedRuntimeException(e);
+      }
+   }
+
+   public void deleteConnectionFactory(String name)
+   {
+      try
+      {
+         MBeanServerConnection server = getServer();
+         server.invoke(namingService, "removeAlias", new Object[] { name },  new String[] { String.class.getName() } );
+      }
+      catch (Exception e)
+      {
+         throw new NestedRuntimeException(e);
+      }
+   }
+
+   public void createQueueConnectionFactory(String name)
+   {
+       createConnectionFactory(name) ;
+   }
+
+   public void deleteQueueConnectionFactory(String name)
+   {
+       deleteConnectionFactory(name) ;
+   }
+
+   public void createTopicConnectionFactory(String name)
+   {
+       createConnectionFactory(name) ;
+   }
+
+   public void deleteTopicConnectionFactory(String name)
+   {
+       deleteConnectionFactory(name) ;
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/jbossmessaging/JMSTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmessaging/JMSTestCase.java	2006-10-23 19:28:54 UTC (rev 57778)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmessaging/JMSTestCase.java	2006-10-23 21:03:35 UTC (rev 57779)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jbossmessaging;
+
+import org.objectweb.jtests.jms.admin.Admin;
+import org.objectweb.jtests.jms.admin.AdminFactory;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.NestedRuntimeException;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * JMSTestCase.
+ * A base test case for all JMS generic test cases.
+ * 
+ * @author <a href="richard.achmatowicz at jboss.com">Richard Achmatowicz</a>
+ * @version $Revision: 38213 $
+ */
+public class JMSTestCase extends JBossTestCase
+{
+    private Logger log = Logger.getLogger(JMSTestCase.class);
+
+    protected Admin admin;
+
+    /**
+     * Constructor for JMSTestCase object
+     * @param name test case name
+     */
+    public JMSTestCase(String name) throws Exception
+    {
+	super(name);
+    }
+
+    /**
+     * Create the Admin object to perform all JMS adminsitrative functions
+     * in a JMS provider-independent manner
+     */
+    protected void setUp() {
+    	try {
+	    log.info("setting up Admin") ;
+	    // get the Admin implementation for the current JMS provider
+	    // specified in provider.properties
+	    admin = AdminFactory.getAdmin() ;
+	} catch (Exception e) {
+	    e.printStackTrace() ;
+	}
+    }
+
+    public void createQueue(String name) {
+        try {
+            admin.createQueue(name) ;
+        } catch (Exception e) {
+            e.printStackTrace() ;
+        }
+    }
+    public void deleteQueue(String name) {
+        try {
+            admin.deleteQueue(name) ;
+        } catch (Exception e) {
+            e.printStackTrace() ;
+        }
+    }
+    public void createTopic(String name) {
+        try {
+            admin.createTopic(name) ;
+        } catch (Exception e) {
+            e.printStackTrace() ;
+        }
+    }
+    public void deleteTopic(String name) {
+        try {
+            admin.deleteTopic(name) ;
+        } catch (Exception e) {
+            e.printStackTrace() ;
+        }
+    }
+
+    public void createConnectionFactory(String name) {
+	try {
+	    admin.createConnectionFactory(name) ; 
+	} catch (Exception e) {
+	    e.printStackTrace() ;
+	}
+    }
+
+    public void deleteConnectionFactory(String name) {
+        try {
+            admin.deleteConnectionFactory(name) ;
+        } catch (Exception e) {
+            e.printStackTrace() ;
+        }
+    }
+
+}

Modified: trunk/testsuite/src/main/org/jboss/test/jbossmessaging/test/ConcurrentDeliveryUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmessaging/test/ConcurrentDeliveryUnitTestCase.java	2006-10-23 19:28:54 UTC (rev 57778)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmessaging/test/ConcurrentDeliveryUnitTestCase.java	2006-10-23 21:03:35 UTC (rev 57779)
@@ -32,15 +32,16 @@
 import javax.jms.TemporaryQueue;
 import javax.naming.Context;
 
-import org.jboss.test.JBossTestCase;
+import org.jboss.test.jbossmessaging.JMSTestCase;
 
 /**
  * Concurrent delivery tests
  *
+ * @author <a href="mailto:richard.achmatowicz at jboss.org">Richard Achmatowicz</a>
  * @author <a href="mailto:adrian at jboss.org>Adrian Brock</a>
  * @version <tt>$Revision: 37406 $</tt>
  */
-public class ConcurrentDeliveryUnitTestCase extends JBossTestCase
+public class ConcurrentDeliveryUnitTestCase extends JMSTestCase
 {
    static String QUEUE_FACTORY = "ConnectionFactory";
 

Added: trunk/testsuite/src/resources/jbossmessaging/provider.properties
===================================================================
--- trunk/testsuite/src/resources/jbossmessaging/provider.properties	2006-10-23 19:28:54 UTC (rev 57778)
+++ trunk/testsuite/src/resources/jbossmessaging/provider.properties	2006-10-23 21:03:35 UTC (rev 57779)
@@ -0,0 +1,35 @@
+##
+# JORAM: Java(TM) Open Reliable Asynchronous Messaging
+# Copyright (C) 2002 INRIA
+# Contact: joram-team at objectweb.org
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+# USA
+#
+# Initial developer(s): Jeff Mesnil (jmesnil at inrialpes.fr)
+# Contributor(s): ______________________________________.
+##
+
+##
+# This property is used to chose which provider is to be tested
+# Uncomment the chosen provider and comment the other ones
+##
+
+jms.provider.admin.class = org.jboss.test.jbossmessaging.JBossMessagingAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.JoramAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.AshnaMQAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.FioranoMQAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.PramatiAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.SwiftMQAdmin




More information about the jboss-cvs-commits mailing list