[jboss-cvs] JBossAS SVN: r106494 - in branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite: ejb3 and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 7 19:47:25 EDT 2010


Author: ALRubinger
Date: 2010-07-07 19:47:24 -0400 (Wed, 07 Jul 2010)
New Revision: 106494

Added:
   branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/
   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/AsyncLocalBusiness.java
Modified:
   branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java
Log:
[EJBTHREE-1721] Add a simple EJB 3.1 @Asynchronous test (now passing, but it is not really going async ATM)

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-07 23:13:33 UTC (rev 106493)
+++ branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ServerIntegrationTest.java	2010-07-07 23:47:24 UTC (rev 106494)
@@ -29,6 +29,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.logging.Logger;
@@ -59,6 +60,8 @@
 import org.jboss.ejb3.embedded.api.JBossEJBContainer;
 import org.jboss.embedded.api.server.JBossASEmbeddedServer;
 import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
+import org.jboss.jbossas.embedded.testsuite.ejb3.async.AsyncBean;
+import org.jboss.jbossas.embedded.testsuite.ejb3.async.AsyncLocalBusiness;
 import org.jboss.jbossas.embedded.testsuite.ejb3.entity.Jbossian;
 import org.jboss.jbossas.embedded.testsuite.ejb3.entity.JbossianRegistrarBean;
 import org.jboss.jbossas.embedded.testsuite.ejb3.entity.JbossianRegistrarLocalBusiness;
@@ -288,6 +291,46 @@
    }
 
    /**
+    * Tests EJB3 3.1 @Asynchronous support
+    */
+   @Test
+   public void testEjb31Async() throws Exception
+   {
+      // Log
+      log.info("testEjb31Async");
+
+      // Make a deployment
+      final String name = "ejb31async.jar";
+      final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, name).addPackage(
+            AsyncLocalBusiness.class.getPackage());
+      log.info(archive.toString(true));
+      // Deploy
+      server.deploy(archive);
+
+      // Test
+      try
+      {
+         final AsyncLocalBusiness bean = (AsyncLocalBusiness) NAMING_CONTEXT.lookup(AsyncBean.class.getSimpleName()
+               + JNDI_SUFFIX_LOCAL_BUSINESS);
+         final Future<Integer> invocation = bean.getNextCounter();
+
+         // Block and test
+         final int value = invocation.get();
+         Assert.assertEquals("First 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());
+      }
+      finally
+      {
+         // Undeploy
+         server.undeploy(archive);
+      }
+
+   }
+
+   /**
     * Tests deployment of a virtual WAR containing a servlet 
     * and JSP.
     * 

Added: 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	                        (rev 0)
+++ branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/AsyncBean.java	2010-07-07 23:47:24 UTC (rev 106494)
@@ -0,0 +1,64 @@
+/*
+ * 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.jbossas.embedded.testsuite.ejb3.async;
+
+import java.util.concurrent.Future;
+
+import javax.ejb.AsyncResult;
+import javax.ejb.Asynchronous;
+import javax.ejb.Local;
+import javax.ejb.Stateful;
+
+/**
+ * Stateful implementation of an EJB w/ Asynchronous methods
+ * 
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+ at Stateful
+ at Local(AsyncLocalBusiness.class)
+public class AsyncBean implements AsyncLocalBusiness
+{
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Counter
+    */
+   private int current;
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.jbossas.embedded.testsuite.ejb3.async.AsyncLocalBusiness#getNextCounter()
+    */
+   @Asynchronous
+   @Override
+   public Future<Integer> getNextCounter()
+   {
+      return new AsyncResult<Integer>(++current);
+   }
+
+}

Added: branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/AsyncLocalBusiness.java
===================================================================
--- branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/AsyncLocalBusiness.java	                        (rev 0)
+++ branches/TEMP_ALR_JBAS-8146_ASYNC_EJB3_INTEGRATION/embedded/src/test/java/org/jboss/jbossas/embedded/testsuite/ejb3/async/AsyncLocalBusiness.java	2010-07-07 23:47:24 UTC (rev 106494)
@@ -0,0 +1,42 @@
+/*
+ * 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.jbossas.embedded.testsuite.ejb3.async;
+
+import java.util.concurrent.Future;
+
+/**
+ * Local business view of a bean with asynchronous methods
+ * 
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public interface AsyncLocalBusiness
+{
+   // --------------------------------------------------------------------------------||
+   // Contracts ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Returns the next count in a series, starting with 1 and incrementing
+    * on subsequent invocations
+    */
+   Future<Integer> getNextCounter();
+}



More information about the jboss-cvs-commits mailing list