use of org.apache.qpid.server.security.group.FileGroupDatabase in project qpid-broker-j by apache.
the class FileGroupDatabaseTest method testRemoveGroupPersistedToFile.
public void testRemoveGroupPersistedToFile() throws Exception {
writeAndSetGroupFile("myGroup1.users", "user1,user2", "myGroup2.users", "user1,user2");
Set<String> groups = _groupDatabase.getAllGroups();
assertEquals(2, groups.size());
Set<String> groupsForUser1 = _groupDatabase.getGroupsForUser(USER1);
assertEquals(2, groupsForUser1.size());
_groupDatabase.removeGroup(MY_GROUP1);
groups = _groupDatabase.getAllGroups();
assertEquals(1, groups.size());
assertTrue(groups.contains(MY_GROUP2));
groupsForUser1 = _groupDatabase.getGroupsForUser(USER1);
assertEquals(1, groupsForUser1.size());
FileGroupDatabase newGroupDatabase = new FileGroupDatabase();
newGroupDatabase.setGroupFile(_groupFile);
Set<String> newGroups = newGroupDatabase.getAllGroups();
assertEquals(1, newGroups.size());
assertTrue(newGroups.contains(MY_GROUP2));
Set<String> newGroupsForUser1 = newGroupDatabase.getGroupsForUser(USER1);
assertEquals(1, newGroupsForUser1.size());
assertTrue(newGroupsForUser1.contains(MY_GROUP2));
}
Aggregations