[jboss-cvs] JBossAS SVN: r82970 - in projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy: common/ejb/slsb and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 16 02:08:24 EST 2009
Author: ALRubinger
Date: 2009-01-16 02:08:24 -0500 (Fri, 16 Jan 2009)
New Revision: 82970
Added:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/sfsb/MyStateful2xOnlyWithBindingsBean.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/sfsb/MyStatefulBeanWithHomesBoundWithBusiness.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless2xOnlyWithBindingsBean.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessBeanWithHomesBoundWithBusiness.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSession2xOnlyWithBindingsTestCase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionHomeBusinessBoundTogetherTestCase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSession2xOnlyWithBindingsTestCase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionHomeBusinessBoundTogetherTestCase.java
Modified:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/SessionTestCaseSupport.java
Log:
[EJBTHREE-1688] Bulk up Proxy bindings test coverage for edge case deployments
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/sfsb/MyStateful2xOnlyWithBindingsBean.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/sfsb/MyStateful2xOnlyWithBindingsBean.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/sfsb/MyStateful2xOnlyWithBindingsBean.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.common.ejb.sfsb;
+
+import javax.ejb.LocalHome;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.LocalHomeBinding;
+import org.jboss.ejb3.annotation.RemoteHomeBinding;
+
+/**
+ * MyStateful2xOnlyWithBindingsBean
+ *
+ * SFSB with only EJB 2.x Views, and explicit JNDI Bindings
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at LocalHome(MyStatefulLocalHome.class)
+ at LocalHomeBinding(jndiBinding = MyStateful2xOnlyWithBindingsBean.JNDI_BINDING_LOCAL_HOME)
+ at RemoteHome(MyStatefulRemoteHome.class)
+ at RemoteHomeBinding(jndiBinding = MyStateful2xOnlyWithBindingsBean.JNDI_BINDING_REMOTE_HOME)
+public class MyStateful2xOnlyWithBindingsBean extends MyStatefulBeanBase
+{
+ public static final String JNDI_BINDING_LOCAL_HOME = "MyStateful2xOnlyWithBindingBeanLocalHome";
+
+ public static final String JNDI_BINDING_REMOTE_HOME = "MyStateful2xOnlyWithBindingBeanRemoteHome";
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/sfsb/MyStatefulBeanWithHomesBoundWithBusiness.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/sfsb/MyStatefulBeanWithHomesBoundWithBusiness.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/sfsb/MyStatefulBeanWithHomesBoundWithBusiness.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.proxy.common.ejb.sfsb;
+
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.LocalHomeBinding;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteHomeBinding;
+
+/**
+ * MyStatefulBeanWithHomesBoundWithBusiness
+ *
+ * A test SFSB where the default local and default remote business
+ * interfaces are bound to the same addresses as the local home and
+ * remote home interfaces, respectively
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at Remote (MyStatefulRemoteBusiness.class)
+ at Local (MyStatefulLocalBusiness.class)
+ at RemoteHome (MyStatefulRemoteHome.class)
+ at LocalHome (MyStatefulLocalHome.class)
+ at RemoteBinding (jndiBinding=MyStatefulBeanWithHomesBoundWithBusiness.REMOTE_JNDI_NAME)
+ at LocalBinding (jndiBinding=MyStatefulBeanWithHomesBoundWithBusiness.LOCAL_JNDI_NAME)
+ at LocalHomeBinding (jndiBinding=MyStatefulBeanWithHomesBoundWithBusiness.LOCAL_JNDI_NAME)
+ at RemoteHomeBinding (jndiBinding=MyStatefulBeanWithHomesBoundWithBusiness.REMOTE_JNDI_NAME)
+public class MyStatefulBeanWithHomesBoundWithBusiness extends MyStatefulBeanBase implements MyStatefulRemoteBusiness, MyStatefulLocalBusiness
+{
+ /**
+ * Remote Business / Remote Home JNDI Name
+ */
+ public static final String REMOTE_JNDI_NAME = "MyStatefulBeanWithHomesBoundWithBusiness/allRemotes";
+
+ /**
+ * Local Business / Local Home JNDI Name
+ */
+ public static final String LOCAL_JNDI_NAME = "MyStatefulBeanWithHomesBoundWithBusiness/allLocals";
+
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless2xOnlyWithBindingsBean.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless2xOnlyWithBindingsBean.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless2xOnlyWithBindingsBean.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.common.ejb.slsb;
+
+import javax.ejb.LocalHome;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.LocalHomeBinding;
+import org.jboss.ejb3.annotation.RemoteHomeBinding;
+
+/**
+ * MyStateless2xOnlyWithBindingsBean
+ *
+ * SLSB with only EJB 2.x Views, and explicit JNDI Bindings
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at LocalHome(MyStatelessLocalHome.class)
+ at LocalHomeBinding(jndiBinding = MyStateless2xOnlyWithBindingsBean.JNDI_BINDING_LOCAL_HOME)
+ at RemoteHome(MyStatelessRemoteHome.class)
+ at RemoteHomeBinding(jndiBinding = MyStateless2xOnlyWithBindingsBean.JNDI_BINDING_REMOTE_HOME)
+public class MyStateless2xOnlyWithBindingsBean
+{
+ public static final String JNDI_BINDING_LOCAL_HOME = "MyStateless2xOnlyWithBindingBeanLocalHome";
+
+ public static final String JNDI_BINDING_REMOTE_HOME = "MyStateless2xOnlyWithBindingBeanRemoteHome";
+
+ public String sayHi(String name)
+ {
+ return "Hi " + name;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessBeanWithHomesBoundWithBusiness.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessBeanWithHomesBoundWithBusiness.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessBeanWithHomesBoundWithBusiness.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.proxy.common.ejb.slsb;
+
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.LocalHomeBinding;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteHomeBinding;
+
+/**
+ * MyStatelessBeanWithHomesBoundWithBusiness
+ *
+ * A test SLSB where the default local and default remote business
+ * interfaces are bound to the same addresses as the local home and
+ * remote home interfaces, respectively
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at Remote(MyStatelessRemote.class)
+ at Local(MyStatelessLocal.class)
+ at RemoteHome(MyStatelessRemoteHome.class)
+ at LocalHome(MyStatelessLocalHome.class)
+ at RemoteBinding(jndiBinding = MyStatelessBeanWithHomesBoundWithBusiness.REMOTE_JNDI_NAME)
+ at LocalBinding(jndiBinding = MyStatelessBeanWithHomesBoundWithBusiness.LOCAL_JNDI_NAME)
+ at LocalHomeBinding(jndiBinding = MyStatelessBeanWithHomesBoundWithBusiness.LOCAL_JNDI_NAME)
+ at RemoteHomeBinding(jndiBinding = MyStatelessBeanWithHomesBoundWithBusiness.REMOTE_JNDI_NAME)
+public class MyStatelessBeanWithHomesBoundWithBusiness implements MyStatelessRemote, MyStatelessLocal
+{
+ /**
+ * Remote Business / Remote Home JNDI Name
+ */
+ public static final String REMOTE_JNDI_NAME = "MyStatelessBeanWithHomesBoundWithBusiness/allRemotes";
+
+ /**
+ * Local Business / Local Home JNDI Name
+ */
+ public static final String LOCAL_JNDI_NAME = "MyStatelessBeanWithHomesBoundWithBusiness/allLocals";
+
+ /**
+ * @see {@link MyStateless#sayHi(String)}
+ */
+ public String sayHi(String name)
+ {
+ return "Hi " + name;
+ }
+
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSession2xOnlyWithBindingsTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSession2xOnlyWithBindingsTestCase.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSession2xOnlyWithBindingsTestCase.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.proxy.session.unit;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.test.proxy.common.SessionTestCaseBase;
+import org.jboss.ejb3.test.proxy.common.Utils;
+import org.jboss.ejb3.test.proxy.common.container.StatefulContainer;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStateful2xOnlyWithBindingsBean;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulLocalHome;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulRemoteHome;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * ProxyStatefulSession2xOnlyWithBindingsTestCase
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProxyStatefulSession2xOnlyWithBindingsTestCase extends SessionTestCaseSupport
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * JNDI Context
+ */
+ private static Context context;
+
+ // --------------------------------------------------------------------------------||
+ // Tests --------------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ @Test
+ public void testLocalHome() throws Exception
+ {
+ Object bean = this.getNamingContext().lookup(MyStateful2xOnlyWithBindingsBean.JNDI_BINDING_LOCAL_HOME);
+ assertTrue(bean instanceof MyStatefulLocalHome);
+ }
+
+ @Test
+ public void testRemoteHome() throws Exception
+ {
+ Object bean = this.getNamingContext().lookup(MyStateful2xOnlyWithBindingsBean.JNDI_BINDING_REMOTE_HOME);
+ assertTrue(bean instanceof MyStatefulRemoteHome);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Context to be used for JNDI Operations
+ */
+ @Override
+ protected Context getNamingContext()
+ {
+ return context;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Perform setup before any tests
+ *
+ * @throws Throwable
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Throwable
+ {
+ // Create Bootstrap and Deploy
+ SessionTestCaseBase.setUpBeforeClass();
+
+ // Deploy MC Beans
+ ProxyStatefulSession2xOnlyWithBindingsTestCase.bootstrap.deploy(ProxyStatefulSessionTestCase.class);
+
+ // Create a SFSB
+ StatefulContainer container = Utils.createSfsb(MyStateful2xOnlyWithBindingsBean.class);
+
+ // Install
+ Ejb3RegistrarLocator.locateRegistrar().bind(container.getName(), container);
+
+ // Create JNDI Context
+ context = new InitialContext(); // Props from CP jndi.properties
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception
+ {
+ if (bootstrap != null)
+ bootstrap.shutdown();
+ bootstrap = null;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionHomeBusinessBoundTogetherTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionHomeBusinessBoundTogetherTestCase.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionHomeBusinessBoundTogetherTestCase.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.proxy.session.unit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.test.proxy.common.SessionTestCaseBase;
+import org.jboss.ejb3.test.proxy.common.Utils;
+import org.jboss.ejb3.test.proxy.common.container.StatefulContainer;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulBeanWithHomesBoundWithBusiness;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulLocalBusiness;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulLocalHome;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulRemoteBusiness;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulRemoteHome;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * ProxyStatefulSessionHomeBusinessBoundTogetherTestCase
+ *
+ * Test Cases to ensure that an SFSB with Home and Business
+ * Views are bound together as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProxyStatefulSessionHomeBusinessBoundTogetherTestCase extends SessionTestCaseSupport
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * JNDI Context
+ */
+ private static Context context;
+
+ // --------------------------------------------------------------------------------||
+ // Tests --------------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Test Local Home Binding is made alongside Local Business
+ * Default Binding
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testLocalHomeBoundAlongsideLocalBusinessDefault() throws Exception
+ {
+ this.checkBusinessAndHomeInterfacesBoundTogether(MyStatefulBeanWithHomesBoundWithBusiness.LOCAL_JNDI_NAME,
+ MyStatefulLocalBusiness.class, MyStatefulLocalHome.class);
+ }
+
+ /**
+ * Test Remote Home Binding is made alongside Remote Business
+ * Default Binding
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testRemoteHomeBoundAlongsideRemoteBusinessDefault() throws Exception
+ {
+ this.checkBusinessAndHomeInterfacesBoundTogether(MyStatefulBeanWithHomesBoundWithBusiness.REMOTE_JNDI_NAME,
+ MyStatefulRemoteBusiness.class, MyStatefulRemoteHome.class);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Context to be used for JNDI Operations
+ */
+ @Override
+ protected Context getNamingContext()
+ {
+ return context;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Perform setup before any tests
+ *
+ * @throws Throwable
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Throwable
+ {
+ // Create Bootstrap
+ SessionTestCaseBase.setUpBeforeClass();
+
+ // Deploy MC Beans
+ ProxyStatefulSessionHomeBusinessBoundTogetherTestCase.bootstrap.deploy(ProxyStatefulSessionTestCase.class);
+
+ // Create a SFSB
+ StatefulContainer container = Utils.createSfsb(MyStatefulBeanWithHomesBoundWithBusiness.class);
+
+ // Install
+ Ejb3RegistrarLocator.locateRegistrar().bind(container.getName(), container);
+
+ // Create JNDI Context
+ ProxyStatefulSessionHomeBusinessBoundTogetherTestCase.context = new InitialContext(); // Props from CP jndi.properties
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception
+ {
+ if (bootstrap != null)
+ bootstrap.shutdown();
+ bootstrap = null;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSession2xOnlyWithBindingsTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSession2xOnlyWithBindingsTestCase.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSession2xOnlyWithBindingsTestCase.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session.unit;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.test.proxy.common.SessionTestCaseBase;
+import org.jboss.ejb3.test.proxy.common.Utils;
+import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStateless2xOnlyWithBindingsBean;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessLocalHome;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemoteHome;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProxyStatelessSession2xOnlyWithBindingsTestCase extends SessionTestCaseSupport
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * JNDI Context
+ */
+ private static Context context;
+
+ // --------------------------------------------------------------------------------||
+ // Tests --------------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ @Test
+ public void testLocalHome() throws Exception
+ {
+ Object bean = this.getNamingContext().lookup(MyStateless2xOnlyWithBindingsBean.JNDI_BINDING_LOCAL_HOME);
+ assertTrue(bean instanceof MyStatelessLocalHome);
+ }
+
+ @Test
+ public void testRemoteHome() throws Exception
+ {
+ Object bean = this.getNamingContext().lookup(MyStateless2xOnlyWithBindingsBean.JNDI_BINDING_REMOTE_HOME);
+ assertTrue(bean instanceof MyStatelessRemoteHome);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Context to be used for JNDI Operations
+ */
+ @Override
+ protected Context getNamingContext()
+ {
+ return context;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Perform setup before any tests
+ *
+ * @throws Throwable
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Throwable
+ {
+ // Create Bootstrap and Deploy
+ SessionTestCaseBase.setUpBeforeClass();
+
+ // Deploy MC Beans
+ ProxyStatelessSession2xOnlyWithBindingsTestCase.bootstrap.deploy(ProxyStatelessSessionTestCase.class);
+
+ // Create a SLSB
+ StatelessContainer container = Utils.createSlsb(MyStateless2xOnlyWithBindingsBean.class);
+
+ // Install
+ Ejb3RegistrarLocator.locateRegistrar().bind(container.getName(), container);
+
+ // Create JNDI Context
+ context = new InitialContext(); // Props from CP jndi.properties
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception
+ {
+ if (bootstrap != null)
+ bootstrap.shutdown();
+ bootstrap = null;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionHomeBusinessBoundTogetherTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionHomeBusinessBoundTogetherTestCase.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionHomeBusinessBoundTogetherTestCase.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.session.unit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.test.proxy.common.SessionTestCaseBase;
+import org.jboss.ejb3.test.proxy.common.Utils;
+import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessBeanWithHomesBoundWithBusiness;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessLocal;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessLocalHome;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemote;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemoteHome;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * ProxyStatelessSessionHomeBusinessBoundTogetherTestCase
+ *
+ * Test Cases to ensure that an SLSB with Home and Business
+ * Views are bound together as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProxyStatelessSessionHomeBusinessBoundTogetherTestCase extends SessionTestCaseSupport
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * JNDI Context
+ */
+ private static Context context;
+
+ // --------------------------------------------------------------------------------||
+ // Tests --------------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Test Local Home Binding is made alongside Local Business
+ * Default Binding
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testLocalHomeBoundAlongsideLocalBusinessDefault() throws Exception
+ {
+ this.checkBusinessAndHomeInterfacesBoundTogether(MyStatelessBeanWithHomesBoundWithBusiness.LOCAL_JNDI_NAME,
+ MyStatelessLocal.class, MyStatelessLocalHome.class);
+ }
+
+ /**
+ * Test Remote Home Binding is made alongside Remote Business
+ * Default Binding
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testRemoteHomeBoundAlongsideRemoteBusinessDefault() throws Exception
+ {
+ this.checkBusinessAndHomeInterfacesBoundTogether(MyStatelessBeanWithHomesBoundWithBusiness.REMOTE_JNDI_NAME,
+ MyStatelessRemote.class, MyStatelessRemoteHome.class);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Context to be used for JNDI Operations
+ */
+ @Override
+ protected Context getNamingContext()
+ {
+ return context;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Perform setup before any tests
+ *
+ * @throws Throwable
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Throwable
+ {
+ // Create Bootstrap
+ SessionTestCaseBase.setUpBeforeClass();
+
+ // Deploy MC Beans
+ ProxyStatelessSessionHomeBusinessBoundTogetherTestCase.bootstrap.deploy(ProxyStatelessSessionTestCase.class);
+
+ // Create a SLSB
+ StatelessContainer container = Utils.createSlsb(MyStatelessBeanWithHomesBoundWithBusiness.class);
+
+ // Install
+ Ejb3RegistrarLocator.locateRegistrar().bind(container.getName(), container);
+
+ // Create JNDI Context
+ ProxyStatelessSessionHomeBusinessBoundTogetherTestCase.context = new InitialContext(); // Props from CP jndi.properties
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception
+ {
+ if (bootstrap != null)
+ bootstrap.shutdown();
+ bootstrap = null;
+ }
+}
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/SessionTestCaseSupport.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/SessionTestCaseSupport.java 2009-01-16 05:57:29 UTC (rev 82969)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/SessionTestCaseSupport.java 2009-01-16 07:08:24 UTC (rev 82970)
@@ -25,9 +25,13 @@
import javax.naming.Binding;
import javax.naming.Context;
+import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
+import junit.framework.TestCase;
+
import org.jboss.ejb3.test.proxy.common.SessionTestCaseBase;
+import org.jboss.logging.Logger;
/**
* SessionTestCaseSupport
@@ -42,6 +46,12 @@
{
// --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(SessionTestCaseSupport.class);
+
+ // --------------------------------------------------------------------------------||
// Contracts ----------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -76,7 +86,16 @@
//
// and "errors" out the testcase. Not exactly what i wanted. So instead to get the
// test case failing, let's just check whether the jndi-name is present
- NamingEnumeration<Binding> namingEnumeration = getNamingContext().listBindings(beanImplClass.getSimpleName());
+ String jndiBase = beanImplClass.getSimpleName();
+ NamingEnumeration<Binding> namingEnumeration = null;
+ try
+ {
+ namingEnumeration = getNamingContext().listBindings(jndiBase);
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ TestCase.fail("JNDI Context at " + jndiBase + " could not be found");
+ }
while (namingEnumeration.hasMore())
{
Binding binding = namingEnumeration.next();
@@ -90,4 +109,41 @@
}
}
}
+
+ /**
+ * Ensures that a proxy is bound at the specified JNDI name, and that it is
+ * assignable to both the business and home interfaces provided
+ *
+ * @param jndiName
+ * @param businessInterface
+ * @param homeInterface
+ * @throws Exception
+ */
+ protected void checkBusinessAndHomeInterfacesBoundTogether(String jndiName, Class<?> businessInterface,
+ Class<?> homeInterface) throws Exception
+ {
+ // Lookup
+ Object obj = null;
+ try
+ {
+ obj = this.getNamingContext().lookup(jndiName);
+ log.info("Obtained from JNDI " + jndiName + ": " + obj);
+ }
+ // Make sure the target is bound
+ catch (NameNotFoundException nnfe)
+ {
+ TestCase.fail("Expected business/home proxy not found at " + jndiName);
+ }
+ // Make sure the result isn't null
+ TestCase.assertNotNull("Expected object from JNDI " + jndiName + " was null", obj);
+
+ // Ensure castable
+ String castErrorMessagePrefix = "Obtained proxy from JNDI " + jndiName + " which is not assignable to ";
+ TestCase.assertTrue(castErrorMessagePrefix + businessInterface.getName(), businessInterface.isAssignableFrom(obj
+ .getClass()));
+ TestCase.assertTrue(castErrorMessagePrefix + homeInterface.getName(), homeInterface.isAssignableFrom(obj
+ .getClass()));
+
+ }
+
}
More information about the jboss-cvs-commits
mailing list