[jboss-dev-forums] [Design of EJB 3.0] - Re: EJBTHREE-1423 Test case for @RemoteBinding
jaikiran
do-not-reply at jboss.com
Thu Jul 10 07:23:04 EDT 2008
The testcase fails on 1.0.0.Beta27 of JBossMetadata. The test includes:
1) Ensure that the @RemoteBinding is picked up and the corresponding RemoteBindingMetaData is created an stored in the JBossSessionBeanMetaData. --> This passes
2) Ensure that the bean is bound to the jndi-name specified in the RemoteBindingMetaData. --> This fails.
Here's the bean definition:
@Stateless
| @Remote (MyStatelessRemote.class)
| @Local (MyStatelessLocal.class)
| @RemoteBinding (jndiBinding="SomeRemoteName")
| public class MyStatelessBeanWithBindings implements MyStatelessLocal, MyStatelessRemote
| {
|
| ...
|
| }
|
Here's the relevant part from the test case:
@Test
| public void testRemoteBinding() throws Throwable
| {
| // create the bean
| SessionContainer sessionContainer = Utils.createSlsb(MyStatelessBeanWithBindings.class);
|
| // bind it to JNDI
| Ejb3RegistrarLocator.locateRegistrar().bind(sessionContainer.getName(), sessionContainer);
|
| List<RemoteBindingMetaData> remoteBindingsMetadata = sessionContainer.getMetaData().getRemoteBindings();
|
| assertNotNull("No RemoteBindingMetadata available", remoteBindingsMetadata);
| // make sure that the remotebinding metadata list has 1 @RemoteBinding information
| assertEquals("RemoteBindingMetadata does not have any RemoteBinding information available", remoteBindingsMetadata.size(), 1);
|
|
| // Ensure that the RemoteBindingMetaData is created properly with the specified jndiBinding name.
| Iterator<RemoteBindingMetaData> remoteBindingsMetadataIterator = remoteBindingsMetadata.iterator();
| RemoteBindingMetaData remoteBindingMetadata = remoteBindingsMetadataIterator.next();
|
| assertEquals("RemoteBinding JNDI name does not match SomeRemoteName", "SomeRemoteName", remoteBindingMetadata.getJndiName());
|
| // Now ensure that the RemoteBindingMetaData is used for binding the
| // remote interface of the bean.
| Context ctx = new InitialContext();
| Object remoteBean = ctx.lookup(remoteBindingMetadata.getJndiName());
|
| assertNotNull("Remote bean returned from JNDI lookup for jndi-name " + remoteBindingMetadata.getJndiName() + " is null");
|
| assertTrue("Remote bean returned from JNDI lookup is NOT an instance of " + MyStatelessRemote.class, (remoteBean instanceof MyStatelessRemote)); ---> This fails. The jndi object returned is org.jnp.interfaces.NamingContext at 145e2d5
|
| }
|
Upon some debugging, i observed that the org.jboss.metadata.ejb.jboss.JBossSessionPolicyDecorator.determineJndiName returns an incorrect jndi-name:
16:40:47,623 INFO [MetaDataHelper] Business Remote JNDI Name: SomeRemoteName/remote
| 16:40:47,639 INFO [MetaDataHelper] Business Remote JNDI Name for org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemote: SomeRemoteName/remote-org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemote
| 16:40:47,639 INFO [MetaDataHelper] Local JNDI Name: SomeRemoteName/local
| 16:40:47,639 INFO [MetaDataHelper] Business Local JNDI Name for org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessLocal: SomeRemoteName/local-org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessLocal
|
As a result, the bean gets bound to SomeRemoteName/remote instead of SomeRemoteName.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163547#4163547
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4163547
More information about the jboss-dev-forums
mailing list