// get a reference to the remote run-as session.
Object obj = getInitialContext().lookup("RunAsSessionBean/remote");
RunAsSession session = (RunAsSession) PortableRemoteObject.narrow(obj, RunAsSession.class);
// invoke the session, that delegates the invocation to the delegate session using @RunAs.
Principal principal = session.invokeRunAs();
assertNotNull("Found unexpected null principal", principal);
// run-as identity should be the default unauthenticated identity configured in the login module.
assertEquals("anonymous", principal.getName());
this.logout();