[jboss-cvs] JBossAS SVN: r63157 - branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 18 15:50:04 EDT 2007


Author: bdecoste
Date: 2007-05-18 15:50:04 -0400 (Fri, 18 May 2007)
New Revision: 63157

Modified:
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java
Log:
[EJBTHREE-635] test for concurrent getInvokedBusinessInterface and getBusinessObject

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java	2007-05-18 19:14:12 UTC (rev 63156)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java	2007-05-18 19:50:04 UTC (rev 63157)
@@ -62,6 +62,58 @@
       stateless.testSessionContext();
    }
    
+   public void testConcurrentInvokedBusinessInterface() throws Exception
+   {   
+      for (int i = 0 ; i < 100 ; ++i)
+      {
+         Runnable r = new Runnable()
+         {
+            public void run()
+            {
+               try
+               {
+                  Stateless stateless1 = (Stateless)getInitialContext().lookup("Stateless");
+                  Stateless stateless2 = (Stateless)getInitialContext().lookup("Stateless");
+                  
+                  Class interfc = stateless1.testInvokedBusinessInterface();
+                  assertEquals(interfc, Stateless.class);
+                  
+                  interfc = stateless2.testInvokedBusinessInterface();
+                  assertEquals(interfc, Stateless.class);
+                  
+                  Stateless stateless = (Stateless)stateless1.testBusinessObject(Stateless.class);
+                  stateless.noop();
+      
+                  assertEquals(interfc, Stateless.class);
+                  
+                  try{
+                     stateless1.testBusinessObject(Stateful.class);
+                     fail("IllegalStateException not thrown");
+                  }
+                  catch (javax.ejb.EJBException e)
+                  {
+                     if (!(e.getCause() instanceof IllegalStateException)) throw e;
+                     assertEquals(IllegalStateException.class, e.getCause().getClass());
+                  }
+                  
+                  stateless1.testEjbObject();
+                  
+                  stateless1.testEjbLocalObject();
+               }
+               catch (Exception e)
+               {
+                  e.printStackTrace();
+                  fail("caught exception " + e);
+               }
+            }
+         };
+         
+         new Thread(r).start();
+      }
+      
+      Thread.sleep(5 * 1000);
+   }
+   
    public void testStatelessInvokedBusinessInterface() throws Exception
    {
       Stateless stateless1 = (Stateless)getInitialContext().lookup("Stateless");




More information about the jboss-cvs-commits mailing list