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
}
}
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());
}
}
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());
}
}
Aggregations