[jboss-cvs] JBossAS SVN: r79356 - in projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar: unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 10 20:31:15 EDT 2008
Author: ALRubinger
Date: 2008-10-10 20:31:15 -0400 (Fri, 10 Oct 2008)
New Revision: 79356
Added:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/RemoteBindingNoJndiBindingTestBean.java
Modified:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java
Log:
[EJBTHREE-1525] Added Unit Test for @RemoteBinding w/ no jndiBinding attribute
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/RemoteBindingNoJndiBindingTestBean.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/RemoteBindingNoJndiBindingTestBean.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/RemoteBindingNoJndiBindingTestBean.java 2008-10-11 00:31:15 UTC (rev 79356)
@@ -0,0 +1,47 @@
+/*
+ * 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.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+/**
+ * RemoteBindingNoJndiBindingTestBean
+ *
+ * Tests that an EJB with @RemoteBinding but no JNDI Binding
+ * defined is bound to the correct location (as obtained from
+ * JBossSessionBeanMetaData.getJndiName())
+ *
+ * EJBTHREE-1525
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(RemoteJndiBindingTest.class)
+ at RemoteBinding(factory = "SomethingFake")
+public class RemoteBindingNoJndiBindingTestBean extends JndiBindingTestBeanBase implements RemoteJndiBindingTest
+{
+
+}
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-10 22:51:20 UTC (rev 79355)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java 2008-10-11 00:31:15 UTC (rev 79356)
@@ -77,6 +77,7 @@
import org.jboss.ejb3.test.proxy.jndiregistrar.ClientBindUrlTestBean;
import org.jboss.ejb3.test.proxy.jndiregistrar.JndiBindingTestBean;
import org.jboss.ejb3.test.proxy.jndiregistrar.LocalJndiBindingTest;
+import org.jboss.ejb3.test.proxy.jndiregistrar.RemoteBindingNoJndiBindingTestBean;
import org.jboss.ejb3.test.proxy.jndiregistrar.RemoteJndiBindingTest;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
@@ -193,6 +194,47 @@
}
/**
+ * Tests that an EJB with @RemoteBinding defined with no "jndiBinding" attribute
+ * is bound as expected to the default JNDI name
+ *
+ * EJBTHREE-1525
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testRemoteBindingButNoJndiBinding() throws Throwable
+ {
+ // Create and bind the bean into JNDI
+ this.sessionContainer = Utils.createSlsb(RemoteBindingNoJndiBindingTestBean.class);
+ Ejb3RegistrarLocator.locateRegistrar().bind(this.sessionContainer.getName(), this.sessionContainer);
+
+ // Get a JNDI Context
+ Context context = new InitialContext(); // Props from jndi.properties on Client CP
+
+ // Lookup JNDI Binding Test EJB at location defined by metadata
+ JBossSessionBeanMetaData smd = this.sessionContainer.getMetaData();
+ String jndiBinding = smd.getJndiName();
+ Object ejb = null;
+ try
+ {
+ ejb = context.lookup(jndiBinding);
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ fail("EJB was not bound as expected into JNDI at " + jndiBinding);
+ }
+ TestCase.assertNotNull("Expected remote binding in JNDI at " + jndiBinding + " was not found", ejb);
+ TestCase.assertTrue(ejb instanceof BindingTest);
+ BindingTest test = (BindingTest) ejb;
+ String passed = "Testing ALR";
+ String returnValue = test.echo(passed);
+ TestCase.assertEquals(passed, returnValue);
+
+ // Unbind and test
+ this.unbindAndTest(context, this.sessionContainer);
+ }
+
+ /**
* Ensures that bindings at N Remote Locations are made and may be
* invoked upon, and that all associated bindings are cleansed on undeploy
*
@@ -204,7 +246,7 @@
// 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";
@@ -213,7 +255,8 @@
// 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.assertNotNull("Expected remote binding in JNDI at " + RemoteJndiBindingTest.JNDI_BINDING_1
+ + " was not found", location1);
TestCase.assertTrue(location1 instanceof BindingTest);
BindingTest test1 = (BindingTest) location1;
String result1 = test1.echo(testMessage);
@@ -221,7 +264,8 @@
// 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.assertNotNull("Expected remote binding in JNDI at " + RemoteJndiBindingTest.JNDI_BINDING_2
+ + " was not found", location2);
TestCase.assertTrue(location2 instanceof BindingTest);
BindingTest test2 = (BindingTest) location2;
String result2 = test2.echo(testMessage);
@@ -229,12 +273,13 @@
// 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.assertNotNull("Expected remote binding in JNDI at "
+ + RemoteJndiBindingTest.JNDI_BINDING_DECLARED_BY_BUSINESS_INTERFACE + " 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);
}
More information about the jboss-cvs-commits
mailing list