checkEmpty(service1);
checkEmpty(service2);
// prepare for syncing
UserGroupLoadedListener listener = new UserGroupLoadedListener() {
@Override
public void usersAndGroupsChanged(UserGroupLoadedEvent event) {
synchronized (this) {
this.notifyAll();
}
}
};
service2.registerUserGroupLoadedListener(listener);
// modifiy store1
store1.addGroup(group);
store1.store();
assertTrue(service1.getUserGroups().size()==1);
assertTrue(service1.getGroupCount()==1);
// increment lastmodified adding a second manually, the test is too fast
xmlFile.setLastModified(xmlFile.lastModified()+2000);
// wait for the listener to unlock when
// service 2 triggers a load event
synchronized (listener) {
listener.wait();
}
// here comes the magic !!!
assertTrue(service2.getUserGroups().size()==1);
assertTrue(service2.getGroupCount()==1);