[jboss-cvs] JBossAS SVN: r64270 - in trunk/ejb3: src/test/org/jboss/ejb3/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 25 09:00:48 EDT 2007


Author: wolfc
Date: 2007-07-25 09:00:48 -0400 (Wed, 25 Jul 2007)
New Revision: 64270

Added:
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStateful.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStatefulBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/unit/EjbContextCheckTestCase.java
Modified:
   trunk/ejb3/build-test.xml
Log:
EJBTHREE-1020: unit test

Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml	2007-07-25 12:04:38 UTC (rev 64269)
+++ trunk/ejb3/build-test.xml	2007-07-25 13:00:48 UTC (rev 64270)
@@ -2053,6 +2053,13 @@
       <build-simple-jar name="ejbthree989"/>
    </target>
    
+   <target name="ejbthree1020"
+      description="Builds a simple jar file."
+      depends="compile-classes">
+      
+      <build-simple-jar name="ejbthree1020"/>
+   </target>
+   
    <target name="jaxws"
       description="Builds a simple jar."
       depends="compile-classes">
@@ -3470,7 +3477,7 @@
       ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921, ejbthree936, 
       ejbthree939,
       ejbthree953, ejbthree957, ejbthree959, ejbthree963, ejbthree967, ejbthree971, ejbthree973, ejbthree985, ejbthree986,
-      ejbthree989,
+      ejbthree989, ejbthree1020,
       jaxws,
       aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency, 
       securitydomain, enventry, 
@@ -4348,6 +4355,9 @@
       <antcall target="test" inheritRefs="true">
          <param name="test" value="ejbthree989"/>
       </antcall>
+      <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree1020"/>
+      </antcall>
    </target>
 
    <target name="entity-tests" depends="init" description="Execute all tests">

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStateful.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStateful.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStateful.java	2007-07-25 13:00:48 UTC (rev 64270)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.ejb3.test.ejbthree1020;
+
+import javax.ejb.Init;
+import javax.ejb.Remote;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface MyStateful
+{
+   @Init
+   void create(int id);
+   
+   int getId();
+   
+   void method1(int expectedId);
+   
+   void method2(int expectedId);
+}


Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStateful.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStatefulBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStatefulBean.java	2007-07-25 13:00:48 UTC (rev 64270)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.ejb3.test.ejbthree1020;
+
+import javax.ejb.Init;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateful
+public class MyStatefulBean implements MyStateful
+{
+   private static Object lock = new Object();
+   
+   private int id;
+   
+   @Init
+   public void create(int id)
+   {
+      this.id = id;
+   }
+   
+   public int getId()
+   {
+      return id;
+   }
+   
+   public void method1(int expectedId)
+   {
+      try
+      {
+         SessionContext ctx1 = (SessionContext) new InitialContext().lookup("java:comp/EJBContext");
+         if(expectedId != ctx1.getBusinessObject(MyStateful.class).getId())
+            throw new RuntimeException("ids on first check don't match");
+         
+         lock.wait(5000);
+         
+         SessionContext ctx2 = (SessionContext) new InitialContext().lookup("java:comp/EJBContext");
+         if(expectedId != ctx2.getBusinessObject(MyStateful.class).getId())
+            throw new RuntimeException("ids on second check don't match");
+         
+         System.out.println("ctx1 = " + ctx1);
+         System.out.println("ctx2 = " + ctx2);
+      }
+      catch (NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (InterruptedException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   public void method2(int expectedId)
+   {
+      try
+      {
+         SessionContext ctx1 = (SessionContext) new InitialContext().lookup("java:comp/EJBContext");
+         if(expectedId != ctx1.getBusinessObject(MyStateful.class).getId())
+            throw new RuntimeException("ids on check don't match");
+         
+         lock.notify();
+      }
+      catch(NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+}


Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/MyStatefulBean.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/unit/EjbContextCheckTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/unit/EjbContextCheckTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/unit/EjbContextCheckTestCase.java	2007-07-25 13:00:48 UTC (rev 64270)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.ejb3.test.ejbthree1020.unit;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1020.MyStateful;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test to see if resources of type URL work.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public class EjbContextCheckTestCase extends JBossTestCase
+{
+   public EjbContextCheckTestCase(String name)
+   {
+      super(name);
+   }
+
+   private MyStateful lookupBean() throws Exception
+   {
+      return (MyStateful) getInitialContext().lookup("MyStatefulBean/remote");
+   }
+   
+   public void test1() throws Exception
+   {
+      final MyStateful bean1 = lookupBean();
+      bean1.create(1);
+      
+      MyStateful bean2 = lookupBean();
+      bean2.create(2);
+      
+      Thread thread = new Thread()
+      {
+         @Override
+         public void run()
+         {
+            bean1.method1(1);
+         }
+      };
+      thread.start();
+      
+      Thread.sleep(1000);
+      
+      bean2.method2(2);
+      
+      thread.join(5000);
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(EjbContextCheckTestCase.class, "ejbthreeXXX.jar");
+   }
+}


Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1020/unit/EjbContextCheckTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list