[jboss-cvs] JBoss Messaging SVN: r1652 - in branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms: stress stress2

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 29 15:56:43 EST 2006


Author: clebert.suconic at jboss.com
Date: 2006-11-29 15:56:39 -0500 (Wed, 29 Nov 2006)
New Revision: 1652

Added:
   branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress/ConcurrentCloseStressTest.java
Removed:
   branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress2/StressTest.java
Log:
StressTestcase for http://jira.jboss.com/jira/browse/JBMESSAGING-660

Copied: branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress/ConcurrentCloseStressTest.java (from rev 1649, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress2/StressTest.java)
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress2/StressTest.java	2006-11-28 22:36:15 UTC (rev 1649)
+++ branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress/ConcurrentCloseStressTest.java	2006-11-29 20:56:39 UTC (rev 1652)
@@ -0,0 +1,271 @@
+/*
+   * 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.messaging.jms.stress;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.jms.ConnectionTest;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+/**
+ * This test was added to test regression on http://jira.jboss.com/jira/browse/JBMESSAGING-660
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision:$</tt>
+ *          <p/>
+ *          $Id:$
+ */
+public class ConcurrentCloseStressTest extends MessagingTestCase
+{
+   private static final Logger log = Logger.getLogger(ConnectionTest.class);
+
+   public ConcurrentCloseStressTest(String name)
+   {
+      super(name);
+   }
+
+   InitialContext ic;
+   JBossConnectionFactory cf;
+   Queue queue;
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+
+      ServerManagement.start("all");
+
+
+      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+      cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
+
+      ServerManagement.undeployQueue("TestQueue");
+      ServerManagement.deployQueue("TestQueue");
+
+      queue = (Queue) ic.lookup("queue/TestQueue");
+
+      log.debug("setup done");
+   }
+
+   public void tearDown() throws Exception
+   {
+      ServerManagement.undeployQueue("TestQueue");
+
+      super.tearDown();
+
+      log.debug("tear down done");
+   }
+
+
+   public void testProducersAndConsumers() throws Exception
+   {
+      Connection connectionProducer = cf.createConnection();
+      Connection connectionReader = cf.createConnection();
+
+      connectionReader.start();
+      connectionProducer.start(); // try with and without this...
+
+      ProducerThread producerThread[] = new ProducerThread[20];
+      ReaderThread readerThread[] = new ReaderThread[20];
+      TestThread threads[] = new TestThread[40];
+
+
+      for (int i = 0; i < 20; i++)
+      {
+         producerThread[i] = new ProducerThread(connectionProducer, queue);
+         readerThread[i] = new ReaderThread(connectionReader, queue);
+         threads[i] = producerThread[i];
+         threads[i+20] = readerThread[i];
+      }
+
+
+      for (int i = 0; i < 40; i++)
+      {
+         threads[i].start();
+      }
+
+      for (int i = 0; i < 40; i++)
+      {
+         threads[i].join();
+      }
+
+
+      boolean hasFailure=false;
+      for (int i = 0; i < 40; i++)
+      {
+         if (threads[i].exceptions.size() > 0)
+         {
+            hasFailure = true;
+            for (Iterator failureIter = threads[i].exceptions.iterator(); failureIter.hasNext();)
+            {
+               Exception ex = (Exception) failureIter.next();
+               log.error("Exception occurred in one of the threads - " + ex, ex);
+            }
+         }
+      }
+
+      if (hasFailure)
+      {
+         fail ("An exception has occurred in one of the threads");
+      }
+   }
+
+
+   static class TestThread extends Thread
+   {
+      ArrayList exceptions = new ArrayList();
+   }
+
+
+   static class ReaderThread extends TestThread
+   {
+      private static final Logger log = Logger.getLogger(ReaderThread.class);
+      Connection conn;
+
+      Queue queue;
+
+      public ReaderThread(Connection conn, Queue queue) throws Exception
+      {
+         this.conn = conn;
+         this.queue = queue;
+      }
+
+
+      public void run()
+      {
+         int messageCounter = 0;
+         int commitCounter = 0;
+         try
+         {
+            Session session = conn.createSession(true,Session.AUTO_ACKNOWLEDGE);
+            MessageConsumer consumer = session.createConsumer((Destination)queue);
+
+            while (true)
+            {
+               messageCounter++;
+               TextMessage message = (TextMessage) consumer.receive(5000);
+               if (message == null)
+               {
+                  break;
+               }
+               log.info("read message " + message.getText());
+
+               // alternating commits and rollbacks
+               if ( (commitCounter++) % 2 == 0 )
+               {
+                  log.info("commit");
+                  session.commit();
+               }
+               else
+               {
+                  log.info("rollback");
+                  session.rollback();
+               }
+
+               if (messageCounter%7 == 0 )
+               {
+                  session.close();
+                  session = conn.createSession(true,Session.AUTO_ACKNOWLEDGE);
+                  consumer = session.createConsumer((Destination)queue);
+               }
+            }
+
+            session.commit();
+            consumer.close();
+            session.close();
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+            exceptions.add(e);
+         }
+      }
+
+   }
+
+
+   static class ProducerThread extends TestThread
+   {
+      private static final Logger log = Logger.getLogger(ProducerThread.class);
+
+      Connection conn;
+
+      Queue queue;
+
+      public ProducerThread(Connection conn, Queue queue) throws Exception
+      {
+         this.conn = conn;
+         this.queue = queue;
+      }
+
+
+      public void run()
+      {
+         for (int i = 0; i < 10; i++)
+         {
+            try
+            {
+               Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
+               MessageProducer producer = sess.createProducer((Destination)queue);
+
+               for (int j = 0; j < 20; j++)
+               {
+                  producer.send(sess.createTextMessage("Message " + i + ", " + j));
+                  log.info("Sending message " + j + " on i=" + i);
+                  if (j%2==0)
+                  {
+                     log.info("commit");
+                     sess.commit();
+                  }
+                  else
+                  {
+                     log.info("rollback");
+                     sess.rollback();
+                  }
+
+               }
+
+               sess.commit();
+               sess.close();
+
+            }
+            catch (Exception e)
+            {
+               e.printStackTrace();
+               exceptions.add(e);
+            }
+         }
+      }
+
+   }
+
+}

Deleted: branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress2/StressTest.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress2/StressTest.java	2006-11-29 00:22:57 UTC (rev 1651)
+++ branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress2/StressTest.java	2006-11-29 20:56:39 UTC (rev 1652)
@@ -1,273 +0,0 @@
-/*
-   * 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.messaging.jms.stress2;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.logging.Logger;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.jms.ConnectionTest;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision:$</tt>
- *          <p/>
- *          $Id:$
- */
-public class StressTest extends MessagingTestCase
-{
-   private static final Logger log = Logger.getLogger(ConnectionTest.class);
-
-   public StressTest(String name)
-   {
-      super(name);
-   }
-
-   InitialContext ic;
-   JBossConnectionFactory cf;
-   Queue queue;
-
-   public void setUp() throws Exception
-   {
-      super.setUp();
-
-      ServerManagement.start("all");
-
-
-      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-      cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
-      ServerManagement.undeployQueue("TestQueue");
-      ServerManagement.deployQueue("TestQueue");
-
-      queue = (Queue) ic.lookup("queue/TestQueue");
-
-      log.debug("setup done");
-   }
-
-   public void tearDown() throws Exception
-   {
-      ServerManagement.undeployQueue("TestQueue");
-
-      super.tearDown();
-
-      log.debug("tear down done");
-   }
-
-
-   public void testProducersAndConsumers() throws Exception
-   {
-      Connection connectionProducer = cf.createConnection();
-      Connection connectionReader = cf.createConnection();
-
-      connectionReader.start();
-      connectionProducer.start(); // try with and without this...
-
-      ProducerThread producerThread[] = new ProducerThread[20];
-      ReaderThread readerThread[] = new ReaderThread[20];
-      TestThread threads[] = new TestThread[40];
-
-
-      for (int i = 0; i < 20; i++)
-      {
-         producerThread[i] = new ProducerThread(connectionProducer, queue);
-         readerThread[i] = new ReaderThread(connectionReader, queue);
-         threads[i] = producerThread[i];
-         threads[i+20] = readerThread[i];
-      }
-
-
-      for (int i = 0; i < 40; i++)
-      {
-         threads[i].start();
-      }
-
-      for (int i = 0; i < 40; i++)
-      {
-         threads[i].join();
-      }
-
-
-      boolean hasFailure=false;
-      for (int i = 0; i < 40; i++)
-      {
-         if (threads[i].exceptions.size() > 0)
-         {
-            hasFailure = true;
-            for (Iterator failureIter = threads[i].exceptions.iterator(); failureIter.hasNext();)
-            {
-               Exception ex = (Exception) failureIter.next();
-               log.error("Exception occurred in one of the threads - " + ex, ex);
-            }
-         }
-      }
-
-      if (hasFailure)
-      {
-         fail ("An exception has occurred in one of the threads");
-      }
-
-
-
-
-   }
-
-
-   static class TestThread extends Thread
-   {
-      ArrayList exceptions = new ArrayList();
-   }
-
-
-   static class ReaderThread extends TestThread
-   {
-      private static final Logger log = Logger.getLogger(ReaderThread.class);
-      Connection conn;
-
-      Queue queue;
-
-      public ReaderThread(Connection conn, Queue queue) throws Exception
-      {
-         this.conn = conn;
-         this.queue = queue;
-      }
-
-
-      public void run()
-      {
-         int messageCounter = 0;
-         int commitCounter = 0;
-         try
-         {
-            Session session = conn.createSession(true,Session.AUTO_ACKNOWLEDGE);
-            MessageConsumer consumer = session.createConsumer((Destination)queue);
-
-            while (true)
-            {
-               messageCounter++;
-               TextMessage message = (TextMessage) consumer.receive(5000);
-               if (message == null)
-               {
-                  break;
-               }
-               log.info("read message " + message.getText());
-
-               // alternating commits and rollbacks
-               if ( (commitCounter++) % 2 == 0 )
-               {
-                  log.info("commit");
-                  session.commit();
-               }
-               else
-               {
-                  log.info("rollback");
-                  session.rollback();
-               }
-
-               if (messageCounter%7 == 0 )
-               {
-                  session.close();
-                  session = conn.createSession(true,Session.AUTO_ACKNOWLEDGE);
-                  consumer = session.createConsumer((Destination)queue);
-               }
-            }
-
-            session.commit();
-            consumer.close();
-            session.close();
-         }
-         catch (Exception e)
-         {
-            e.printStackTrace();
-            exceptions.add(e);
-         }
-      }
-
-   }
-
-
-   static class ProducerThread extends TestThread
-   {
-      private static final Logger log = Logger.getLogger(ProducerThread.class);
-
-      Connection conn;
-
-      Queue queue;
-
-      public ProducerThread(Connection conn, Queue queue) throws Exception
-      {
-         this.conn = conn;
-         this.queue = queue;
-      }
-
-
-      public void run()
-      {
-         for (int i = 0; i < 10; i++)
-         {
-            try
-            {
-               Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-               MessageProducer producer = sess.createProducer((Destination)queue);
-
-               for (int j = 0; j < 500; j++)
-               {
-                  producer.send(sess.createTextMessage("Message " + i + ", " + j));
-                  log.info("Sending message " + j + " on j=" + j);
-                  if (j%2==0)
-                  {
-                     log.info("commit");
-                     sess.commit();
-                  }
-                  else
-                  {
-                     log.info("rollback");
-                     sess.rollback();
-                  }
-
-               }
-
-               sess.close();
-
-            }
-            catch (Exception e)
-            {
-               e.printStackTrace();
-               exceptions.add(e);
-            }
-         }
-      }
-
-   }
-
-}




More information about the jboss-cvs-commits mailing list