[jboss-cvs] JBossAS SVN: r75554 - in projects/ejb3/trunk/testsuite: src/test/java/org/jboss/ejb3/test and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 9 11:44:43 EDT 2008


Author: pferraro
Date: 2008-07-09 11:44:43 -0400 (Wed, 09 Jul 2008)
New Revision: 75554

Added:
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/MyStateful.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/MyStatefulBean.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/unit/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/unit/ContainerShutdownTestCase.java
Modified:
   projects/ejb3/trunk/testsuite/build-test.xml
   projects/ejb3/trunk/testsuite/src/test/resources/testrunner-config/jbossas_configuration-ejb3_test-bindings.xml
Log:
[EJBTHREE-1116] Test case reproducing occasional NoSuchEJBException when StatefulContainer is stopped during concurrent EJB request

Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml	2008-07-09 15:23:51 UTC (rev 75553)
+++ projects/ejb3/trunk/testsuite/build-test.xml	2008-07-09 15:44:43 UTC (rev 75554)
@@ -2386,6 +2386,10 @@
       <build-simple-jar name="ejbthree1082"/>
    </target>
 	
+   <target name="ejbthree1116" >
+      <build-simple-jar name="ejbthree1116"/>
+   </target>
+	
    <target name="ejbthree1119" >
       <build-simple-jar name="ejbthree1119"/>
    </target>
@@ -4209,7 +4213,7 @@
       ejbthree989, ejbthree994, ejbthree1020, ejbthree1023, ejbthree1025, ejbthree1040,
       ejbthree1057, ejbthree1059, ejbthree1060,
       ejbthree1062,
-      ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
+      ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1116, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
       ejbthree1130, 
       ejbthree1146, ejbthree1148, ejbthree1154, ejbthree1155, ejbthree1157, ejbthree1222, ejbthree1271, ejbthree1339,
    	  jaxws, jbas4489, epcpropagation, aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
@@ -4983,6 +4987,9 @@
          <param name="test" value="ejbthree1082"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree1116"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="ejbthree1119"/>
       </antcall>
       <antcall target="test" inheritRefs="true">

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/MyStateful.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/MyStateful.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/MyStateful.java	2008-07-09 15:44:43 UTC (rev 75554)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.ejbthree1116;
+
+import javax.ejb.Remote;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+ at Remote
+public interface MyStateful
+{
+   public int getCount();
+   public void increment();
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/MyStatefulBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/MyStatefulBean.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/MyStatefulBean.java	2008-07-09 15:44:43 UTC (rev 75554)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.ejbthree1116;
+
+import javax.ejb.Stateful;
+
+/**
+ * @author Paul Ferraro
+ */
+ at Stateful
+public class MyStatefulBean implements MyStateful
+{
+   private int count;
+   
+   public int getCount()
+   {
+      return this.count;
+   }
+   
+   public void increment()
+   {
+      this.count++;
+   }
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/unit/ContainerShutdownTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/unit/ContainerShutdownTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1116/unit/ContainerShutdownTestCase.java	2008-07-09 15:44:43 UTC (rev 75554)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.ejbthree1116.unit;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.concurrent.CountDownLatch;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.aop.DispatcherConnectException;
+import org.jboss.ejb3.test.ejbthree1116.MyStateful;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test verifying fix of EJBTHREE-1116.
+ * @author Paul Ferraro
+ */
+public class ContainerShutdownTestCase extends JBossTestCase
+{
+   private static final String JAR = "ejbthree1116.jar";
+   
+   /**
+    * Create a new ContainerShutdownTestCase.
+    * 
+    * @param name
+    */
+   public ContainerShutdownTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testSimple() throws Exception
+   {
+      MyStateful bean = (MyStateful) new InitialContext().lookup("MyStatefulBean/remote");
+      
+      this.undeploy(JAR);
+      
+      try
+      {
+         bean.increment();
+      }
+      catch (UndeclaredThrowableException e)
+      {
+         assertInstanceOf(e.getUndeclaredThrowable(), DispatcherConnectException.class);
+      }
+      catch (Exception e)
+      {
+         this.log.error(e.getMessage(), e);
+         
+         assertTrue(e.toString(), false);
+      }
+      finally
+      {
+         this.deploy(JAR);
+      }
+   }
+
+   public void testConcurrent() throws Exception
+   {
+      MyStateful bean = (MyStateful) new InitialContext().lookup("MyStatefulBean/remote");
+      
+      CountDownLatch latch = new CountDownLatch(2);
+      
+      Thread thread = new Thread(new Undeployer(latch));
+      
+      thread.start();
+      
+      latch.countDown();
+      
+      try
+      {
+         latch.await();
+         
+         while (!Thread.currentThread().isInterrupted())
+         {
+            bean.increment();
+         }
+         
+         this.log.warn("Test was interrupted");
+      }
+      catch (InterruptedException e)
+      {
+         this.log.warn("Test was interrupted");
+      }
+      catch (Exception e)
+      {
+         this.log.error(e.getMessage(), e);
+         
+         assertInstanceOf(e, UndeclaredThrowableException.class);
+         
+         assertInstanceOf(((UndeclaredThrowableException) e).getUndeclaredThrowable(), DispatcherConnectException.class);
+      }
+      finally
+      {
+         try
+         {
+            thread.join();
+            
+            this.deploy(JAR);
+         }
+         catch (InterruptedException e)
+         {
+            Thread.currentThread().interrupt();
+         }
+      }
+   }
+   
+   private class Undeployer implements Runnable
+   {
+      private CountDownLatch latch;
+      
+      public Undeployer(CountDownLatch latch)
+      {
+         this.latch = latch;
+      }
+      
+      public void run()
+      {
+         try
+         {
+            this.latch.countDown();
+            this.latch.await();
+
+            ContainerShutdownTestCase.this.undeploy(JAR);
+         }
+         catch (InterruptedException e)
+         {
+            Thread.currentThread().interrupt();
+         }
+         catch (Exception e)
+         {
+            ContainerShutdownTestCase.this.log.error(e.getMessage(), e);
+         }
+      }
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(ContainerShutdownTestCase.class, JAR);
+   }
+}

Modified: projects/ejb3/trunk/testsuite/src/test/resources/testrunner-config/jbossas_configuration-ejb3_test-bindings.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/testrunner-config/jbossas_configuration-ejb3_test-bindings.xml	2008-07-09 15:23:51 UTC (rev 75553)
+++ projects/ejb3/trunk/testsuite/src/test/resources/testrunner-config/jbossas_configuration-ejb3_test-bindings.xml	2008-07-09 15:44:43 UTC (rev 75554)
@@ -144,6 +144,7 @@
         <test name="ejbthree1071" />
         <test name="ejbthree1075" />
         <test name="ejbthree1082" />
+        <test name="ejbthree1116" />
         <test name="ejbthree1119" />
         <test name="ejbthree1122" />
         <test name="ejbthree1123" />




More information about the jboss-cvs-commits mailing list