@Override
protected void setUp() throws Exception {
super.setUp();
if (!(superuser instanceof SessionImpl)) {
throw new NotExecutableException("SessionImpl expected.");
}
sImpl = (SessionImpl) superuser;
UserManager umgr = sImpl.getUserManager();
if (umgr.isAutoSave()) {
try {
umgr.autoSave(false);
} catch (RepositoryException e) {
// user manager cannot have the autosave behavior changed
// -> test not executable
throw new NotExecutableException("Expected user manager that can have its autosave behavior changed to false.");
}
}
this.umgr = (UserManagerImpl) umgr;
// avoid collision with testing a-folders that may have been created
// with another test (but not removed as user/groups got removed)
String path = this.umgr.getUsersPath() + "/t";
if (sImpl.nodeExists(path)) {
sImpl.getNode(path).remove();
}
path = this.umgr.getGroupsPath() + "/g";
if (sImpl.nodeExists(path)) {
sImpl.getNode(path).remove();
}
sImpl.save();
Authorizable administrators = umgr.getAuthorizable(SecurityConstants.ADMINISTRATORS_NAME);
if (administrators == null) {
groupIdToRemove = umgr.createGroup(new PrincipalImpl(SecurityConstants.ADMINISTRATORS_NAME)).getID();
sImpl.save();
} else if (!administrators.isGroup()) {
throw new NotExecutableException("Expected " + administrators.getID() + " to be a group.");
}
}