use of org.osgi.service.useradmin.Role in project felix by apache.
the class CustomRoleImplTest method testRemoveRolePropertiesYieldsEvent.
/**
* Tests that changing the properties of a user-role yields an event.
*/
public void testRemoveRolePropertiesYieldsEvent() throws Exception {
final Role role = m_repository.addRole("testUser", Role.USER);
role.getProperties().put("key", "value");
assertNotNull(role);
m_latch = new CountDownLatch(1);
new Thread(new Runnable() {
public void run() {
role.getProperties().remove("key");
}
}).start();
assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class CustomRoleImplTest method testChangePropertiesYieldsEvent.
/**
* Tests that changing the credentials of a user-role yields an event.
*/
public void testChangePropertiesYieldsEvent() throws Exception {
final Role role = m_repository.addRole("testUser", Role.USER);
role.getProperties().put("key", "value1");
assertNotNull(role);
m_latch = new CountDownLatch(1);
new Thread(new Runnable() {
public void run() {
role.getProperties().put("key", "value2");
}
}).start();
assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class CustomRoleImplTest method testAddBasicGroupMemberYieldsEvent.
/**
* Tests that adding a basic member to a group-role yields an event.
*/
public void testAddBasicGroupMemberYieldsEvent() throws Exception {
final Group role = (Group) m_repository.addRole("testGroup", Role.GROUP);
assertNotNull(role);
m_latch = new CountDownLatch(1);
new Thread(new Runnable() {
public void run() {
Role anyone = m_repository.getRoleByName(Role.USER_ANYONE);
assertTrue(role.addMember(anyone));
}
}).start();
assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class CustomRoleImplTest method testRemovingGroupMemberYieldsEvent.
/**
* Tests that removing a member from a group-role yields an event.
*/
public void testRemovingGroupMemberYieldsEvent() throws Exception {
final Role anyone = m_repository.getRoleByName(Role.USER_ANYONE);
final Group role = (Group) m_repository.addRole("testGroup", Role.GROUP);
assertNotNull(role);
role.addRequiredMember(anyone);
m_latch = new CountDownLatch(1);
new Thread(new Runnable() {
public void run() {
assertTrue(role.removeMember(anyone));
}
}).start();
assertTrue(m_latch.await(100, TimeUnit.SECONDS));
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class MemoryRoleRepositoryStore method addRole.
public Role addRole(String roleName, int type) throws Exception {
if (roleName == null) {
throw new IllegalArgumentException("Name cannot be null!");
}
Role role = RoleFactory.createRole(type, roleName);
Object result = m_entries.putIfAbsent(roleName, role);
return (result == null) ? role : null;
}
Aggregations