@Test(timeout = 5000)
public void testAuthorizableBeanListener() {
COUNT_AUTHORIZATION_CHANGED = 0;
COUNT_BEAN_CHANGED = 0;
BeanDocument autorizableBean = new BeanDocument(CampaignClient
.getInstance().getRootDirectory(), "test-document-name",
"document-type", new ImageBean(TestMap.createTransfertImage()));
autorizableBean = addBean(autorizableBean);
autorizableBean.addPropertyChangeListener(new AuthorizationAdapter() {
@Override
public void authorizationChanged(PropertyChangeEvent evt) {
COUNT_AUTHORIZATION_CHANGED++;
}
});
autorizableBean.getBean().addPropertyChangeListener(
new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
COUNT_BEAN_CHANGED++;
}
});
((ImageBean) autorizableBean.getBean()).setImage(TestMap
.createTransfertImage());
sleep();
assertEquals("The bean have changed", 1, COUNT_BEAN_CHANGED);
assertEquals("The authorization have not changed", 0,
COUNT_AUTHORIZATION_CHANGED);
UniqueID guid = new UniqueID();
autorizableBean.addModifier(guid);
sleep();
autorizableBean.removeModifier(guid);
autorizableBean.addUser(guid);
sleep();
autorizableBean.removeUser(guid);
sleep();
autorizableBean.setPublic(true);
sleep();
autorizableBean.setPublic(false);
sleep();
HashSet<UniqueID> users = new HashSet<UniqueID>();
users.add(new UniqueID());
autorizableBean.setUsers(users);
sleep();
autorizableBean.setModifiers(users);
sleep();
assertEquals("The authorization have not changed", 8,
COUNT_AUTHORIZATION_CHANGED);
assertEquals("The bean have changed", 1, COUNT_BEAN_CHANGED);