[jboss-cvs] JBossAS SVN: r61742 - branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 27 11:38:57 EDT 2007


Author: adrian at jboss.org
Date: 2007-03-27 11:38:57 -0400 (Tue, 27 Mar 2007)
New Revision: 61742

Added:
   branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/AbstractRestartDisconnectClientsTest.java
   branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/DestinationManagerDisconnectClientsUnitTestCase.java
   branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/PersistenceManagerDisconnectClientsUnitTestCase.java
Modified:
   branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java
Log:
[JBAS-2813] - Add more tests for restarting parts of the server triggering the ExceptionListener on the client

Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/AbstractRestartDisconnectClientsTest.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/AbstractRestartDisconnectClientsTest.java	                        (rev 0)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/AbstractRestartDisconnectClientsTest.java	2007-03-27 15:38:57 UTC (rev 61742)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbossmq.test;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.jboss.test.JBossTestCase;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * A test to make sure exception listeners are fired when a service is restarted
+ *
+ * @author <a href="mailto:adrian at jboss.org>Adrian Brock</a>
+ * @version <tt>$Revision: 57211 $</tt>
+ */
+public abstract class AbstractRestartDisconnectClientsTest extends JBossTestCase implements ExceptionListener
+{
+   static String FACTORY = "ConnectionFactory";
+   
+   private SynchronizedBoolean exceptionListenerFired = new SynchronizedBoolean(false); 
+   
+   public AbstractRestartDisconnectClientsTest(String name) throws Exception
+   {
+      super(name);
+   }
+
+   protected abstract ObjectName getRestartObjectName();
+   
+   public synchronized void onException(JMSException exception)
+   {
+      exceptionListenerFired.set(true);
+      getLog().debug("Received notification of error: ", exception);
+      notifyAll();
+   }
+
+   public void testDisconnect() throws Exception
+   {
+      ConnectionFactory factory = (ConnectionFactory) getInitialContext().lookup(FACTORY);
+      Connection connection = factory.createConnection();
+      try
+      {
+         connection.setExceptionListener(this);
+         connection.start();
+         MBeanServerConnection server = getServer();
+         ObjectName objectName = getRestartObjectName();
+         server.invoke(objectName, "stop", null, null);
+         try
+         {
+            // Shouldn't really have to wait for the ping timeout, but just in case
+            synchronized (this)
+            {
+               if (exceptionListenerFired.get() == false)
+                  wait(20 * 1000);
+            }
+            assertTrue("Exception Listener should have been invoked", exceptionListenerFired.get());
+         }
+         finally
+         {
+            server.invoke(objectName, "start", null, null);
+         }
+      }
+      finally
+      {
+         try
+         {
+            connection.close();
+         }
+         catch (JMSException ignored)
+         {
+         }
+      }
+   }
+}

Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/DestinationManagerDisconnectClientsUnitTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/DestinationManagerDisconnectClientsUnitTestCase.java	                        (rev 0)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/DestinationManagerDisconnectClientsUnitTestCase.java	2007-03-27 15:38:57 UTC (rev 61742)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbossmq.test;
+
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+
+/**
+ * A test to make sure exception listeners are fired when the destination manager service is stopped
+ *
+ * @author <a href="mailto:adrian at jboss.org>Adrian Brock</a>
+ * @version <tt>$Revision: 57211 $</tt>
+ */
+public class DestinationManagerDisconnectClientsUnitTestCase extends AbstractRestartDisconnectClientsTest
+{
+   static ObjectName DM = ObjectNameFactory.create("jboss.mq:service=DestinationManager");
+
+   public DestinationManagerDisconnectClientsUnitTestCase(String name) throws Exception
+   {
+      super(name);
+   }
+
+   protected ObjectName getRestartObjectName()
+   {
+      return DM;
+   }
+}

Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/PersistenceManagerDisconnectClientsUnitTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/PersistenceManagerDisconnectClientsUnitTestCase.java	                        (rev 0)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/PersistenceManagerDisconnectClientsUnitTestCase.java	2007-03-27 15:38:57 UTC (rev 61742)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbossmq.test;
+
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+
+/**
+ * A test to make sure exception listeners are fired when the persistence manager service is stopped
+ *
+ * @author <a href="mailto:adrian at jboss.org>Adrian Brock</a>
+ * @version <tt>$Revision: 57211 $</tt>
+ */
+public class PersistenceManagerDisconnectClientsUnitTestCase extends AbstractRestartDisconnectClientsTest
+{
+   static ObjectName PM = ObjectNameFactory.create("jboss.mq:service=PersistenceManager");
+
+   public PersistenceManagerDisconnectClientsUnitTestCase(String name) throws Exception
+   {
+      super(name);
+   }
+
+   protected ObjectName getRestartObjectName()
+   {
+      return PM;
+   }
+}

Modified: branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java	2007-03-27 15:36:55 UTC (rev 61741)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java	2007-03-27 15:38:57 UTC (rev 61742)
@@ -21,75 +21,27 @@
  */
 package org.jboss.test.jbossmq.test;
 
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 
 import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.test.JBossTestCase;
 
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
-
 /**
  * A test to make sure exception listeners are fired when the UIL2 service is stopped
  *
  * @author <a href="mailto:adrian at jboss.org>Adrian Brock</a>
  * @version <tt>$Revision: 57211 $</tt>
  */
-public class UIL2DisconnectClientsUnitTestCase extends JBossTestCase implements ExceptionListener
+public class UIL2DisconnectClientsUnitTestCase extends AbstractRestartDisconnectClientsTest
 {
-   static String FACTORY = "ConnectionFactory";
    static ObjectName UIL2 = ObjectNameFactory.create("jboss.mq:service=InvocationLayer,type=UIL2");
    
-   private SynchronizedBoolean exceptionListenerFired = new SynchronizedBoolean(false); 
-   
    public UIL2DisconnectClientsUnitTestCase(String name) throws Exception
    {
       super(name);
    }
 
-   public synchronized void onException(JMSException exception)
+   protected ObjectName getRestartObjectName()
    {
-      exceptionListenerFired.set(true);
-      notifyAll();
+      return UIL2;
    }
-
-   public void testDisconnect() throws Exception
-   {
-      ConnectionFactory factory = (ConnectionFactory) getInitialContext().lookup(FACTORY);
-      Connection connection = factory.createConnection();
-      try
-      {
-         connection.setExceptionListener(this);
-         connection.start();
-         MBeanServerConnection server = getServer();
-         server.invoke(UIL2, "stop", null, null);
-         try
-         {
-            // Shouldn't really have to wait for the ping timeout, but just in case
-            synchronized (this)
-            {
-               wait(60 * 1000);
-            }
-            assertTrue("Exception Listener should have been invoked", exceptionListenerFired.get());
-         }
-         finally
-         {
-            server.invoke(UIL2, "start", null, null);
-         }
-      }
-      finally
-      {
-         try
-         {
-            connection.close();
-         }
-         catch (JMSException ignored)
-         {
-         }
-      }
-   }
 }




More information about the jboss-cvs-commits mailing list