Search in sources :

Example 1 with TimerEjb

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.");
}
Also used : SampleEjb(org.glassfish.tests.embedded.ejb.basic.SampleEjb) GlassFish(org.glassfish.embeddable.GlassFish) URI(java.net.URI) File(java.io.File) TimerEjb(org.glassfish.tests.embedded.ejb.basic.TimerEjb) Deployer(org.glassfish.embeddable.Deployer) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

File (java.io.File)1 URI (java.net.URI)1 InitialContext (javax.naming.InitialContext)1 Deployer (org.glassfish.embeddable.Deployer)1 GlassFish (org.glassfish.embeddable.GlassFish)1 SampleEjb (org.glassfish.tests.embedded.ejb.basic.SampleEjb)1 TimerEjb (org.glassfish.tests.embedded.ejb.basic.TimerEjb)1 Test (org.junit.Test)1