[jboss-cvs] JBossAS SVN: r67199 - 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
Fri Nov 16 15:21:59 EST 2007
Author: bdecoste
Date: 2007-11-16 15:21:58 -0500 (Fri, 16 Nov 2007)
New Revision: 67199
Added:
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocalHome.java
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulRemoteHome.java
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocalHome.java
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemoteHome.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/StatefulLocal.java
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulRemote.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/StatelessRemote.java
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java
Log:
[EJBTHREE-1019] added tests for home proxies
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-11-16 19:53:14 UTC (rev 67198)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulBean.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -21,9 +21,12 @@
*/
package org.jboss.ejb3.test.localfromremote;
-import javax.ejb.Stateful;
import javax.ejb.Local;
+import javax.ejb.LocalHome;
import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateful;
+
import javax.naming.InitialContext;
import org.jboss.logging.Logger;
@@ -32,12 +35,15 @@
*/
@Stateful
@Local(StatefulLocal.class)
+ at LocalHome(StatefulLocalHome.class)
@Remote(StatefulRemote.class)
+ at RemoteHome(StatefulRemoteHome.class)
public class StatefulBean implements StatefulRemote, StatefulLocal
{
private static final Logger log = Logger.getLogger(StatefulBean.class);
private static int methodCount = 0;
+ private static int homeMethodCount = 0;
public void localCall() throws Exception
{
@@ -47,6 +53,15 @@
stateless.method();
}
+ public void localHomeCall() throws Exception
+ {
+ InitialContext jndiContext = new InitialContext();
+ StatelessLocalHome statelessHome = (StatelessLocalHome)jndiContext.lookup("StatelessBean/localHome");
+ StatelessLocal stateless = statelessHome.create();
+ log.info("*** calling LocalHome remotely ... " + jndiContext.getEnvironment());
+ stateless.homeMethod();
+ }
+
public int remoteCall() throws Exception
{
++methodCount;
@@ -56,10 +71,27 @@
return stateful.method();
}
+ public int remoteHomeCall() throws Exception
+ {
+ ++homeMethodCount;
+ InitialContext jndiContext = new InitialContext();
+ StatefulRemoteHome statefulHome = (StatefulRemoteHome)jndiContext.lookup("StatefulBean/remoteHome");
+ StatefulRemote stateful = statefulHome.create();
+ log.info("*** calling RemoteHome ... " + jndiContext.getEnvironment());
+ return stateful.homeMethod();
+ }
+
public int method() throws Exception
{
++methodCount;
log.info("*** method called " + methodCount);
return methodCount;
}
+
+ public int homeMethod() throws Exception
+ {
+ ++homeMethodCount;
+ log.info("*** homeMethod called " + homeMethodCount);
+ return homeMethodCount;
+ }
}
Modified: 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 2007-11-16 19:53:14 UTC (rev 67198)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocal.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -28,7 +28,13 @@
{
void localCall() throws Exception;
+ void localHomeCall() throws Exception;
+
int remoteCall() throws Exception;
+ int remoteHomeCall() throws Exception;
+
int method() throws Exception;
+
+ int homeMethod() throws Exception;
}
Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocalHome.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocalHome.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulLocalHome.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+import javax.ejb.*;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulLocalHome extends EJBHome
+{
+ public StatefulLocal create() throws java.rmi.RemoteException, javax.ejb.CreateException;
+}
+
Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulRemote.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulRemote.java 2007-11-16 19:53:14 UTC (rev 67198)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulRemote.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -28,7 +28,13 @@
{
void localCall() throws Exception;
+ void localHomeCall() throws Exception;
+
int remoteCall() throws Exception;
+ int remoteHomeCall() throws Exception;
+
int method() throws Exception;
+
+ int homeMethod() throws Exception;
}
Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulRemoteHome.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulRemoteHome.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatefulRemoteHome.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+import javax.ejb.*;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulRemoteHome extends EJBHome
+{
+ public StatefulRemote create() throws java.rmi.RemoteException, javax.ejb.CreateException;
+}
+
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-11-16 19:53:14 UTC (rev 67198)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessBean.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -21,9 +21,13 @@
*/
package org.jboss.ejb3.test.localfromremote;
-import javax.ejb.Stateless;
+
import javax.ejb.Local;
+import javax.ejb.LocalHome;
import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateless;
+
import javax.naming.InitialContext;
import org.jboss.logging.Logger;
@@ -33,12 +37,15 @@
*/
@Stateless
@Local(StatelessLocal.class)
+ at LocalHome(StatelessLocalHome.class)
@Remote(StatelessRemote.class)
+ at RemoteHome(StatelessRemoteHome.class)
public class StatelessBean implements StatelessRemote, StatelessLocal
{
private static final Logger log = Logger.getLogger(StatelessBean.class);
private static int methodCount = 0;
+ private static int homeMethodCount = 0;
public void localCall() throws Exception
{
@@ -48,6 +55,15 @@
stateful.method();
}
+ public void localHomeCall() throws Exception
+ {
+ InitialContext jndiContext = new InitialContext();
+ StatefulLocalHome statefulHome = (StatefulLocalHome)jndiContext.lookup("StatefulBean/localHome");
+ StatefulLocal stateful = statefulHome.create();
+ log.info("*** calling LocalHome remotely ... " + jndiContext.getEnvironment());
+ stateful.homeMethod();
+ }
+
public int remoteCall() throws Exception
{
++methodCount;
@@ -57,10 +73,26 @@
return stateless.method();
}
+ public int remoteHomeCall() throws Exception
+ {
+ ++homeMethodCount;
+ InitialContext jndiContext = new InitialContext();
+ StatelessRemoteHome statelessHome = (StatelessRemoteHome)jndiContext.lookup("StatelessBean/remoteHome");
+ StatelessRemote stateless = statelessHome.create();
+ return stateless.homeMethod();
+ }
+
public int method() throws Exception
{
++methodCount;
log.info("*** method called " + methodCount);
return methodCount;
}
+
+ public int homeMethod() throws Exception
+ {
+ ++homeMethodCount;
+ log.info("*** homeMethod called " + homeMethodCount);
+ return homeMethodCount;
+ }
}
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-11-16 19:53:14 UTC (rev 67198)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocal.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -27,4 +27,6 @@
public interface StatelessLocal
{
int method() throws Exception;
+
+ int homeMethod() throws Exception;
}
Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocalHome.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocalHome.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessLocalHome.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -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;
+
+import javax.ejb.*;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessLocalHome extends EJBHome
+{
+
+ public StatelessLocal create() throws java.rmi.RemoteException, javax.ejb.CreateException;
+}
+
Modified: 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 2007-11-16 19:53:14 UTC (rev 67198)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemote.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -28,7 +28,13 @@
{
void localCall() throws Exception;
+ void localHomeCall() throws Exception;
+
int remoteCall() throws Exception;
+ int remoteHomeCall() throws Exception;
+
int method() throws Exception;
+
+ int homeMethod() throws Exception;
}
Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemoteHome.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemoteHome.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/StatelessRemoteHome.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+import javax.ejb.*;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessRemoteHome extends EJBHome
+{
+ public StatelessRemote create() throws java.rmi.RemoteException, javax.ejb.CreateException;
+}
+
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-11-16 19:53:14 UTC (rev 67198)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java 2007-11-16 20:21:58 UTC (rev 67199)
@@ -24,7 +24,9 @@
import javax.naming.InitialContext;
import org.jboss.ejb3.test.localfromremote.StatefulRemote;
+import org.jboss.ejb3.test.localfromremote.StatefulRemoteHome;
import org.jboss.ejb3.test.localfromremote.StatelessRemote;
+import org.jboss.ejb3.test.localfromremote.StatelessRemoteHome;
import org.jboss.logging.Logger;
import org.jboss.test.JBossTestCase;
import junit.framework.Test;
@@ -58,6 +60,21 @@
{}
}
+ public void testStatelessLocalHomeFromRemoteHome() throws Exception
+ {
+ StatefulRemoteHome home = (StatefulRemoteHome) getInitialContext().lookup("StatefulBean/remoteHome");
+ StatefulRemote bean = home.create();
+ assertNotNull(bean);
+
+ try
+ {
+ bean.localHomeCall();
+ fail("should not be allowed to call local interface remotely");
+ }
+ catch (javax.ejb.EJBException e)
+ {}
+ }
+
public void testStatelessRemoteFromRemote() throws Exception
{
StatefulRemote bean = (StatefulRemote) getInitialContext().lookup("StatefulBean/remote");
@@ -67,6 +84,16 @@
assertEquals(1, methodCount);
}
+ public void testStatelessRemoteHomeFromRemoteHome() throws Exception
+ {
+ StatefulRemoteHome home = (StatefulRemoteHome) getInitialContext().lookup("StatefulBean/remoteHome");
+ StatefulRemote bean = home.create();
+ assertNotNull(bean);
+
+ int methodCount = bean.remoteHomeCall();
+ assertEquals(1, methodCount);
+ }
+
public void testStatefulRemoteFromRemote() throws Exception
{
StatelessRemote bean = (StatelessRemote) getInitialContext().lookup("StatelessBean/remote");
@@ -76,6 +103,16 @@
assertEquals(1, methodCount);
}
+ public void testStatefulRemoteHomeFromRemoteHome() throws Exception
+ {
+ StatelessRemoteHome home = (StatelessRemoteHome) getInitialContext().lookup("StatelessBean/remoteHome");
+ StatelessRemote bean = home.create();
+ assertNotNull(bean);
+
+ int methodCount = bean.remoteHomeCall();
+ assertEquals(1, methodCount);
+ }
+
public void testStatefulLocalFromRemote() throws Exception
{
InitialContext jndiContext = new InitialContext();
@@ -94,6 +131,25 @@
}
}
+ public void testStatefulLocalHomeFromRemoteHome() throws Exception
+ {
+ InitialContext jndiContext = new InitialContext();
+ StatelessRemoteHome home = (StatelessRemoteHome) jndiContext.lookup("StatelessBean/remoteHome");
+ StatelessRemote bean = home.create();
+ assertNotNull(bean);
+
+ try
+ {
+ bean.localHomeCall();
+ fail("should not be allowed to call local interface remotely");
+ }
+ catch (javax.naming.NamingException e)
+ {
+ if (e.getCause() == null || !(e.getCause() instanceof javax.ejb.EJBException))
+ fail("should not be allowed to call local interface remotely");
+ }
+ }
+
public static Test suite() throws Exception
{
return getDeploySetup(LocalTestCase.class, "");
More information about the jboss-cvs-commits
mailing list