SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("somebody", "password");
client.login();
System.out.println("testPassivation");
Stateless stateless = (Stateless)getInitialContext().lookup("Stateless");
stateless.testInjection();
ServiceRemote service = (ServiceRemote) getInitialContext().lookup("ServiceBean/remote");
service.testInjection();
ClusteredStateful stateful = (ClusteredStateful)getInitialContext().lookup("ClusteredStateful");
assertNotNull(stateful);
stateful.setState("state");
assertEquals("state", stateful.getState());
stateful.testSerializedState("state");
assertEquals(null, stateful.getInterceptorState());
stateful.setInterceptorState("hello world");
assertFalse(stateful.testSessionContext());
Thread.sleep(10 * 1000);
assertTrue(stateful.wasPassivated());
assertEquals("state", stateful.getState());
assertEquals("hello world", stateful.getInterceptorState());
Stateful another = (Stateful)getInitialContext().lookup("Stateful");
assertEquals(null, another.getInterceptorState());
another.setInterceptorState("foo");
assertEquals("foo", another.getInterceptorState());
assertEquals("hello world", stateful.getInterceptorState());
assertFalse(stateful.testSessionContext());
stateful.testResources();
stateless.testInjection();
service.testInjection();
}