[jboss-cvs] JBossAS SVN: r109547 - in trunk/testsuite/src/main/org/jboss/test/ejb3/async: test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 29 16:23:20 EST 2010


Author: ALRubinger
Date: 2010-11-29 16:23:19 -0500 (Mon, 29 Nov 2010)
New Revision: 109547

Modified:
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterBean.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterCommonBusiness.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java
Log:
[EJBTHREE-1721] Expose further @Async failures

Modified: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java	2010-11-29 21:21:48 UTC (rev 109546)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java	2010-11-29 21:23:19 UTC (rev 109547)
@@ -14,7 +14,16 @@
 public class AsyncBean implements AsyncCommonBusiness
 {
     @Asynchronous
-    public Future<String> getExecutingThreadName() {
-        return new AsyncResult<String>(Thread.currentThread().getName());
+    public Future<String> getExecutingThreadNameAsync() {
+        return this.getExecutingThreadName();
     }
+
+    public Future<String> getExecutingThreadNameBlocking() {
+        return this.getExecutingThreadName();
+    }
+
+    private Future<String> getExecutingThreadName(){
+      return new AsyncResult<String>(Thread.currentThread().getName());
+    }
+    
 }

Modified: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java	2010-11-29 21:21:48 UTC (rev 109546)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java	2010-11-29 21:23:19 UTC (rev 109547)
@@ -39,5 +39,12 @@
      *
      * @return
      */
-    Future<String> getExecutingThreadName();
+    Future<String> getExecutingThreadNameAsync();
+
+    /**
+     * Returns the Thread of execution for this invocation
+     *
+     * @return
+     */
+    Future<String> getExecutingThreadNameBlocking();
 }
\ No newline at end of file

Modified: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterBean.java	2010-11-29 21:21:48 UTC (rev 109546)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterBean.java	2010-11-29 21:23:19 UTC (rev 109547)
@@ -21,7 +21,12 @@
  */
 package org.jboss.test.ejb3.async;
 
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase;
+
 import javax.ejb.*;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
 import java.util.logging.Logger;
 
 /**
@@ -62,11 +67,11 @@
      *
      * @return
      */
-    public boolean isLocalInvocationExecutedInNewThread() {
+    public boolean isLocalAsyncInvocationExecutedInNewThread() {
         final String current = Thread.currentThread().getName();
         final String used;
         try{
-            used = local.getExecutingThreadName().get();
+            used = local.getExecutingThreadNameAsync().get();
         }
         catch(final Exception e){
             throw new RuntimeException(e);
@@ -79,11 +84,11 @@
      * 
      * @return
      */
-    public boolean isRemoteInvocationExecutedInNewThread() {
+    public boolean isRemoteAsyncInvocationExecutedInNewThread() {
         final String current = Thread.currentThread().getName();
         final String used;
         try{
-            used = remote.getExecutingThreadName().get();
+            used = remote.getExecutingThreadNameAsync().get();
         }
         catch(final Exception e){
             throw new RuntimeException(e);
@@ -91,4 +96,17 @@
         log.info("Remote @Asynchronous Invocation - Current:" + current + ", Used: " + used);
         return !current.equals(used);
     }
+
+    public boolean isLocalBlockingInvocationExecutedInSameThread(){
+                 final String current = Thread.currentThread().getName();
+        final String used;
+        try{
+            used = local.getExecutingThreadNameBlocking().get();
+        }
+        catch(final Exception e){
+            throw new RuntimeException(e);
+        }
+        log.info("Local non- at Asynchronous Invocation - Current:" + current + ", Used: " + used);
+        return current.equals(used);
+    }
 }
\ No newline at end of file

Modified: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterCommonBusiness.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterCommonBusiness.java	2010-11-29 21:21:48 UTC (rev 109546)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterCommonBusiness.java	2010-11-29 21:23:19 UTC (rev 109547)
@@ -37,10 +37,17 @@
    /**
     * Returns whether or not a local invocation is executed in a new Thread
     */
-   boolean isLocalInvocationExecutedInNewThread();
+   boolean isLocalAsyncInvocationExecutedInNewThread();
 
    /**
     * Returns whether or not a remote invocation is executed in a new Thread
     */
-   boolean isRemoteInvocationExecutedInNewThread();
+   boolean isRemoteAsyncInvocationExecutedInNewThread();
+
+    /**
+     * Returns whether a Future return type on a non-Asynchronous
+     * method is executed within the same Thread
+     * @return
+     */
+   boolean isLocalBlockingInvocationExecutedInSameThread();
 }
\ No newline at end of file

Modified: trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java	2010-11-29 21:21:48 UTC (rev 109546)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java	2010-11-29 21:23:19 UTC (rev 109547)
@@ -23,11 +23,11 @@
 
 import junit.framework.Assert;
 import junit.framework.Test;
+import org.jboss.logging.Logger;
 import org.jboss.test.JBossTestCase;
 import org.jboss.test.ejb3.async.AsyncTesterCommonBusiness;
 
 import javax.naming.InitialContext;
-import java.util.concurrent.Future;
 
 /**
  * Test Cases to ensure the EJB 3.1 implementation of the @Asynchronous
@@ -38,6 +38,9 @@
 public class AsyncSessionBeanUnitTestCase
    extends JBossTestCase
 {
+
+   private static final Logger log = Logger.getLogger(AsyncSessionBeanUnitTestCase.class);
+
    public static Test suite() throws Exception
    {
       return getDeploySetup(AsyncSessionBeanUnitTestCase.class, "ejb31-async.jar");
@@ -52,16 +55,21 @@
       throws Exception
    {
       final AsyncTesterCommonBusiness bean = this.getTesterBean();
-      Assert.assertTrue("Remote invocation not executed in new Thread",bean.isRemoteInvocationExecutedInNewThread());
+       Assert.assertTrue("Remote invocation not executed in new Thread",bean.isRemoteAsyncInvocationExecutedInNewThread());
    }
 
    public void testLocalAsyncInvocation()
       throws Exception
    {
       final AsyncTesterCommonBusiness bean = this.getTesterBean();
-      Assert.assertTrue("Local invocation not executed in new Thread",bean.isLocalInvocationExecutedInNewThread());
+      Assert.assertTrue("Local invocation not executed in new Thread",bean.isLocalAsyncInvocationExecutedInNewThread());
    }
 
+   public void testLocalBlockingInvocation() throws Exception{
+      final AsyncTesterCommonBusiness bean = this.getTesterBean();
+      Assert.assertTrue("Local non-async invocation not executed in same Thread",bean.isLocalBlockingInvocationExecutedInSameThread()); 
+   }
+
    private AsyncTesterCommonBusiness getTesterBean() throws Exception {
       final InitialContext ctx = getInitialContext();
       final String jndiName = "AsyncTesterBean/remote";



More information about the jboss-cvs-commits mailing list