[jboss-cvs] JBossAS SVN: r64404 - in branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote: unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 1 13:50:24 EDT 2007


Author: bdecoste
Date: 2007-08-01 13:50:24 -0400 (Wed, 01 Aug 2007)
New Revision: 64404

Added:
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocal.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemote.java
Modified:
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocal.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java
Log:
[EJBTHREE-1019] added additional tests for stateful and stateless

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulBean.java	2007-08-01 16:39:02 UTC (rev 64403)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulBean.java	2007-08-01 17:50:24 UTC (rev 64404)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3.test.localfromremote;
 
 import javax.ejb.Stateful;
+import javax.ejb.Local;
 import javax.ejb.Remote;
 import javax.naming.InitialContext;
 import org.jboss.logging.Logger;
@@ -30,10 +31,11 @@
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  */
 @Stateful
+ at Local(StatefulLocal.class)
 @Remote(StatefulRemote.class)
-public class StatefulBean implements StatefulRemote
+public class StatefulBean implements StatefulRemote, StatefulLocal
 {
-   private static final Logger log = Logger.getLogger(StatefulRemote.class);
+   private static final Logger log = Logger.getLogger(StatefulBean.class);
    
    private static int methodCount = 0;
    
@@ -41,8 +43,8 @@
    {
       InitialContext jndiContext = new InitialContext();
       StatelessLocal stateless = (StatelessLocal)jndiContext.lookup("StatelessBean/local");
-      log.info("*** remote Local called " + jndiContext.getEnvironment());
-      stateless.method();
+      log.info("*** calling Local remotely ...  " + jndiContext.getEnvironment());
+      stateless.method();   
    }
    
    public int remoteCall() throws Exception
@@ -50,14 +52,14 @@
       ++methodCount;
       InitialContext jndiContext = new InitialContext();
       StatefulRemote stateful = (StatefulRemote)jndiContext.lookup("StatefulBean/remote");
-      log.info("*** calling Remote " + jndiContext.getEnvironment());
+      log.info("*** calling Remote ... " + jndiContext.getEnvironment());
       return stateful.method();
    }
    
    public int method() throws Exception
    {
       ++methodCount;
-      log.info("*** remote method called " + methodCount);
+      log.info("*** method called " + methodCount);
       return methodCount;
    }
 }

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocal.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocal.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocal.java	2007-08-01 17:50:24 UTC (rev 64404)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.localfromremote;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulLocal
+{
+   void localCall() throws Exception;
+   
+   int remoteCall() throws Exception;
+   
+   int method() throws Exception;
+}

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessBean.java	2007-08-01 16:39:02 UTC (rev 64403)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessBean.java	2007-08-01 17:50:24 UTC (rev 64404)
@@ -23,6 +23,9 @@
 
 import javax.ejb.Stateless;
 import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.naming.InitialContext;
+
 import org.jboss.logging.Logger;
 
 /**
@@ -30,12 +33,34 @@
  */
 @Stateless
 @Local(StatelessLocal.class)
-public class StatelessBean implements StatelessLocal
+ at Remote(StatelessRemote.class)
+public class StatelessBean implements StatelessRemote, StatelessLocal
 {
    private static final Logger log = Logger.getLogger(StatelessBean.class);
   
-   public void method() throws Exception
+   private static int methodCount = 0;
+   
+   public void localCall() throws Exception
    {
-      log.info("*** Local called");
+      InitialContext jndiContext = new InitialContext();
+      StatefulLocal stateful = (StatefulLocal)jndiContext.lookup("StatefulBean/local");
+      log.info("*** calling Local remotely ... " + jndiContext.getEnvironment());
+      stateful.method();
    }
+   
+   public int remoteCall() throws Exception
+   {
+      ++methodCount;
+      InitialContext jndiContext = new InitialContext();
+      StatelessRemote stateless = (StatelessRemote)jndiContext.lookup("StatelessBean/remote");
+      log.info("*** calling Remote ... " + jndiContext.getEnvironment());
+      return stateless.method();
+   }
+   
+   public int method() throws Exception
+   {
+      ++methodCount;
+      log.info("*** method called " + methodCount);
+      return methodCount;
+   }
 }

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocal.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocal.java	2007-08-01 16:39:02 UTC (rev 64403)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocal.java	2007-08-01 17:50:24 UTC (rev 64404)
@@ -26,5 +26,5 @@
  */
 public interface StatelessLocal
 {
-   void method() throws Exception;
+   int method() throws Exception;
 }

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemote.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemote.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemote.java	2007-08-01 17:50:24 UTC (rev 64404)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.localfromremote;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessRemote
+{
+   void localCall() throws Exception;
+   
+   int remoteCall() throws Exception;
+   
+   int method() throws Exception;
+}

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java	2007-08-01 16:39:02 UTC (rev 64403)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java	2007-08-01 17:50:24 UTC (rev 64404)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3.test.localfromremote.unit;
 
 import org.jboss.ejb3.test.localfromremote.StatefulRemote;
+import org.jboss.ejb3.test.localfromremote.StatelessRemote;
 import org.jboss.logging.Logger;
 import org.jboss.test.JBossTestCase;
 import junit.framework.Test;
@@ -41,7 +42,7 @@
       super(name);
    }
  
-   public void testLocalFromRemote() throws Exception
+   public void testStatelessLocalFromRemote() throws Exception
    {
       StatefulRemote bean = (StatefulRemote) getInitialContext().lookup("StatefulBean/remote");
       assertNotNull(bean);
@@ -55,7 +56,7 @@
       {}
    }
    
-   public void testRemoteFromRemote() throws Exception
+   public void testStatelessRemoteFromRemote() throws Exception
    {
       StatefulRemote bean = (StatefulRemote) getInitialContext().lookup("StatefulBean/remote");
       assertNotNull(bean);
@@ -64,6 +65,29 @@
       assertEquals(1, methodCount);
    }
    
+   public void testStatefulRemoteFromRemote() throws Exception
+   {
+      StatelessRemote bean = (StatelessRemote) getInitialContext().lookup("StatelessBean/remote");
+      assertNotNull(bean);
+      
+      int methodCount = bean.remoteCall();
+      assertEquals(1, methodCount);
+   }
+   
+   public void testStatefulLocalFromRemote() throws Exception
+   {
+      StatelessRemote bean = (StatelessRemote) getInitialContext().lookup("StatelessBean/remote");
+      assertNotNull(bean);
+      
+      try
+      {
+         bean.localCall();
+         fail("should not be allowed to call local interface remotely");
+      }
+      catch (javax.ejb.EJBException e)
+      {}
+   }
+   
    public static Test suite() throws Exception
    {
       return getDeploySetup(LocalTestCase.class, ""); 




More information about the jboss-cvs-commits mailing list