[jboss-cvs] JBossAS SVN: r61549 - trunk/testsuite/src/main/org/jboss/test/jbossmq/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 21 10:25:05 EDT 2007


Author: adrian at jboss.org
Date: 2007-03-21 10:25:05 -0400 (Wed, 21 Mar 2007)
New Revision: 61549

Added:
   trunk/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java
Log:
Port JBAS-4222 from JBoss-4.2

Added: trunk/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmq/test/UIL2DisconnectClientsUnitTestCase.java	2007-03-21 14:25:05 UTC (rev 61549)
@@ -0,0 +1,95 @@
+/*
+ * 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.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
+{
+   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)
+   {
+      exceptionListenerFired.set(true);
+      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();
+         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