Search in sources :

Example 1 with EncStatefulObject

use of org.apache.openejb.test.stateful.EncStatefulObject in project tomee by apache.

the class RedeployTest method createAndDestroy.

private void createAndDestroy(final Assembler assembler, final ConfigurationFactory config, final File file) throws Exception {
    // Deploy the file
    assembler.createApplication(config.configureApplication(file));
    // Lookup and execute a bean
    final Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    final InitialContext ctx = new InitialContext(properties);
    final EncStatefulHome home = (EncStatefulHome) ctx.lookup(AnnotatedFieldInjectionStatefulBean.class.getSimpleName());
    final EncStatefulObject ejbObject = home.create("foo");
    ejbObject.lookupStringEntry();
    // Undeploy the file
    assembler.destroyApplication(file.getCanonicalPath());
    // Try and execute the bean after it's been undeployed -- should fail
    try {
        ejbObject.lookupStringEntry();
        fail("Proxy should no longer be valid");
    } catch (final Exception e) {
    // this should happen
    }
    try {
        ctx.lookup(AnnotatedFieldInjectionStatefulBean.class.getSimpleName());
        fail("JNDI References should have been cleaned up");
    } catch (final NamingException e) {
    // this also should happen
    }
}
Also used : EncStatefulObject(org.apache.openejb.test.stateful.EncStatefulObject) NamingException(javax.naming.NamingException) AnnotatedFieldInjectionStatefulBean(org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean) Properties(java.util.Properties) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) EncStatefulHome(org.apache.openejb.test.stateful.EncStatefulHome) InitialContext(javax.naming.InitialContext) NamingException(javax.naming.NamingException)

Example 2 with EncStatefulObject

use of org.apache.openejb.test.stateful.EncStatefulObject in project tomee by apache.

the class MiscEjbTests method test02_isIdentical_stateful.

public void test02_isIdentical_stateful() {
    try {
        final String jndiName = "client/tests/stateful/EncBean";
        EncStatefulHome ejbHome2 = null;
        EncStatefulObject ejbObject2 = null;
        final Object obj = initialContext.lookup(jndiName);
        ejbHome2 = (EncStatefulHome) obj;
        ejbObject2 = ejbHome2.create("isIdentical test");
        //System.out.println("_______________________________________________________");
        //System.out.println(" ejb1 "+ejbObject);
        //System.out.println(" ejb2 "+ejbObject2);
        assertTrue("The EJBObjects should not be identical", !ejbObject.isIdentical(ejbObject2));
    //System.out.println("-------------------------------------------------------");
    } catch (final Exception e) {
        //System.out.println("-------------------------------------------------------");
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EncStatefulObject(org.apache.openejb.test.stateful.EncStatefulObject) EncCmpObject(org.apache.openejb.test.entity.cmp.EncCmpObject) EncStatefulObject(org.apache.openejb.test.stateful.EncStatefulObject) EncBmpObject(org.apache.openejb.test.entity.bmp.EncBmpObject) EncStatefulHome(org.apache.openejb.test.stateful.EncStatefulHome)

Example 3 with EncStatefulObject

use of org.apache.openejb.test.stateful.EncStatefulObject in project tomee by apache.

the class MiscEjbTests method test02_isIdentical_stateful.

public void test02_isIdentical_stateful() {
    try {
        final String jndiName = "client/tests/stateful/EncBean";
        EncStatefulHome ejbHome2 = null;
        EncStatefulObject ejbObject2 = null;
        final Object obj = initialContext.lookup(jndiName);
        ejbHome2 = (EncStatefulHome) obj;
        ejbObject2 = ejbHome2.create("isIdentical test");
        //System.out.println("_______________________________________________________");
        //System.out.println(" ejb1 "+ejbObject);
        //System.out.println(" ejb2 "+ejbObject2);
        assertTrue("The EJBObjects should not be identical", !ejbObject.isIdentical(ejbObject2));
    //System.out.println("-------------------------------------------------------");
    } catch (final Exception e) {
        //System.out.println("-------------------------------------------------------");
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EncStatefulObject(org.apache.openejb.test.stateful.EncStatefulObject) EncCmpObject(org.apache.openejb.test.entity.cmp.EncCmpObject) EncStatefulObject(org.apache.openejb.test.stateful.EncStatefulObject) EncBmpObject(org.apache.openejb.test.entity.bmp.EncBmpObject) EncStatefulHome(org.apache.openejb.test.stateful.EncStatefulHome)

Aggregations

EncStatefulHome (org.apache.openejb.test.stateful.EncStatefulHome)3 EncStatefulObject (org.apache.openejb.test.stateful.EncStatefulObject)3 EncBmpObject (org.apache.openejb.test.entity.bmp.EncBmpObject)2 EncCmpObject (org.apache.openejb.test.entity.cmp.EncCmpObject)2 Properties (java.util.Properties)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)1 AnnotatedFieldInjectionStatefulBean (org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean)1