[jboss-cvs] JBossAS SVN: r79258 - in projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy: jndiregistrar and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 8 02:35:55 EDT 2008
Author: ALRubinger
Date: 2008-10-08 02:35:55 -0400 (Wed, 08 Oct 2008)
New Revision: 79258
Added:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/BindingTest.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/JndiBindingTestBean.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/JndiBindingTestBeanBase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/LocalJndiBindingTest.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/RemoteJndiBindingTest.java
Removed:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/binding/
Modified:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java
Log:
[EJBTHREE-1515] Centralize tests and test for unbinding of alternate JNDI Bindings
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/BindingTest.java (from rev 79234, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/binding/BindingTest.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/BindingTest.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/BindingTest.java 2008-10-08 06:35:55 UTC (rev 79258)
@@ -0,0 +1,46 @@
+/*
+ * 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.jndiregistrar;
+
+/**
+ * BindingTest
+ *
+ * Defines all functions required of
+ * the Remote Binding Test EJB
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface BindingTest
+{
+
+ /*
+ * Common functions
+ */
+
+ /**
+ * Echos the specified parameter
+ *
+ * @param param
+ */
+ String echo(String param);
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/JndiBindingTestBean.java (from rev 79234, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/binding/JndiBindingTestBean.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/JndiBindingTestBean.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/JndiBindingTestBean.java 2008-10-08 06:35:55 UTC (rev 79258)
@@ -0,0 +1,50 @@
+/*
+ * 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.jndiregistrar;
+
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteBindings;
+
+/**
+ * JndiBindingTestBean
+ *
+ * Tests EJB for explicit JNDI Bindings
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(RemoteJndiBindingTest.class)
+ at Local(LocalJndiBindingTest.class)
+ at RemoteBindings(
+{@RemoteBinding(jndiBinding = RemoteJndiBindingTest.JNDI_BINDING_1),
+ @RemoteBinding(jndiBinding = RemoteJndiBindingTest.JNDI_BINDING_2)})
+ at LocalBinding(jndiBinding = LocalJndiBindingTest.JNDI_BINDING)
+public class JndiBindingTestBean extends JndiBindingTestBeanBase implements RemoteJndiBindingTest, LocalJndiBindingTest
+{
+
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/JndiBindingTestBeanBase.java (from rev 79234, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/binding/JndiBindingTestBeanBase.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/JndiBindingTestBeanBase.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/JndiBindingTestBeanBase.java 2008-10-08 06:35:55 UTC (rev 79258)
@@ -0,0 +1,43 @@
+/*
+ * 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.jndiregistrar;
+
+/**
+ * JndiBindingTestBeanBase
+ *
+ * Common base for @RemoteBinding test EJBs
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JndiBindingTestBeanBase implements BindingTest
+{
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.test.proxy.binding.BindingTest#echo(java.lang.String)
+ */
+ public String echo(String param)
+ {
+ return param;
+ }
+
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/LocalJndiBindingTest.java (from rev 79234, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/binding/LocalJndiBindingTest.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/LocalJndiBindingTest.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/LocalJndiBindingTest.java 2008-10-08 06:35:55 UTC (rev 79258)
@@ -0,0 +1,39 @@
+/*
+ * 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.jndiregistrar;
+
+/**
+ * LocalJndiBindingTest
+ *
+ * Local Business Interface defining an overridden
+ * JNDI Binding
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface LocalJndiBindingTest extends BindingTest
+{
+ /*
+ * Define an overridden JNDI Binding
+ */
+ String JNDI_BINDING = "MyOverriddenBinding/local";
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/RemoteJndiBindingTest.java (from rev 79234, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/binding/RemoteJndiBindingTest.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/RemoteJndiBindingTest.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/RemoteJndiBindingTest.java 2008-10-08 06:35:55 UTC (rev 79258)
@@ -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.jndiregistrar;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+/**
+ * RemoteJndiBindingTest
+ *
+ * Remote Business Interface defining three overridden
+ * JNDI Bindings, as well as access to test a local binding
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at RemoteBinding(jndiBinding = RemoteJndiBindingTest.JNDI_BINDING_DECLARED_BY_BUSINESS_INTERFACE)
+public interface RemoteJndiBindingTest extends BindingTest
+{
+ /*
+ * Define some overridden JNDI Bindings to be declared by the EJB Impl Class
+ */
+ String JNDI_BINDING_1 = "MyOverriddenBinding1/remote";
+
+ String JNDI_BINDING_2 = "MyOverriddenBinding2/remote";
+
+ /**
+ * A JNDI Binding to be declared here on the business interface
+ */
+ String JNDI_BINDING_DECLARED_BY_BUSINESS_INTERFACE = "MyOverriddenBindingDeclaredByBusinessInterface/remote";
+}
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java 2008-10-08 06:33:43 UTC (rev 79257)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java 2008-10-08 06:35:55 UTC (rev 79258)
@@ -36,6 +36,8 @@
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
+import junit.framework.TestCase;
+
import org.jboss.aop.AspectManager;
import org.jboss.aop.AspectXmlLoader;
import org.jboss.ejb3.annotation.LocalBinding;
@@ -68,6 +70,10 @@
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.jboss.ejb3.test.proxy.jndiregistrar.BindingTest;
+import org.jboss.ejb3.test.proxy.jndiregistrar.JndiBindingTestBean;
+import org.jboss.ejb3.test.proxy.jndiregistrar.LocalJndiBindingTest;
+import org.jboss.ejb3.test.proxy.jndiregistrar.RemoteJndiBindingTest;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
@@ -181,8 +187,89 @@
}
}
+
+ /**
+ * Ensures that bindings at N Remote Locations are made and may be
+ * invoked upon, and that all associated bindings are cleansed on undeploy
+ *
+ * EJBTHREE-1515
+ */
+ @Test
+ public void testMultipleRemoteJndiBindings() throws Throwable
+ {
+ // Create and bind the bean into JNDI
+ this.sessionContainer = Utils.createSlsb(JndiBindingTestBean.class);
+ Ejb3RegistrarLocator.locateRegistrar().bind(this.sessionContainer.getName(), this.sessionContainer);
+
+ // Initialize
+ String testMessage = "Find me at N JNDI Locations";
+ // Get a JNDI Context
+ Context context = new InitialContext(); // Props from jndi.properties on Client CP
+
+ // Lookup JNDI Binding Test EJB at Location 1, and invoke
+ Object location1 = context.lookup(RemoteJndiBindingTest.JNDI_BINDING_1);
+ TestCase.assertNotNull("Expected remote binding in JNDI at " + location1 + " was not found", location1);
+ TestCase.assertTrue(location1 instanceof BindingTest);
+ BindingTest test1 = (BindingTest) location1;
+ String result1 = test1.echo(testMessage);
+ TestCase.assertEquals(testMessage, result1);
+
+ // Lookup JNDI Binding Test EJB at Location 2, and invoke
+ Object location2 = context.lookup(RemoteJndiBindingTest.JNDI_BINDING_2);
+ TestCase.assertNotNull("Expected remote binding in JNDI at " + location2 + " was not found", location2);
+ TestCase.assertTrue(location2 instanceof BindingTest);
+ BindingTest test2 = (BindingTest) location2;
+ String result2 = test2.echo(testMessage);
+ TestCase.assertEquals(testMessage, result2);
+
+ // Lookup JNDI Binding Test EJB at Location 3, and invoke
+ Object location3 = context.lookup(RemoteJndiBindingTest.JNDI_BINDING_DECLARED_BY_BUSINESS_INTERFACE);
+ TestCase.assertNotNull("Expected remote binding in JNDI at " + location3 + " was not found", location2);
+ TestCase.assertTrue(location3 instanceof BindingTest);
+ BindingTest test3 = (BindingTest) location3;
+ String result3 = test3.echo(testMessage);
+ TestCase.assertEquals(testMessage, result3);
+
+ // Unbind and test
+ this.unbindAndTest(context, this.sessionContainer);
+ }
+
/**
+ * Ensures that an alternate local binding is made and may
+ * be invoked upon, and that all associated bindings are cleansed
+ * upon undeploy
+ *
+ * EJBTHREE-1515
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAlternateLocalJndiBinding() throws Throwable
+ {
+ // Create and bind the bean into JNDI
+ this.sessionContainer = Utils.createSlsb(JndiBindingTestBean.class);
+ Ejb3RegistrarLocator.locateRegistrar().bind(this.sessionContainer.getName(), this.sessionContainer);
+
+ // Initialize
+ String testMessage = "Find me at Overridden Local JNDI Location";
+
+ // Get a JNDI Context
+ Context context = new InitialContext(); // Props from jndi.properties on Client CP
+
+ // Lookup JNDI Binding Test EJB at alternate local location, and invoke
+ Object localLocation = context.lookup(LocalJndiBindingTest.JNDI_BINDING);
+ TestCase.assertNotNull("Expected local binding in JNDI at " + localLocation + " was not found", localLocation);
+ TestCase.assertTrue(localLocation instanceof BindingTest);
+ BindingTest test = (BindingTest) localLocation;
+ String result = test.echo(testMessage);
+ TestCase.assertEquals(testMessage, result);
+
+ // Unbind and test
+ this.unbindAndTest(context, this.sessionContainer);
+ }
+
+ /**
* Test that the 2.x SLSB bean is unbound from the jndi, after the
* {@link JndiStatelessSessionRegistrar#unbindEjb(Context, org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData)}
* is called. <br>
@@ -862,6 +949,20 @@
jndiNames.add(metadata.getLocalHomeJndiName());
// remote home jndi name
jndiNames.add(metadata.getHomeJndiName());
+
+ // Remote Bindings
+ List<RemoteBindingMetaData> remoteBindings = metadata.getRemoteBindings();
+ if (remoteBindings != null)
+ {
+ for (RemoteBindingMetaData remoteBinding : remoteBindings)
+ {
+ String remoteBindingJndiName = remoteBinding.getJndiName();
+ if (remoteBindingJndiName != null && remoteBindingJndiName.trim().length() > 0)
+ {
+ jndiNames.add(remoteBindingJndiName);
+ }
+ }
+ }
// Interface specific Business remote jndi names
BusinessRemotesMetaData businessRemotesMetadata = metadata.getBusinessRemotes();
@@ -926,6 +1027,11 @@
continue;
}
+ catch(Throwable t)
+ {
+ throw new RuntimeException("JNDI Name " + jndiName
+ + " was not unbound, and further an exception was raised upon lookup", t);
+ }
}
More information about the jboss-cvs-commits
mailing list