Skip to content

Commit

Permalink
WFLY-1077 IIOP subsystem: Fix naming tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tadamski committed Jan 13, 2015
1 parent c0ebcb6 commit 6fd41d1
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 47 deletions.
@@ -0,0 +1,61 @@
package org.jboss.as.test.integration.ejb.iiop.naming;

import java.rmi.RemoteException;
import java.util.Properties;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Tests that corba name lookups work from inside the AS itself - IIOP bean name defined in deployment descriptor
*
* @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a>
*/
@RunWith(Arquillian.class)
public class IIOPNamingInContainerDDNameTestCase {

@ArquillianResource
private ManagementClient managementClient;

@Deployment(name="test")
public static Archive<?> descriptorOverrideDeploy() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addPackage(IIOPNamingInContainerDDNameTestCase.class.getPackage())
.addAsManifestResource(IIOPNamingInContainerDDNameTestCase.class.getPackage(), "jboss-ejb3-naming.xml", "jboss-ejb3.xml");
}

/**
* <p>
* Tests the lookup of a bean that used the jboss-ejb3.xml deployment descriptor to override the COSNaming binding.
* So, insteand of looking for the standard test2/IIOPNamingBean context we will look for the configured
* bean/custom/name/IIOPNamingBean context.
* </p>
*
* @throws NamingException if an error occurs while looking up the bean.
* @throws RemoteException if an error occurs while invoking the remote bean.
*/
@Test
@OperateOnDeployment("test")
public void testIIOPNamingInvocationWithDDOverride() throws NamingException, RemoteException {
final Properties prope = new Properties();
final InitialContext context = new InitialContext(prope);
final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() + ":3528#bean/custom/name/IIOPNamingBean");
final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class);
final IIOPRemote result = object.create();
Assert.assertEquals("hello", result.hello());
}

}
Expand Up @@ -16,6 +16,7 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import java.rmi.NoSuchObjectException;
import java.rmi.RemoteException;
import java.util.Properties;
Expand All @@ -38,17 +39,9 @@ public static Archive<?> deploy() {
.addAsManifestResource(IIOPNamingInContainerTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml");
}

@Deployment(name="test2")
public static Archive<?> descriptorOverrideDeploy() {
return ShrinkWrap.create(JavaArchive.class, "test2.jar")
.addPackage(IIOPNamingInContainerTestCase.class.getPackage())
.addAsManifestResource(IIOPNamingInContainerTestCase.class.getPackage(), "jboss-ejb3-naming.xml", "jboss-ejb3.xml");
}

@Test
@OperateOnDeployment("test")
public void testIIOPNamingInvocation() throws NamingException, RemoteException {

final Properties prope = new Properties();
final InitialContext context = new InitialContext(prope);
final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() + ":3528#IIOPNamingBean");
Expand All @@ -75,27 +68,4 @@ public void testStatefulIIOPNamingInvocation() throws NamingException, RemoteExc

}
}

/**
* <p>
* Tests the lookup of a bean that used the jboss-ejb3.xml deployment descriptor to override the COSNaming binding.
* So, insteand of looking for the standard test2/IIOPNamingBean context we will look for the configured
* bean/custom/name/IIOPNamingBean context.
* </p>
*
* @throws NamingException if an error occurs while looking up the bean.
* @throws RemoteException if an error occurs while invoking the remote bean.
*/
@Test
@OperateOnDeployment("test2")
public void testIIOPNamingInvocationWithDDOverride() throws NamingException, RemoteException {
final Properties prope = new Properties();
final InitialContext context = new InitialContext(prope);
final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() + ":3528#bean/custom/name/IIOPNamingBean");
final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class);
final IIOPRemote result = object.create();
Assert.assertEquals("hello", result.hello());
}


}
@@ -1,5 +1,19 @@
package org.jboss.as.test.integration.ejb.iiop.naming;

import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assume.assumeThat;
import static org.junit.matchers.JUnitMatchers.containsString;

import java.rmi.NoSuchObjectException;
import java.rmi.RemoteException;
import java.util.Properties;

import javax.ejb.RemoveException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
Expand All @@ -13,21 +27,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ejb.RemoveException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import java.rmi.NoSuchObjectException;
import java.rmi.RemoteException;
import java.util.Properties;

import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assume.assumeThat;
import static org.junit.matchers.JUnitMatchers.containsString;

/**
* @author Stuart Douglas
* @author <a href="mailto:tadamski@redhat.com">Tomasz Adamski</a>
*/
@RunWith(Arquillian.class)
@RunAsClient
Expand Down Expand Up @@ -59,7 +61,7 @@ private static String property(final String name) {
public void testIIOPNamingInvocation() throws NamingException, RemoteException {
final Properties prope = new Properties();
prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() + ":3528/JBoss/Naming/root");
prope.put(Context.PROVIDER_URL, "corbaloc::" +managementClient.getMgmtAddress() + ":3528/NameService");
final InitialContext context = new InitialContext(prope);
final Object iiopObj = context.lookup("IIOPNamingBean");
final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class);
Expand All @@ -71,7 +73,7 @@ public void testIIOPNamingInvocation() throws NamingException, RemoteException {
public void testStatefulIIOPNamingInvocation() throws NamingException, RemoteException, RemoveException {
final Properties prope = new Properties();
prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() +":3528/JBoss/Naming/root");
prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() +":3528/NameService");
final InitialContext context = new InitialContext(prope);
final Object iiopObj = context.lookup("IIOPStatefulNamingBean");
final IIOPStatefulNamingHome object = (IIOPStatefulNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPStatefulNamingHome.class);
Expand Down Expand Up @@ -168,7 +170,7 @@ public void testStatefulIIOPNamingIIOPInvocation() throws NamingException, Remot
public void testCorbalocInvocationWithDDOverride() throws NamingException, RemoteException {
final Properties prope = new Properties();
prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() +":3528/JBoss/Naming/root");
prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() +":3528/NameService");
final InitialContext context = new InitialContext(prope);
final Object iiopObj = context.lookup("bean/custom/name/IIOPNamingBean");
final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class);
Expand Down

0 comments on commit 6fd41d1

Please sign in to comment.