// Add group with no prior groups.
try
{
gms.addUserToGroup("anonuser1", "testusertogroup1.group1");
Collection principals = ums.getUser("anonuser1").getSubject().getPrincipals();
assertTrue("anonuser1 should contain testusertogroup1.group1", principals.contains(new GroupPrincipalImpl(
"testusertogroup1.group1")));
}
catch (SecurityException sex)
{
assertTrue("should add user to group. exception caught: " + sex, false);
}
// Add group with existing groups.
try
{
gms.addUserToGroup("anonuser1", "testusertogroup1.group2");
Collection principals = ums.getUser("anonuser1").getSubject().getPrincipals();
assertTrue("anonuser1 should contain testusertogroup1.group2", principals.contains(new GroupPrincipalImpl(
"testusertogroup1.group2")));
}
catch (SecurityException sex)
{
assertTrue("should add user to group. exception caught: " + sex, false);