[jboss-cvs] JBossAS SVN: r63425 - in branches/JBoss_4_0_4_GA_ASPATCH-228: testsuite/src/main/org/jboss/test/jbossmq and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 8 11:43:01 EDT 2007


Author: jhowell at redhat.com
Date: 2007-06-08 11:43:01 -0400 (Fri, 08 Jun 2007)
New Revision: 63425

Added:
   branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/
   branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyClientILService.java
   branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyJBossMQTest.java
   branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerIL.java
   branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerSession.java
   branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerSessionPool.java
   branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/test/ConnectionConsumerErrorFiredUnitTestCase.java
Modified:
   branches/JBoss_4_0_4_GA_ASPATCH-228/messaging/src/main/org/jboss/mq/SpyConnectionConsumer.java
Log:
[ASPATCH-228] changed SpyConnectionconsumer and added unit tests for the change.

Modified: branches/JBoss_4_0_4_GA_ASPATCH-228/messaging/src/main/org/jboss/mq/SpyConnectionConsumer.java
===================================================================
--- branches/JBoss_4_0_4_GA_ASPATCH-228/messaging/src/main/org/jboss/mq/SpyConnectionConsumer.java	2007-06-08 13:56:40 UTC (rev 63424)
+++ branches/JBoss_4_0_4_GA_ASPATCH-228/messaging/src/main/org/jboss/mq/SpyConnectionConsumer.java	2007-06-08 15:43:01 UTC (rev 63425)
@@ -333,7 +333,7 @@
       }
       catch (Throwable t)
       {
-         log.warn("Connection consumer closing due to error in listening thread " + this, t);
+         
          try
          {
             for (int i = 0; i < mesList.size(); i++)
@@ -356,6 +356,7 @@
             if (trace)
                log.trace("Ignoring error during close " + this, ignore);
          }
+         connection.asynchFailure("Connection consumer closing due to error in listening thread" + this, t);
       }
    }   
 

Added: branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyClientILService.java
===================================================================
--- branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyClientILService.java	                        (rev 0)
+++ branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyClientILService.java	2007-06-08 15:43:01 UTC (rev 63425)
@@ -0,0 +1,84 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.jbossmq.support;
+
+import java.util.Properties;
+
+import org.jboss.mq.Connection;
+import org.jboss.mq.ReceiveRequest;
+import org.jboss.mq.SpyDestination;
+import org.jboss.mq.il.ClientIL;
+import org.jboss.mq.il.ClientILService;
+import org.jboss.mq.il.ServerIL;
+
+/**
+ * DummyClientILService.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DummyClientILService implements ClientILService, ClientIL
+{
+   private Connection connection;
+   
+   public ClientIL getClientIL() throws Exception
+   {
+      return this;
+   }
+
+   public void init(Connection connection, Properties props) throws Exception
+   {
+      this.connection = connection;
+      DummyServerIL serverIL = (DummyServerIL) connection.getServerIL();
+      serverIL.setClientIL(this);
+   }
+
+   public void start() throws Exception
+   {
+      // Nothing
+   }
+
+   public void stop() throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("stop");
+   }
+
+   public void close() throws Exception
+   {
+      connection.asynchClose();
+   }
+
+   public void deleteTemporaryDestination(SpyDestination dest) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("deleteTemporaryDestination");
+   }
+
+   public void pong(long serverTime) throws Exception
+   {
+      connection.asynchPong(serverTime);
+   }
+
+   public void receive(ReceiveRequest[] messages) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("receive");
+   }
+}

Added: branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyJBossMQTest.java
===================================================================
--- branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyJBossMQTest.java	                        (rev 0)
+++ branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyJBossMQTest.java	2007-06-08 15:43:01 UTC (rev 63425)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.jbossmq.support;
+
+import java.util.Properties;
+
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+
+import org.jboss.mq.GenericConnectionFactory;
+import org.jboss.mq.SpyConnection;
+import org.jboss.mq.il.ServerIL;
+import org.jboss.mq.il.ServerILFactory;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * DummyJBossMQTest.<p>
+ * 
+ * Uses the DummyIL to test client behaviour under
+ * more "controlled" conditions
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class DummyJBossMQTest extends BaseTestCase implements ExceptionListener
+{
+   private JMSException exception;
+   
+   public DummyJBossMQTest(String name)
+   {
+      super(name);
+   }
+   
+   protected SpyConnection createConnection() throws Exception
+   {
+      ServerIL serverIL = new DummyServerIL();
+      Properties properties = new Properties();
+      properties.put(ServerILFactory.CLIENT_IL_SERVICE_KEY, DummyClientILService.class.getName());
+      GenericConnectionFactory gcf = new GenericConnectionFactory(serverIL, properties);
+      SpyConnection connection = new SpyConnection(SpyConnection.UNIFIED, gcf);
+      connection.setExceptionListener(this);
+      return connection;
+   }
+   
+   protected void setThrowError(SpyConnection connection, String when)
+   {
+      DummyServerIL serverIL = (DummyServerIL) connection.getServerIL();
+      serverIL.setThrowError(when);
+   }
+   
+   protected synchronized JMSException getException() throws Exception
+   {
+      if (exception == null)
+         wait(10000);
+      return exception;
+   }
+
+   public synchronized void onException(JMSException exception)
+   {
+      this.exception = exception;
+      notifyAll();
+   }
+}

Added: branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerIL.java
===================================================================
--- branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerIL.java	                        (rev 0)
+++ branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerIL.java	2007-06-08 15:43:01 UTC (rev 63425)
@@ -0,0 +1,177 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.jbossmq.support;
+
+import java.io.IOException;
+
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
+import javax.jms.Topic;
+
+import org.jboss.mq.AcknowledgementRequest;
+import org.jboss.mq.ConnectionToken;
+import org.jboss.mq.DurableSubscriptionID;
+import org.jboss.mq.SpyDestination;
+import org.jboss.mq.SpyMessage;
+import org.jboss.mq.Subscription;
+import org.jboss.mq.TransactionRequest;
+import org.jboss.mq.il.ClientIL;
+import org.jboss.mq.il.ServerIL;
+import org.jboss.util.id.UID;
+
+/**
+ * DummyServerIL.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DummyServerIL implements ServerIL
+{
+   private ClientIL clientIL;
+
+   private String when = "";
+   
+   public void setThrowError(String when)
+   {
+      this.when = when;
+   }
+   
+   public void setClientIL(ClientIL clientIL)
+   {
+      this.clientIL = clientIL;
+   }
+   
+   public void acknowledge(ConnectionToken dc, AcknowledgementRequest item) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("acknowledge");
+   }
+
+   public void addMessage(ConnectionToken dc, SpyMessage message) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("addMessage");
+   }
+
+   public String authenticate(String userName, String password) throws Exception
+   {
+      return UID.asString();
+   }
+
+   public SpyMessage[] browse(ConnectionToken dc, Destination dest, String selector) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("browse");
+   }
+
+   public void checkID(String ID) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("checkID");
+   }
+
+   public String checkUser(String userName, String password) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("checkUser");
+   }
+
+   public ServerIL cloneServerIL() throws Exception
+   {
+      return this;
+   }
+
+   public void connectionClosing(ConnectionToken dc) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("connectionClosing");
+   }
+
+   public Queue createQueue(ConnectionToken dc, String dest) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("createQueue");
+   }
+
+   public Topic createTopic(ConnectionToken dc, String dest) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("createTopic");
+   }
+
+   public void deleteTemporaryDestination(ConnectionToken dc, SpyDestination dest) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("deleteTemporaryDestination");
+   }
+
+   public void destroySubscription(ConnectionToken dc, DurableSubscriptionID id) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("destroySubscription");
+   }
+
+   public String getID() throws Exception
+   {
+      return UID.asString();
+   }
+
+   public TemporaryQueue getTemporaryQueue(ConnectionToken dc) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("getTemporaryQueue");
+   }
+
+   public TemporaryTopic getTemporaryTopic(ConnectionToken dc) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("getTemporaryTopic");
+   }
+
+   public void ping(ConnectionToken dc, long clientTime) throws Exception
+   {
+      clientIL.pong(clientTime);
+   }
+
+   public SpyMessage receive(ConnectionToken dc, int subscriberId, long wait) throws Exception
+   {
+      if ("receive".equals(when))
+         throw new IOException("Error in receive");
+      return null;
+   }
+
+   public void setConnectionToken(ConnectionToken newConnectionToken) throws Exception
+   {
+      // Nothing
+   }
+
+   public void setEnabled(ConnectionToken dc, boolean enabled) throws Exception
+   {
+      // Nothing
+   }
+
+   public void subscribe(ConnectionToken dc, Subscription s) throws Exception
+   {
+      // Nothing
+   }
+
+   public void transact(ConnectionToken dc, TransactionRequest t) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("transact");
+      
+   }
+
+   public void unsubscribe(ConnectionToken dc, int subscriptionId) throws Exception
+   {
+      throw new org.jboss.util.NotImplementedException("unsubscribe");
+   }
+}

Added: branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerSession.java
===================================================================
--- branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerSession.java	                        (rev 0)
+++ branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerSession.java	2007-06-08 15:43:01 UTC (rev 63425)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.jbossmq.support;
+
+import javax.jms.JMSException;
+import javax.jms.ServerSession;
+import javax.jms.Session;
+
+import org.jboss.util.NotImplementedException;
+
+/**
+ * DummyServerSession.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DummyServerSession implements ServerSession
+{
+   private Session session;
+   
+   public DummyServerSession(Session session)
+   {
+      this.session = session;
+   }
+   
+   public Session getSession() throws JMSException
+   {
+      return session;
+   }
+
+   public void start() throws JMSException
+   {
+      throw new NotImplementedException("start");
+   }
+}

Added: branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerSessionPool.java
===================================================================
--- branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerSessionPool.java	                        (rev 0)
+++ branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/support/DummyServerSessionPool.java	2007-06-08 15:43:01 UTC (rev 63425)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.jbossmq.support;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.ServerSession;
+import javax.jms.ServerSessionPool;
+import javax.jms.Session;
+
+/**
+ * DummyServerSessionPool.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DummyServerSessionPool implements ServerSessionPool
+{
+   private Connection connection;
+   
+   public DummyServerSessionPool(Connection connection)
+   {
+      this.connection = connection;
+   }
+   
+   public ServerSession getServerSession() throws JMSException
+   {
+      return new DummyServerSession(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
+   }
+}

Added: branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/test/ConnectionConsumerErrorFiredUnitTestCase.java
===================================================================
--- branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/test/ConnectionConsumerErrorFiredUnitTestCase.java	                        (rev 0)
+++ branches/JBoss_4_0_4_GA_ASPATCH-228/testsuite/src/main/org/jboss/test/jbossmq/test/ConnectionConsumerErrorFiredUnitTestCase.java	2007-06-08 15:43:01 UTC (rev 63425)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.jbossmq.test;
+
+import java.io.IOException;
+
+import javax.jms.JMSException;
+import javax.jms.ServerSessionPool;
+
+import org.jboss.mq.SpyConnection;
+import org.jboss.mq.SpyQueue;
+import org.jboss.test.jbossmq.support.DummyJBossMQTest;
+import org.jboss.test.jbossmq.support.DummyServerSessionPool;
+
+/**
+ * Test an error in the connection consumer fires
+ * the asynch failure, i.e. exception listener
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConnectionConsumerErrorFiredUnitTestCase extends DummyJBossMQTest
+{
+   public ConnectionConsumerErrorFiredUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testExceptionListenerFiredOnError() throws Exception
+   {
+      SpyConnection connection = createConnection();
+      try
+      {
+         ServerSessionPool pool = new DummyServerSessionPool(connection);
+         connection.createConnectionConsumer(new SpyQueue("QUEUE.testQueue"), null, pool, 1);
+         setThrowError(connection, "receive");
+         connection.start();
+         
+         JMSException e = getException();
+         assertNotNull("ExceptionListener should have been invoked", e);
+         checkThrowable(IOException.class, e.getLinkedException());
+      }
+      finally
+      {
+         connection.close();
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list