[jboss-cvs] JBossAS SVN: r63260 - in branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test: messagedriven/support and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 30 14:27:33 EDT 2007


Author: luc.texier at jboss.com
Date: 2007-05-30 14:27:33 -0400 (Wed, 30 May 2007)
New Revision: 63260

Added:
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/jbossmq/test/AbstractRestartDisconnectClientsTest.java
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java
Modified:
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/JMSContainerInvokerSimpleMessageDrivenUnitTest.java
   branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/SendMessageOperation.java
Log:
ASPATCH-220 Added support for stopping ILs

Added: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/jbossmq/test/AbstractRestartDisconnectClientsTest.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/jbossmq/test/AbstractRestartDisconnectClientsTest.java	                        (rev 0)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/jbossmq/test/AbstractRestartDisconnectClientsTest.java	2007-05-30 18:27:33 UTC (rev 63260)
@@ -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/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java	                        (rev 0)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java	2007-05-30 18:27:33 UTC (rev 63260)
@@ -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 UIL2 service is stopped
+ *
+ * @author <a href="mailto:adrian at jboss.org>Adrian Brock</a>
+ * @version <tt>$Revision: 57211 $</tt>
+ */
+public class UIL2DisconnectClientsUnitTestCase extends AbstractRestartDisconnectClientsTest
+{
+   static ObjectName UIL2 = ObjectNameFactory.create("jboss.mq:service=InvocationLayer,type=UIL2");
+   
+   public UIL2DisconnectClientsUnitTestCase(String name) throws Exception
+   {
+      super(name);
+   }
+
+   protected ObjectName getRestartObjectName()
+   {
+      return UIL2;
+   }
+}

Modified: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java	2007-05-30 18:25:58 UTC (rev 63259)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java	2007-05-30 18:27:33 UTC (rev 63260)
@@ -178,6 +178,7 @@
       
       ConnectionFactory factory = (ConnectionFactory) lookup(connectionFactoryJNDI, ConnectionFactory.class);
       connection = factory.createConnection();
+      connection.setExceptionListener(this);
       return connection;
    }
    

Modified: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/JMSContainerInvokerSimpleMessageDrivenUnitTest.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/JMSContainerInvokerSimpleMessageDrivenUnitTest.java	2007-05-30 18:25:58 UTC (rev 63259)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/JMSContainerInvokerSimpleMessageDrivenUnitTest.java	2007-05-30 18:27:33 UTC (rev 63260)
@@ -35,7 +35,7 @@
  */
 public abstract class JMSContainerInvokerSimpleMessageDrivenUnitTest extends SimpleMessageDrivenUnitTest
 {
-   protected ObjectName persistenceManager = ObjectNameFactory.create("jboss.mq:service=DestinationManager");
+   protected ObjectName persistenceManager = ObjectNameFactory.create("jboss.mq:service=PersistenceManager");
    
    protected ObjectName mdbInvoker = ObjectNameFactory.create("jboss.j2ee:service=EJB,jndiName=TestMDB,plugin=invoker,binding=jms-container-invoker-driven-bean");
    

Modified: branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/SendMessageOperation.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/SendMessageOperation.java	2007-05-30 18:25:58 UTC (rev 63259)
+++ branches/JBoss_4_0_5_GA_CP/testsuite/src/main/org/jboss/test/messagedriven/support/SendMessageOperation.java	2007-05-30 18:27:33 UTC (rev 63260)
@@ -21,6 +21,7 @@
  */
 package org.jboss.test.messagedriven.support;
 
+import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageProducer;
 
@@ -44,9 +45,26 @@
 
    public void run() throws Exception
    {
-      MessageProducer producer = test.getMessageProducer();
-      Message message = test.getTestMessage();
-      message.setStringProperty(MESSAGEID, id);
-      producer.send(message);
+      int retries = 5;
+      while (true)
+      {
+         try
+         {
+            MessageProducer producer = test.getMessageProducer();
+            Message message = test.getTestMessage();
+            message.setStringProperty(MESSAGEID, id);
+            producer.send(message);
+            // DONE
+            return;
+         }
+         catch (JMSException e)
+         {
+            // Got an error, sleep then retry
+            if (retries-- > 0)
+               Thread.sleep(1000);
+            else
+               throw e;
+         }
+      }
    }
 }




More information about the jboss-cvs-commits mailing list