[jboss-cvs] JBossAS SVN: r106853 - in trunk/testsuite: imports/sections and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 19 15:40:07 EDT 2010


Author: ALRubinger
Date: 2010-07-19 15:40:07 -0400 (Mon, 19 Jul 2010)
New Revision: 106853

Added:
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/
   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/test/
   trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java
Modified:
   trunk/testsuite/imports/sections/ejb3.xml
   trunk/testsuite/pom.xml
   trunk/testsuite/src/resources/log4j.xml
Log:
[JBAS-8146] Add an @Asynchronous integration test to AS

Modified: trunk/testsuite/imports/sections/ejb3.xml
===================================================================
--- trunk/testsuite/imports/sections/ejb3.xml	2010-07-19 19:36:46 UTC (rev 106852)
+++ trunk/testsuite/imports/sections/ejb3.xml	2010-07-19 19:40:07 UTC (rev 106853)
@@ -193,11 +193,17 @@
    		   </jar>
    </target>
 
+   <target name="ejb31async" depends="compile">
+      <mkdir dir="${build.lib}" />
+      <jar destfile="${build.lib}/ejb31-async.jar">
+         <fileset dir="${build.classes}" includes="org/jboss/test/ejb3/async/*"/>
+      </jar>
+   </target>
 
    <target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,
       jbas7526,
       jbas7556,
-      ejbthree1597,ejbthree7376, jboss51xsd, ejb31nointerface, ejb3war, jbpapp3026, ejb31singleton">
+      ejbthree1597,ejbthree7376, jboss51xsd, ejb31nointerface, ejb3war, jbpapp3026, ejb31singleton,ejb31async">
       <mkdir dir="${build.lib}" />
 
       <!-- A jar with a simple ejb3 session -->

Modified: trunk/testsuite/pom.xml
===================================================================
--- trunk/testsuite/pom.xml	2010-07-19 19:36:46 UTC (rev 106852)
+++ trunk/testsuite/pom.xml	2010-07-19 19:40:07 UTC (rev 106853)
@@ -13,7 +13,7 @@
   <name>JBoss Application Server Testsuite</name>
   <url>http://www.jboss.org/jbossas</url>
   <description>JBoss Application Server Testsuite</description>
-
+    
   <!-- 
     -  This pom lists dependencies used in the testsuite which are not included in the
     -  application server distribution build.

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncBean.java	2010-07-19 19:40:07 UTC (rev 106853)
@@ -0,0 +1,70 @@
+/*
+ * 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

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/AsyncCommonBusiness.java	2010-07-19 19:40:07 UTC (rev 106853)
@@ -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.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/test/AsyncSessionBeanUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/async/test/AsyncSessionBeanUnitTestCase.java	2010-07-19 19:40:07 UTC (rev 106853)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.test;
+
+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 javax.naming.InitialContext;
+import java.util.concurrent.Future;
+
+/**
+ * Test Cases to ensure the EJB 3.1 implementation of the @Asynchronous
+ * feature is working as expected
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+//TODO Move this to the EJB 3.1 Integration TestSuite when it becomes available
+public class AsyncSessionBeanUnitTestCase
+   extends JBossTestCase
+{
+   public static Test suite() throws Exception
+   {
+      Test t1 = getDeploySetup(AsyncSessionBeanUnitTestCase.class, "ejb31-async.jar");
+      return t1;
+   }
+
+   public AsyncSessionBeanUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   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();
+
+         // 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());
+
+   }
+}
\ No newline at end of file

Modified: trunk/testsuite/src/resources/log4j.xml
===================================================================
--- trunk/testsuite/src/resources/log4j.xml	2010-07-19 19:36:46 UTC (rev 106852)
+++ trunk/testsuite/src/resources/log4j.xml	2010-07-19 19:40:07 UTC (rev 106853)
@@ -120,6 +120,9 @@
   <category name="org.jboss.remoting">
     <priority value="INFO" />
   </category>
+ <category name="org.jboss.ejb3.async">
+     <priority value="ALL" />
+       </category>
 
   <!-- Increase the priority threshold for the DefaultDS category
   <category name="DefaultDS">



More information about the jboss-cvs-commits mailing list