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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 23 12:38:12 EST 2010


Author: ALRubinger
Date: 2010-11-23 12:38:11 -0500 (Tue, 23 Nov 2010)
New Revision: 109432

Added:
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncLocalBusiness.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncRemoteBusiness.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterBean.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterCommonBusiness.java
Removed:
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java
Modified:
   trunk/testsuite/pom.xml
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java
Log:
[EJBTHREE-1721] Better expose remote @Asynchronous failures in the testsuite

Modified: trunk/testsuite/pom.xml
===================================================================
--- trunk/testsuite/pom.xml	2010-11-23 14:00:03 UTC (rev 109431)
+++ trunk/testsuite/pom.xml	2010-11-23 17:38:11 UTC (rev 109432)
@@ -13,6 +13,10 @@
   <name>JBoss Application Server Testsuite</name>
   <url>http://www.jboss.org/jbossas</url>
   <description>JBoss Application Server Testsuite</description>
+  
+  <build>
+    <sourceDirectory>src/main</sourceDirectory>
+  </build>
     
   <!-- 
     -  This pom lists dependencies used in the testsuite which are not included in the

Deleted: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java	2010-11-23 14:00:03 UTC (rev 109431)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java	2010-11-23 17:38:11 UTC (rev 109432)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.test.ejb3.async;
-
-import javax.ejb.*;
-import java.util.concurrent.*;
-import java.util.logging.Logger;
-
-/**
- * Stateful implementation of an EJB w/ Asynchronous methods
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- */
- at Stateful
- at Remote(AsyncCommonBusiness.class)
-public class AsyncBean implements AsyncCommonBusiness
-{
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Logger
-    */
-   private static final Logger log = Logger.getLogger(AsyncBean.class.getName());
-
-   // --------------------------------------------------------------------------------||
-   // Instance Members ---------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Counter
-    */
-   private int current;
-
-   // --------------------------------------------------------------------------------||
-   // Required Implementations -------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * {@inheritDoc}
-    * @see org.jboss.jbossas.embedded.testsuite.ejb3.async.AsyncLocalBusiness#getNextCounter()
-    */
-   @Asynchronous
-   public Future<Integer> getNextCounter()
-   {
-      // Return
-      return new AsyncResult<Integer>(++current);
-   }
-
-}
\ No newline at end of file

Deleted: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java	2010-11-23 14:00:03 UTC (rev 109431)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java	2010-11-23 17:38:11 UTC (rev 109432)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.test.ejb3.async;
-
-import java.util.concurrent.Future;
-
-/**
- * Business view of a bean with asynchronous methods
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- */
-public interface AsyncCommonBusiness
-{
-   // --------------------------------------------------------------------------------||
-   // Contracts ----------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Returns the next count in a series, starting with 1 and incrementing
-    * on subsequent invocations
-    */
-   Future<Integer> getNextCounter();
-}
\ No newline at end of file

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncLocalBusiness.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncLocalBusiness.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncLocalBusiness.java	2010-11-23 17:38:11 UTC (rev 109432)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.test.ejb3.async;
+
+/**
+ * Local business view of a bean with asynchronous methods
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public interface AsyncLocalBusiness extends AsyncCommonBusiness
+{
+}
\ No newline at end of file

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncRemoteBusiness.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncRemoteBusiness.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncRemoteBusiness.java	2010-11-23 17:38:11 UTC (rev 109432)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.test.ejb3.async;
+
+/**
+ * Remote business view of a bean with asynchronous methods
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public interface AsyncRemoteBusiness extends AsyncCommonBusiness
+{
+}
\ No newline at end of file

Copied: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterBean.java (from rev 109393, trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterBean.java	2010-11-23 17:38:11 UTC (rev 109432)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.test.ejb3.async;
+
+import javax.ejb.*;
+import java.util.logging.Logger;
+
+/**
+ * EJB Used to test @Asynchronous support by comparing the name
+ * of the current Thread with the one used to execute the
+ * invocation.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+ at Stateless
+ at Remote(AsyncTesterCommonBusiness.class)
+public class AsyncTesterBean implements AsyncTesterCommonBusiness
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(AsyncTesterBean.class.getName());
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   @EJB
+   private AsyncLocalBusiness local;
+
+   @EJB
+   private AsyncRemoteBusiness remote;
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+    /**
+     *
+     * @return
+     */
+    public boolean isLocalInvocationExecutedInNewThread() {
+        final String current = Thread.currentThread().getName();
+        final String used;
+        try{
+            used = local.getExecutingThreadName().get();
+        }
+        catch(final Exception e){
+            throw new RuntimeException(e);
+        }
+        log.info("Local @Asynchronous Invocation - Current:" + current + ", Used: " + used);
+        return !current.equals(used);
+    }
+
+    /**
+     * 
+     * @return
+     */
+    public boolean isRemoteInvocationExecutedInNewThread() {
+        final String current = Thread.currentThread().getName();
+        final String used;
+        try{
+            used = remote.getExecutingThreadName().get();
+        }
+        catch(final Exception e){
+            throw new RuntimeException(e);
+        }
+        log.info("Remote @Asynchronous Invocation - Current:" + current + ", Used: " + used);
+        return !current.equals(used);
+    }
+}
\ No newline at end of file

Copied: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterCommonBusiness.java (from rev 109393, trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterCommonBusiness.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncTesterCommonBusiness.java	2010-11-23 17:38:11 UTC (rev 109432)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.test.ejb3.async;
+
+import java.util.concurrent.Future;
+
+/**
+ * Business view of a bean which tests @Asynchronous calls
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public interface AsyncTesterCommonBusiness
+{
+   // --------------------------------------------------------------------------------||
+   // Contracts ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Returns whether or not a local invocation is executed in a new Thread
+    */
+   boolean isLocalInvocationExecutedInNewThread();
+
+   /**
+    * Returns whether or not a remote invocation is executed in a new Thread
+    */
+   boolean isRemoteInvocationExecutedInNewThread();
+}
\ 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-23 14:00:03 UTC (rev 109431)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java	2010-11-23 17:38:11 UTC (rev 109432)
@@ -24,8 +24,7 @@
 import junit.framework.Assert;
 import junit.framework.Test;
 import org.jboss.test.JBossTestCase;
-import org.jboss.test.ejb3.async.AsyncCommonBusiness;
-import org.jboss.test.ejb3.basic.SimpleSession;
+import org.jboss.test.ejb3.async.AsyncTesterCommonBusiness;
 
 import javax.naming.InitialContext;
 import java.util.concurrent.Future;
@@ -41,8 +40,7 @@
 {
    public static Test suite() throws Exception
    {
-      Test t1 = getDeploySetup(AsyncSessionBeanUnitTestCase.class, "ejb31-async.jar");
-      return t1;
+      return getDeploySetup(AsyncSessionBeanUnitTestCase.class, "ejb31-async.jar");
    }
 
    public AsyncSessionBeanUnitTestCase(String name)
@@ -53,19 +51,22 @@
    public void testRemoteAsyncInvocation()
       throws Exception
    {
-      InitialContext ctx = getInitialContext();
-      String jndiName = "AsyncBean/remote";
-      Object ref = ctx.lookup(jndiName);
-      AsyncCommonBusiness bean = (AsyncCommonBusiness) ref;
-      final Future<Integer> invocation =bean.getNextCounter();
+      final AsyncTesterCommonBusiness bean = this.getTesterBean();
+      Assert.assertTrue("Remote invocation not executed in new Thread",bean.isRemoteInvocationExecutedInNewThread());
+   }
 
-         // Block and test
-         final int value = invocation.get();
-         Assert.assertEquals("Invocation did not return correct result", 1, value);
-         log.info("Got: " + invocation);
-         log.info("Invocation value: " + value);
-         Assert.assertTrue("First invocation did not report as completed", invocation.isDone());
-         Assert.assertFalse("Invocation should not report as cancelled", invocation.isCancelled());
+   public void testLocalAsyncInvocation()
+      throws Exception
+   {
+      final AsyncTesterCommonBusiness bean = this.getTesterBean();
+      Assert.assertTrue("Local invocation not executed in new Thread",bean.isLocalInvocationExecutedInNewThread());
+   }
 
+   private AsyncTesterCommonBusiness getTesterBean() throws Exception {
+      final InitialContext ctx = getInitialContext();
+      final String jndiName = "AsyncTesterBean/remote";
+      final Object ref = ctx.lookup(jndiName);
+      final AsyncTesterCommonBusiness bean = (AsyncTesterCommonBusiness) ref;
+      return bean;
    }
 }
\ No newline at end of file



More information about the jboss-cvs-commits mailing list