jboss - Test the remote client jndi lookup using arquillian -


setup: arquillian, jboss 7.1.1.final managed container

i migrating ejb application ejb 2.x 3.x , jboss 3.x jboss 7.1. during process classes under test , stumbled on arquillian. while arquillian seems offer nice features on inter-bean-functionality cannot figure out whether or not testing of remote client features using jndi lookups works or not.

i used arquillian getting started guides on beans worked, since these using @inject , in application jndi lookups used everywhere (at least think i) need swerve path.

here testcase created based on arquillian getting started. explicitly left in attempts using jndi properties of thought might help.

the test

should_create_greeting() 

works if greeter bean using separate producer.

@runwith(arquillian.class) public class greetertest {     public static final string archive_name = "test";      logger logger = logger.getlogger(greetertest.class.getname());      @deployment     public static archive<?> createdeployment() {         javaarchive jar = shrinkwrap.create(javaarchive.class, archive_name + ".jar").addpackage(greeter.class.getpackage())             .addasmanifestresource("test-persistence.xml", "persistence.xml").addasmanifestresource("oracleguids-ds.xml")             .addasmanifestresource(emptyasset.instance, "beans.xml");     return jar;     }      /**      * @inject works using producer {@code @produces}      */      // @inject      // greeter greeter;      @arquillianresource      context context;       greeterremote greeter;       @before      public void before() throws exception {          map<string, string> env = new hashmap<>();          env.put(context.initial_context_factory, "org.jboss.as.naming.initialcontextfactory");          env.put("jboss.naming.client.ejb.context", "true");          // env.put("jboss.naming.client.connect.options.org.xnio.options.sasl_policy_noplaintext",          // "false");          // env.put("jboss.naming.client.connect.options.org.xnio.options.sasl_policy_noanonymous",          // "false");          // env.put("jboss.naming.client.connectionprovider.create.options.org.xnio.options.ssl_enabled",          // "false");          (map.entry<string, string> entry : env.entryset()) {              context.addtoenvironment(entry.getkey(), entry.getvalue());          }          greeter = (greeterremote) context.lookup(archive_name + "/" + greeter.class.getsimplename() + "!"             + greeterremote.class.getname());      }       @test      public void should_create_greeting() {          assert.assertequals("hello, earthling!", greeter.creategreeting("earthling"));          greeter.greet(system.out, "earthling");      } 

}

is possible test running jndi lookup? missing something?

if want test remote features of ejb want run on client side , not in container.

you can configure deployment client side using @deployment(testable=false). @test methods run if remote client.

beyond can lookup bean via injected context if want.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -