[jboss-cvs] JBossAS SVN: r106628 - in branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite: ejb3/async and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 13 11:32:38 EDT 2010
Author: ALRubinger
Date: 2010-07-13 11:32:38 -0400 (Tue, 13 Jul 2010)
New Revision: 106628
Modified:
branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java
branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/AsyncBean.java
Log:
[JBAS-8146] Strengthen the EJB 3.1 async test to ensure that we actually dispatch to another Thread
Modified: branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java
===================================================================
--- branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java 2010-07-13 15:10:31 UTC (rev 106627)
+++ branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java 2010-07-13 15:32:38 UTC (rev 106628)
@@ -29,12 +29,12 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
-import javax.ejb.AsyncResult;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
@@ -314,6 +314,26 @@
final AsyncLocalBusiness bean = (AsyncLocalBusiness) NAMING_CONTEXT.lookup(AsyncBean.class.getSimpleName()
+ JNDI_SUFFIX_LOCAL_BUSINESS);
final Future<Integer> invocation = bean.getNextCounter();
+
+ // Signal to the bean we're here (to ensure this is an async invocation)
+ try
+ {
+ AsyncBean.BARRIER.await(10, TimeUnit.SECONDS);
+ log.info("Barrier met by all parties");
+ }
+ catch (final InterruptedException e)
+ {
+ Thread.interrupted();
+ Assert.fail("Interrupted while waiting");
+ }
+ catch (BrokenBarrierException e)
+ {
+ Assert.fail("Barrier was broken while waiting: " + e);
+ }
+ catch (TimeoutException e)
+ {
+ Assert.fail("All parties did not arrive at the barrier in the specified time:" + e);
+ }
// Block and test
final int value = invocation.get();
@@ -322,8 +342,6 @@
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());
- Assert.assertFalse("Invocation was not intercepted as async and was returned as normal",
- invocation instanceof AsyncResult<?>);
}
finally
{
Modified: branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/AsyncBean.java
===================================================================
--- branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/AsyncBean.java 2010-07-13 15:10:31 UTC (rev 106627)
+++ branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/AsyncBean.java 2010-07-13 15:32:38 UTC (rev 106628)
@@ -21,7 +21,12 @@
*/
package org.jboss.jbossas.embedded.testsuite.ejb3.async;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.logging.Logger;
import javax.ejb.AsyncResult;
import javax.ejb.Asynchronous;
@@ -38,6 +43,20 @@
public class AsyncBean implements AsyncLocalBusiness
{
// --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(AsyncBean.class.getName());
+
+ /**
+ * Shared blocking point for test/bean communication
+ */
+ public static CyclicBarrier BARRIER = new CyclicBarrier(2);
+
+ // --------------------------------------------------------------------------------||
// Instance Members ---------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -58,6 +77,27 @@
@Override
public Future<Integer> getNextCounter()
{
+ // Wait for the test to be here too
+ try
+ {
+ BARRIER.await(10, TimeUnit.SECONDS);
+ log.info("Barrier met by all parties");
+ }
+ catch (final InterruptedException e)
+ {
+ Thread.interrupted();
+ throw new RuntimeException("Interrupted during waiting", e);
+ }
+ catch (BrokenBarrierException e)
+ {
+ throw new RuntimeException("Barrier was broken while waiting", e);
+ }
+ catch (TimeoutException e)
+ {
+ throw new RuntimeException("All parties did not arrive at the barrier in the specified time", e);
+ }
+
+ // Return
return new AsyncResult<Integer>(++current);
}
More information about the jboss-cvs-commits
mailing list