getLog().debug("");
getLog().debug("Test Stateful Bean");
getLog().debug("==================");
getLog().debug("");
getLog().debug(++test+"- "+"Looking up the home nextgen.StatefulSession...");
StatefulSessionHome statefulSessionHome =
(StatefulSessionHome) ctx.lookup("nextgen.StatefulSession");
assertTrue("statefulSessionHome!= null", statefulSessionHome!= null);
getLog().debug("ok");
getLog().debug(++test+"- "+"Calling create on StatefulSessionHome with name Marc...");
StatefulSession statefulSession =
statefulSessionHome.create("Marc");
assertTrue("statefulSession != null", statefulSession != null);
getLog().debug("ok");
getLog().debug(++test+"- "+"Calling getEJBHome() on StatefulSession...");
assertTrue("statefulSession.getEJBHome() != null", statefulSession.getEJBHome() != null);
getLog().debug("ok");
getLog().debug(++test+"- "+"Calling Business Method A on StatefulSession... ");
getLog().debug(statefulSession.callBusinessMethodA());
getLog().debug(++test+"- "+"Calling Business Method A (state) on StatefulSession... ");
getLog().debug(statefulSession.callBusinessMethodA());
getLog().debug(++test+"- "+"Calling Business Method B (EJBObject) on StatefulSession... ");
getLog().debug(statefulSession.callBusinessMethodB());
getLog().debug(++test+"- "+"Calling Business Method B(String) on StatefulSession... ");
getLog().debug(statefulSession.callBusinessMethodB("of wisdom"));
getLog().debug("***Testing the various local Object class calls");
getLog().debug(++test+"- "+"toString ... ");
getLog().debug(statefulSession.toString());
getLog().debug(++test+"- "+"hashCode ... " +
statefulSession.hashCode());
getLog().debug(++test+"- "+"equals (same object) ... " +
statefulSession.equals(statefulSession));
getLog().debug(++test+"- "+"equals (another object) (false under same home)... " +
statefulSession.equals(statefulSessionHome.create("marc4")));
getLog().debug("***Testing the various local EJBObject class calls");
getLog().debug(++test+"- "+"Get Handle ... ");
Handle statefulHandle = statefulSession.getHandle();
assertTrue("statefulHandle != null", statefulHandle != null);
getLog().debug("OK");
getLog().debug(++test+"- "+"Serialize handle and deserialize....");
MarshalledObject mo2 = new MarshalledObject(statefulHandle);
Handle statefulHandle2 = (Handle) mo2.get();
StatefulSession statefulSession2 = (StatefulSession) statefulHandle2.getEJBObject();
assertTrue("statefulSession2 != null", statefulSession2 != null);
getLog().debug("OK");
getLog().debug(++test+"- "+"Calling businessMethodB on it..." +
statefulSession2.callBusinessMethodB());
getLog().debug(++test+"- "+"They should be identical..." +
statefulSession.isIdentical(statefulSession2));
getLog().debug(++test+"- "+"Calling StatefulSession.remove()...");
statefulSession.remove();
getLog().debug("ok");
getLog().debug(++test+"- "+"Calling StatefulHome.remove(Handle) (this should fail)...");
try
{
statefulSessionHome.remove(statefulSession2.getHandle());
fail("statefulSessionHome.remove did not fail");
}
catch (Exception e)
{
getLog().debug("not found OK");
}
getLog().debug(++test+"- "+"Creating a 3rd bean and calling it...");
StatefulSession ss3 = statefulSessionHome.create("marc3");
getLog().debug(ss3.callBusinessMethodA());
getLog().debug(++test+"- "+"Calling StatefulSession.remove(Handle) on a third bean...");
Handle statefulHandle3 = ss3.getHandle();
statefulSessionHome.remove(statefulHandle3);
getLog().debug("OK");
getLog().debug(++test+"- "+"I should not be able to remove it directly...");
try {
ss3.remove();
fail("ss3.remove() did not fail");
} catch (Exception e) {
getLog().debug("OK");
}
getLog().debug(++test+"- "+"Creating a 4th bean using create<METHOD> and calling it...");
StatefulSession ss4 = statefulSessionHome.createMETHOD("marc4", "address");
getLog().debug(ss4.callBusinessMethodA());
getLog().debug(++test+"- "+"Calling StatefulSession.remove(Handle) on a fourth bean...");
Handle statefulHandle4 = ss4.getHandle();
statefulSessionHome.remove(statefulHandle4);
}