Subject subject = context.getSubject();
assertTrue("expected non-null client subject", subject != null);
Set set = subject.getPrincipals(IdentificationPrincipal.class);
assertEquals("client subject should have one ID principal", set.size(), 1);
IdentificationPrincipal idp = (IdentificationPrincipal) set.iterator().next();
subject = ContextManager.getRegisteredSubject(idp.getId());
assertTrue("expected non-null server subject", subject != null);
assertTrue("server subject should have one remote principal", subject.getPrincipals(IdentificationPrincipal.class).size() == 1);
IdentificationPrincipal remote = subject.getPrincipals(IdentificationPrincipal.class).iterator().next();
assertTrue("server subject should be associated with remote id", ContextManager.getRegisteredSubject(remote.getId()) != null);
assertEquals("server-side subject should have seven principal", 7, subject.getPrincipals().size());
assertTrue("server subject should have two realm principal", subject.getPrincipals(RealmPrincipal.class).size() == 2);
assertTrue("server subject should have two domain principal", subject.getPrincipals(DomainPrincipal.class).size() == 2);
assertTrue("id of server subject should be non-null", ContextManager.getSubjectId(subject) != null);