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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 20 07:27:20 EST 2010


Author: jaikiran
Date: 2010-01-20 07:27:20 -0500 (Wed, 20 Jan 2010)
New Revision: 99656

Added:
   trunk/testsuite/src/main/org/jboss/test/ejb3/war/
   trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/
   trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CalculatorInWEBINFClasses.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/Counter.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CounterBeanInWEBINFLibJar.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CounterDelegateBeanInWarEjbJarXml.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/unit/
   trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/unit/Ejb3WarDeploymentTestCase.java
   trunk/testsuite/src/resources/ejb3/war/
   trunk/testsuite/src/resources/ejb3/war/deployment/
   trunk/testsuite/src/resources/ejb3/war/deployment/ejb-jar.xml
   trunk/testsuite/src/resources/ejb3/war/deployment/web.xml
Modified:
   trunk/testsuite/imports/sections/ejb3.xml
Log:
JBAS-7639 Added tests for EJB deployment through .war files, as defined by EJB3.1 Spec, Section 20.4)

Modified: trunk/testsuite/imports/sections/ejb3.xml
===================================================================
--- trunk/testsuite/imports/sections/ejb3.xml	2010-01-20 12:25:54 UTC (rev 99655)
+++ trunk/testsuite/imports/sections/ejb3.xml	2010-01-20 12:27:20 UTC (rev 99656)
@@ -135,10 +135,38 @@
 	   </jar>
    </target>
 
+   <target name="ejb3war" depends="compile">
+	   <mkdir dir="${build.lib}" />
+	   
+	   <jar destfile="${build.lib}/ejb3-webinf-lib-jar.jar">
+		   <fileset dir="${build.classes}">
+			   <include name="org/jboss/test/ejb3/war/deployment/CounterBeanInWEBINFLibJar.class" />
+		   </fileset>
+	   </jar>
+   	
+   		<war warfile="${build.lib}/ejb3war.war"
+   	         webxml="${source.resources}/ejb3/war/deployment/web.xml">
+   			
+   			<webinf dir="${source.resources}/ejb3/war/deployment">
+   			            <include name="ejb-jar.xml"/>
+			</webinf>
+   			
+   	         <classes dir="${build.classes}">
+   	            <include name="org/jboss/test/ejb3/war/deployment/Counter.class"/>
+   	         	<include name="org/jboss/test/ejb3/war/deployment/CounterDelegateBeanInWarEjbJarXml.class"/>
+   	         	<include name="org/jboss/test/ejb3/war/deployment/CalculatorInWEBINFClasses.class"/>
+   	         </classes>
+   	         <lib dir="${build.lib}">
+   	            <include name="ejb3-webinf-lib-jar.jar"/>
+   	         </lib>
+   	      </war>
+   	
+   </target>
 
+
    <target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,
       jbas7526,
-      ejbthree1597,ejbthree7376, jboss51xsd, ejb31nointerface">
+      ejbthree1597,ejbthree7376, jboss51xsd, ejb31nointerface, ejb3war">
       <mkdir dir="${build.lib}" />
 
       <!-- A jar with a simple ejb3 session -->

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CalculatorInWEBINFClasses.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CalculatorInWEBINFClasses.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CalculatorInWEBINFClasses.java	2010-01-20 12:27:20 UTC (rev 99656)
@@ -0,0 +1,34 @@
+/**
+ * 
+ */
+package org.jboss.test.ejb3.war.deployment;
+
+import javax.ejb.Stateless;
+
+import org.jboss.test.ejb3.war.deployment.unit.Ejb3WarDeploymentTestCase;
+
+/**
+ * CalculatorInWEBINFClasses
+ *
+ * A no-interface view bean which will be placed in the .war/WEB-INF/classes folder.
+ * Will be used in {@link Ejb3WarDeploymentTestCase} for testing deployment of EJBs
+ * through war files as defined in EJB3.1 Spec, Section 20.4
+ *   
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+public class CalculatorInWEBINFClasses
+{
+
+   public int add (int a, int b)
+   {
+      return a + b;
+   }
+   
+   public int subtract (int a, int b)
+   {
+      return a - b;
+   }
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/Counter.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/Counter.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/Counter.java	2010-01-20 12:27:20 UTC (rev 99656)
@@ -0,0 +1,18 @@
+/**
+ * 
+ */
+package org.jboss.test.ejb3.war.deployment;
+
+/**
+ * Counter
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface Counter
+{
+
+   int increment();
+   
+   int decrement();
+}

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CounterBeanInWEBINFLibJar.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CounterBeanInWEBINFLibJar.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CounterBeanInWEBINFLibJar.java	2010-01-20 12:27:20 UTC (rev 99656)
@@ -0,0 +1,52 @@
+/**
+ * 
+ */
+package org.jboss.test.ejb3.war.deployment;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.test.ejb3.war.deployment.unit.Ejb3WarDeploymentTestCase;
+
+/**
+ * CounterBeanInWEBINFLibJar
+ * 
+ * A Stateful bean configured deployed through a jar file in .war/WEB-INF/lib folder.
+ * This bean uses a no-interface view bean ({@link CalculatorInWEBINFClasses}) to
+ * perform its operations.
+ * 
+ * Will be used in {@link Ejb3WarDeploymentTestCase} for testing deployment of EJBs
+ * through war files as defined in EJB3.1 Spec, Section 20.4
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateful
+ at Remote (Counter.class)
+public class CounterBeanInWEBINFLibJar implements Counter
+{
+
+   private int count = 0;
+   
+   /**
+    * Inject the no-interface view bean
+    */
+   @EJB
+   private CalculatorInWEBINFClasses calculator;
+   
+   @Override
+   public int decrement()
+   {
+      this.count = this.calculator.subtract(this.count, 1);
+      return this.count;
+   }
+
+   @Override
+   public int increment()
+   {
+      this.count = this.calculator.add(this.count, 1);
+      return this.count;
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CounterDelegateBeanInWarEjbJarXml.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CounterDelegateBeanInWarEjbJarXml.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/CounterDelegateBeanInWarEjbJarXml.java	2010-01-20 12:27:20 UTC (rev 99656)
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package org.jboss.test.ejb3.war.deployment;
+
+import javax.ejb.EJB;
+
+import org.jboss.test.ejb3.war.deployment.unit.Ejb3WarDeploymentTestCase;
+
+/**
+ * CounterDelegateBeanInWarEjbJarXml
+ *
+ * A Stateful bean configured through a ejb-jar.xml in .war/WEB-INF folder. This bean
+ * just delegates the calls to a bean ({@link CounterBeanInWEBINFLibJar}) which is deployed
+ * in the .war/WEB-INF/lib/<somejar>.jar
+ * 
+ * Will be used in {@link Ejb3WarDeploymentTestCase} for testing deployment of EJBs
+ * through war files as defined in EJB3.1 Spec, Section 20.4
+ * 
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class CounterDelegateBeanInWarEjbJarXml implements Counter
+{
+
+
+   /**
+    * 
+    */
+   @EJB(beanName = "CounterBeanInWEBINFLibJar")
+   private Counter counterBean;
+
+   
+   @Override
+   public int decrement()
+   {
+      return this.counterBean.decrement();
+   }
+
+   @Override
+   public int increment()
+   {
+      return this.counterBean.increment();
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/unit/Ejb3WarDeploymentTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/unit/Ejb3WarDeploymentTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/war/deployment/unit/Ejb3WarDeploymentTestCase.java	2010-01-20 12:27:20 UTC (rev 99656)
@@ -0,0 +1,70 @@
+/**
+ * 
+ */
+package org.jboss.test.ejb3.war.deployment.unit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.ejb3.war.deployment.Counter;
+
+/**
+ * Ejb3WarDeploymentTestCase
+ * 
+ * TestCase for testing the deployment of EJBs through .war files as defined
+ * in EJB3.1 Spec, Section 20.4.
+ * 
+ *  @see https://jira.jboss.org/jira/browse/JBAS-7639
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class Ejb3WarDeploymentTestCase extends JBossTestCase
+{
+
+   public Ejb3WarDeploymentTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * 
+    * @return
+    * @throws Exception
+    */
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(Ejb3WarDeploymentTestCase.class, "ejb3war.war");
+   }
+
+   /**
+    * Tests that the beans deployed through a .war, in various ways (WEB-INF/ejb-jar.xml,
+    * WEB-INF/lib/<somejar>.jar, WEB-INF/classes) works correctly.
+    *  
+    * @throws Exception
+    */
+   public void testEjbDeploymentInWar() throws Exception
+   {
+      Context ctx = new InitialContext();
+      Counter counter = (Counter) ctx.lookup("CounterDelegateBean/remote");
+
+      int count = counter.increment();
+      assertEquals("Unexpected count after increment", 1, count);
+
+      // increment one more time
+      count = counter.increment();
+      assertEquals("Unexpected count after second increment", 2, count);
+
+      // now decrement
+      count = counter.decrement();
+      assertEquals("Unexpected count after decrement", 1, count);
+
+      // decrement one more time
+      count = counter.decrement();
+      assertEquals("Unexpected count after second decrement", 0, count);
+
+   }
+
+}

Added: trunk/testsuite/src/resources/ejb3/war/deployment/ejb-jar.xml
===================================================================
--- trunk/testsuite/src/resources/ejb3/war/deployment/ejb-jar.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/ejb3/war/deployment/ejb-jar.xml	2010-01-20 12:27:20 UTC (rev 99656)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+      	  http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
+      version="3.1">
+   <enterprise-beans>
+      <session>
+         <ejb-name>CounterDelegateBean</ejb-name>
+         <business-remote>org.jboss.test.ejb3.war.deployment.Counter</business-remote>
+         <ejb-class>org.jboss.test.ejb3.war.deployment.CounterDelegateBeanInWarEjbJarXml</ejb-class>
+         <session-type>Stateful</session-type>
+      </session>
+   </enterprise-beans>
+</ejb-jar>
\ No newline at end of file

Added: trunk/testsuite/src/resources/ejb3/war/deployment/web.xml
===================================================================
--- trunk/testsuite/src/resources/ejb3/war/deployment/web.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/ejb3/war/deployment/web.xml	2010-01-20 12:27:20 UTC (rev 99656)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_3_0.xsd"
+      version="3.0">
+      
+      
+</web-app>      
\ No newline at end of file




More information about the jboss-cvs-commits mailing list