[jboss-cvs] JBossAS SVN: r105809 - in branches/JBPAPP_5_1/testsuite: src/main/org/jboss/test/jca/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 8 13:31:21 EDT 2010


Author: clebert.suconic at jboss.com
Date: 2010-06-08 13:31:20 -0400 (Tue, 08 Jun 2010)
New Revision: 105809

Added:
   branches/JBPAPP_5_1/testsuite/src/resources/jca/executejmsrollbackhornetq/
   branches/JBPAPP_5_1/testsuite/src/resources/jca/executejmsrollbackhornetq/test-jms-local-ds.xml
Modified:
   branches/JBPAPP_5_1/testsuite/imports/sections/jca.xml
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jca/test/ExecuteJMSDuringRollbackStressTestCase.java
Log:
fixing HornetQ test

Modified: branches/JBPAPP_5_1/testsuite/imports/sections/jca.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/sections/jca.xml	2010-06-08 17:00:05 UTC (rev 105808)
+++ branches/JBPAPP_5_1/testsuite/imports/sections/jca.xml	2010-06-08 17:31:20 UTC (rev 105809)
@@ -256,6 +256,29 @@
             <patternset refid="jboss.test.set"/>
          </zipfileset>
       </jar>
+   	
+        <jar destfile="${build.lib}/jcaexecutejmsrollbackHornetQ.jar">
+           <fileset dir="${build.classes}">
+              <patternset refid="common.test.client.classes"/>
+              <include name="org/jboss/test/jca/test/ExecuteJMS*"/>
+              <include name="org/jboss/test/jca/jms/*"/>
+              <include name="org/jboss/test/util/ejb/*"/>
+           </fileset>
+           <fileset dir="${build.resources}/jca/test">
+              <include name="**/*.*"/>
+           </fileset>
+           <fileset dir="${build.resources}/jca/executejmsrollbackhornetq">
+              <include name="**/*.*"/>
+           </fileset>
+           <zipfileset src="${junit.junit.lib}/junit.jar">
+              <patternset refid="ejbrunner.set"/>
+           </zipfileset>
+           <zipfileset src="${jboss.test.lib}/jboss-test.jar">
+              <patternset refid="jboss.test.set"/>
+           </zipfileset>
+        </jar>
+        
+   	
       
       <jar destfile="${build.lib}/jca-tests.jar">
          <fileset dir="${build.classes}">

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jca/test/ExecuteJMSDuringRollbackStressTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jca/test/ExecuteJMSDuringRollbackStressTestCase.java	2010-06-08 17:00:05 UTC (rev 105808)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jca/test/ExecuteJMSDuringRollbackStressTestCase.java	2010-06-08 17:31:20 UTC (rev 105809)
@@ -55,333 +55,319 @@
  */
 public class ExecuteJMSDuringRollbackStressTestCase extends EJBTestCase
 {
-   protected final Logger log = Logger.getLogger(getClass());
-   
-   private static final long WAIT = 1000l;
-   
-   private ConnectionFactory cf;
-   
-   private Queue queue;
-   
-   private CountDownLatch latch;
+    protected final Logger log = Logger.getLogger(getClass());
 
-   private TransactionManager tm;
-   
-   private AtomicReference<Transaction> transaction = new AtomicReference<Transaction>();
+    private static final long WAIT = 1000l;
 
-   public void testExecuteJMSDuringRollback() throws Throwable
-   {
-      queue = (Queue) new InitialContext().lookup("queue/testQueue");
-      cf = (ConnectionFactory) new InitialContext().lookup("java:TestJmsLocal");
-      setupQueue();
-      // FIXME This test fails after 5 iterations with JBoss Messaging
-      for (int i = 0; i < 4; ++i)
-      {
-         log.info("Running " + getName() + " iteration=" + i);
-         latch = new CountDownLatch(2);
+    private ConnectionFactory cf;
 
-         ExecuteJMS executeJMS = new ExecuteJMS();
-         Thread thread1 = new Thread(executeJMS);
-         thread1.start();
+    private Queue queue;
 
-         Rollback rollback = new Rollback();
-         Thread thread2 = new Thread(rollback);
-         thread2.start();
-         
-         thread1.join();
-         thread2.join();
-         if (executeJMS.error != null)
-         {
-            log.error(executeJMS.error);
-            throw executeJMS.error;
-         }
-         if (rollback.error != null)
-         {
-            log.error(rollback.error);
-            throw rollback.error;
-         }
-         checkQueue();
-      }
-   }
-   
-   public class ExecuteJMS extends TestRunnable
-   {
-      private Connection c;
-      private MessageProducer p;
-      private Message m;
-      
-      public void setup() throws Throwable
-      {
-         tm.begin();
-         transaction.set(tm.getTransaction());
-         
-         try
-         {
-            c = cf.createConnection();
-            c.start();
-            Session s = c.createSession(true, Session.SESSION_TRANSACTED);
-            MessageConsumer r = s.createConsumer(queue);
-            r.receive(WAIT);
-            r.close();
-            p = s.createProducer(queue);
-            m = s.createTextMessage("100");
-         }
-         catch (Throwable t)
-         {
-            try
+    private CountDownLatch latch;
+
+    private TransactionManager tm;
+
+    private AtomicReference<Transaction> transaction = new AtomicReference<Transaction>();
+
+    public void testExecuteJMSDuringRollback() throws Throwable
+    {
+        queue = (Queue) new InitialContext().lookup("queue/testQueue");
+        cf = (ConnectionFactory) new InitialContext()
+                .lookup("java:TestJmsLocal");
+        setupQueue();
+        // FIXME This test fails after 5 iterations with JBoss Messaging
+        for (int i = 0; i < 4; ++i)
+        {
+            log.info("Running " + getName() + " iteration=" + i);
+            latch = new CountDownLatch(2);
+
+            ExecuteJMS executeJMS = new ExecuteJMS();
+            Thread thread1 = new Thread(executeJMS);
+            thread1.start();
+
+            Rollback rollback = new Rollback();
+            Thread thread2 = new Thread(rollback);
+            thread2.start();
+
+            thread1.join();
+            thread2.join();
+            if (executeJMS.error != null)
             {
-               if (c != null)
-                  c.close();
+                log.error(executeJMS.error);
+                throw executeJMS.error;
             }
-            catch (Exception ignored)
+            if (rollback.error != null)
             {
+                log.error(rollback.error);
+                throw rollback.error;
             }
+            checkQueue();
+        }
+    }
+
+    public class ExecuteJMS extends TestRunnable
+    {
+        private Connection c;
+        private MessageProducer p;
+        private Message m;
+
+        public void setup() throws Throwable
+        {
+            tm.begin();
+            transaction.set(tm.getTransaction());
+
             try
             {
-               tm.rollback();
-            }
-            catch (Exception ignored)
+                c = cf.createConnection();
+                c.start();
+                Session s = c.createSession(true, Session.SESSION_TRANSACTED);
+                MessageConsumer r = s.createConsumer(queue);
+                r.receive(WAIT);
+                r.close();
+                p = s.createProducer(queue);
+                m = s.createTextMessage("100");
+            } catch (Throwable t)
             {
-               log.warn("Ignored", ignored);
+                try
+                {
+                    if (c != null)
+                        c.close();
+                } catch (Exception ignored)
+                {
+                }
+                try
+                {
+                    tm.rollback();
+                } catch (Exception ignored)
+                {
+                    log.warn("Ignored", ignored);
+                }
+                throw t;
             }
-            throw t;
-         }
-      }
+        }
 
-      public void test() throws Throwable
-      {
-         try
-         {
-            p.send(m);
-         }
-         catch (JMSException expected)
-         {
-         }
-         finally
-         {
+        public void test() throws Throwable
+        {
             try
             {
-               if (c != null)
-                  c.close();
-            }
-            catch (Exception ignored)
+                p.send(m);
+            } catch (JMSException expected)
             {
+            } finally
+            {
+                try
+                {
+                    if (c != null)
+                        c.close();
+                } catch (Exception ignored)
+                {
+                }
+                try
+                {
+                    synchronized (transaction)
+                    {
+                        if (TxUtils.isActive(tm))
+                            tm.rollback();
+                        else
+                            tm.suspend();
+                    }
+                } catch (Exception ignored)
+                {
+                }
             }
+
+            tm.begin();
             try
             {
-               synchronized (transaction)
-               {
-                  if (TxUtils.isActive(tm))
-                     tm.rollback();
-                  else
-                     tm.suspend();
-               }
+                Connection c = cf.createConnection();
+                try
+                {
+                    c.start();
+                    c.createSession(true, Session.SESSION_TRANSACTED);
+                } finally
+                {
+                    try
+                    {
+                        c.close();
+                    } catch (Exception ignored)
+                    {
+                    }
+                }
+            } finally
+            {
+                tm.commit();
             }
-            catch (Exception ignored)
+        }
+    }
+
+    public class Rollback extends TestRunnable
+    {
+        public void test() throws Throwable
+        {
+            Transaction tx = transaction.get();
+            if (tx != null)
             {
+                try
+                {
+                    synchronized (transaction)
+                    {
+                        if (TxUtils.isActive(tx))
+                            tx.rollback();
+                    }
+                } catch (Exception ignored)
+                {
+                }
             }
-         }
-         
-         tm.begin();
-         try
-         {
+        }
+    }
+
+    protected void setupQueue() throws Throwable
+    {
+        log.info("setupQueue");
+        tm.begin();
+        try
+        {
             Connection c = cf.createConnection();
             try
             {
-               c.start();
-               c.createSession(true, Session.SESSION_TRANSACTED);
-            }
-            finally
+                c.start();
+                Session s = c.createSession(true, Session.SESSION_TRANSACTED);
+                MessageConsumer mc = s.createConsumer(queue);
+                while (mc.receive(WAIT) != null)
+                    ;
+                mc.close();
+
+                MessageProducer p = s.createProducer(queue);
+                Message m = s.createTextMessage("101");
+                p.send(m);
+            } finally
             {
-               try
-               {
-                  c.close();
-               }
-               catch (Exception ignored)
-               {
-               }
+                try
+                {
+                    c.close();
+                } catch (Exception ignored)
+                {
+                }
             }
-         }
-         finally
-         {
+        } finally
+        {
             tm.commit();
-         }
-      }
-   }
-   
-   public class Rollback extends TestRunnable
-   {
-      public void test() throws Throwable
-      {
-         Transaction tx = transaction.get();
-         if (tx != null)
-         {
+        }
+    }
+
+    protected void checkQueue() throws Throwable
+    {
+        log.info("checking queue");
+        tm.begin();
+        try
+        {
+            Connection c = cf.createConnection();
             try
             {
-               synchronized (transaction)
-               {
-                  if (TxUtils.isActive(tx))
-                     tx.rollback();
-               }
-            }
-            catch (Exception ignored)
+                c.start();
+                Session s = c.createSession(true, Session.SESSION_TRANSACTED);
+                MessageConsumer mc = s.createConsumer(queue);
+                Message m = mc.receive(WAIT);
+                if (m == null || m instanceof TextMessage == false)
+                    throw new RuntimeException("Expected one text message: "
+                            + m);
+                String value = ((TextMessage) m).getText();
+                if ("101".equals(value) == false)
+                    throw new RuntimeException(
+                            "Message should have text 101 got: " + value);
+                if (mc.receive(WAIT) != null)
+                    throw new RuntimeException("Did not expect two messages");
+            } catch (Throwable t)
             {
+                log.error("Error checking queue", t);
+                throw t;
+            } finally
+            {
+                try
+                {
+                    c.close();
+                } catch (Exception ignored)
+                {
+                }
             }
-         }
-      }
-   }
-   
-   protected void setupQueue() throws Throwable
-   {
-      log.info("setupQueue");
-      tm.begin();
-      try
-      {
-         Connection c = cf.createConnection();
-         try
-         {
-            c.start();
-            Session s = c.createSession(true, Session.SESSION_TRANSACTED);
-            MessageConsumer mc = s.createConsumer(queue);
-            while (mc.receive(WAIT) != null);
-            mc.close();
-            
-            MessageProducer p = s.createProducer(queue);
-            Message m = s.createTextMessage("101");
-            p.send(m);
-         }
-         finally
-         {
+        } finally
+        {
+            tm.rollback();
+        }
+    }
+
+    public class TestRunnable implements Runnable
+    {
+        public Throwable error;
+
+        public void setup() throws Throwable
+        {
+        }
+
+        public void test() throws Throwable
+        {
+        }
+
+        public void run()
+        {
             try
             {
-               c.close();
+                setup();
+            } catch (Throwable t)
+            {
+                error = t;
+                latch.countDown();
+                return;
             }
-            catch (Exception ignored)
+            latch.countDown();
+            try
             {
+                latch.await();
+            } catch (InterruptedException e)
+            {
+                log.warn("Ignored", e);
             }
-         }
-      }
-      finally
-      {
-         tm.commit();
-      }
-   }
-   
-   protected void checkQueue() throws Throwable
-   {
-      log.info("checking queue");
-      tm.begin();
-      try
-      {
-         Connection c = cf.createConnection();
-         try
-         {
-            c.start();
-            Session s = c.createSession(true, Session.SESSION_TRANSACTED);
-            MessageConsumer mc = s.createConsumer(queue);
-            Message m = mc.receive(WAIT);
-            if (m == null || m instanceof TextMessage == false)
-               throw new RuntimeException("Expected one text message: " + m);
-            String value = ((TextMessage) m).getText();
-            if ("101".equals(value) == false)
-               throw new RuntimeException("Message should have text 101 got: " + value);
-            if (mc.receive(WAIT) != null)
-               throw new RuntimeException("Did not expect two messages");
-         }
-         catch (Throwable t)
-         {
-            log.error("Error checking queue", t);
-            throw t;
-         }
-         finally
-         {
             try
             {
-               c.close();
+                test();
+            } catch (Throwable t)
+            {
+                error = t;
             }
-            catch (Exception ignored)
+        }
+    }
+
+    protected void setUp() throws Exception
+    {
+        tm = TransactionManagerLocator.getInstance().locate();
+    }
+
+    public ExecuteJMSDuringRollbackStressTestCase(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite() throws Exception
+    {
+        final String deployUnit = JMSDestinationsUtil.isJBM()?"caexecutejmsrollback.jar":"jcaexecutejmsrollbackHornetQ.jar";
+        
+        return new JBossTestSetup(new TestSuite(
+                ExecuteJMSDuringRollbackStressTestCase.class))
+        {
+            public void setUp() throws Exception
             {
+                super.setUp();
+                JMSDestinationsUtil.setupBasicDestinations();
+                deploy(deployUnit);
+
             }
-         }
-      }
-      finally
-      {
-         tm.rollback();
-      }
-   }
-   
-   public class TestRunnable implements Runnable
-   {
-      public Throwable error;
-      
-      public void setup() throws Throwable
-      {
-      }
-      
-      public void test() throws Throwable
-      {
-      }
-      
-      public void run()
-      {
-         try
-         {
-            setup();
-         }
-         catch (Throwable t)
-         {
-            error = t;
-            latch.countDown();
-            return;
-         }
-         latch.countDown();
-         try
-         {
-            latch.await();
-         }
-         catch (InterruptedException e)
-         {
-            log.warn("Ignored", e);
-         }
-         try
-         {
-            test();
-         }
-         catch (Throwable t)
-         {
-            error = t;
-         }
-      }
-   }
-   
-   protected void setUp() throws Exception
-   {
-      tm = TransactionManagerLocator.getInstance().locate();
-   }
-   
-   public ExecuteJMSDuringRollbackStressTestCase(String name)
-   {
-      super(name);
-   }
 
-   public static Test suite() throws Exception
-   {
-      return new JBossTestSetup(new TestSuite(ExecuteJMSDuringRollbackStressTestCase.class))
-      {
-         public void setUp() throws Exception
-         {
-            super.setUp();
-            JMSDestinationsUtil.setupBasicDestinations();
-            deploy("jcaexecutejmsrollback.jar");
-            
-         }
-         
-         public void tearDown() throws Exception
-         {
-            undeploy("jcaexecutejmsrollback.jar");
-            JMSDestinationsUtil.destroyDestinations();
-         }
-      };
-      
-   }
+            public void tearDown() throws Exception
+            {
+                undeploy(deployUnit);
+                JMSDestinationsUtil.destroyDestinations();
+            }
+        };
+
+    }
 }

Added: branches/JBPAPP_5_1/testsuite/src/resources/jca/executejmsrollbackhornetq/test-jms-local-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jca/executejmsrollbackhornetq/test-jms-local-ds.xml	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jca/executejmsrollbackhornetq/test-jms-local-ds.xml	2010-06-08 17:31:20 UTC (rev 105809)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+	<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="hornetq:service=JMSProviderLoader,name=JMSProviderTest">
+		<attribute name="ProviderName">TestJMSLocalProvider</attribute>
+		<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter
+		</attribute>
+		<attribute name="FactoryRef">java:/ConnectionFactory</attribute>
+		<attribute name="QueueFactoryRef">java:/ConnectionFactory</attribute>
+		<attribute name="TopicFactoryRef">java:/ConnectionFactory</attribute>
+	</mbean>
+
+	<tx-connection-factory>
+		<jndi-name>TestJmsLocal</jndi-name>
+		<rar-name>jms-ra.rar</rar-name>
+		<connection-definition>org.hornetq.ra.HornetQRAConnectionFactory
+		</connection-definition>
+		<config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic
+		</config-property>
+		<config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/TestJMSLocalProvider
+		</config-property>
+		<max-pool-size>20</max-pool-size>
+	</tx-connection-factory>
+
+
+</connection-factories>



More information about the jboss-cvs-commits mailing list