use of org.glassfish.tests.embedded.ejb.remoteejb.RemoteEJBInf in project Payara by payara.
the class EJBTest method test.
@Test
public void test() throws Exception {
glassfish = GlassFishRuntime.bootstrap().newGlassFish();
glassfish.start();
Deployer deployer = glassfish.getDeployer();
URI uri = new File(System.getProperty("user.dir"), "target/remoteejb.jar").toURI();
System.out.println("Deploying [" + uri + "]");
deployer.deploy(uri);
InitialContext ic = new InitialContext();
System.out.println("Looking up SampleEJB.");
SampleEjb sampleEjb = (SampleEjb) ic.lookup("java:global/remoteejb/SampleEjb");
System.out.println("Invoking SampleEjb [" + sampleEjb + "]");
Assert.assertEquals(sampleEjb.saySomething(), "Hello World");
System.out.println("SampleEjb tested successfully");
System.out.println("Looking up TimerEjb.");
TimerEjb timerEjb = (TimerEjb) ic.lookup("java:global/remoteejb/TimerEjb");
System.out.println("Invoking TimerEjb [" + timerEjb + "]");
timerEjb.createTimer();
System.out.println("Verifying TimerEjb [" + timerEjb + "]");
Thread.sleep(4000);
boolean result = timerEjb.verifyTimer();
Assert.assertTrue(result);
System.out.println("TimerEJB tested successfully.");
// ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
// try {
System.out.println("Looking up RemoteEJB.");
// Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
RemoteEJBInf remoteEjb = (RemoteEJBInf) ic.lookup("java:global/remoteejb/RemoteEJB");
System.out.println("Invoking RemoteEJB [" + remoteEjb + "]");
Assert.assertEquals(remoteEjb.sayHi(), "Hi Bhavani");
System.out.println("RemoteEjb tested successfully");
// } finally {
// Thread.currentThread().setContextClassLoader(oldCL);
// }
glassfish.stop();
glassfish.dispose();
System.out.println("EmbeddedTest completed.");
}
Aggregations