use of org.glassfish.tests.embedded.ejb.basic.TimerEjb in project Payara by payara.
the class EmbeddedTest method test.
/*
public static void main(String[] args) {
EmbeddedTest test = new EmbeddedTest();
System.setProperty("basedir", System.getProperty());
test.test();
}
*/
@Test
public void test() throws Exception {
GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish();
glassfish.start();
Deployer deployer = glassfish.getDeployer();
URI uri = new File(System.getProperty("user.dir"), "target/classes").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/classes/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/classes/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.");
glassfish.stop();
glassfish.dispose();
System.out.println("EmbeddedTest completed.");
}
Aggregations