use of org.osgi.service.useradmin.Role in project felix by apache.
the class RoleRepositoryTest method testChangeRolePropertyYieldsEventOk.
/**
* Tests whether changing an existing property to a role causes an event to be emitted to the {@link RoleRepository}.
*/
public void testChangeRolePropertyYieldsEventOk() throws Exception {
final Role role = m_roleRepository.addRole("john.doe", Role.USER);
role.getProperties().put("key", "value");
m_latch = new CountDownLatch(1);
new Thread(new Runnable() {
public void run() {
role.getProperties().put("key", "other-value");
}
}).start();
assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class RoleRepositoryTest method testAddRolePropertyYieldsEventOk.
/**
* Tests whether adding a new property to a role causes an event to be emitted to the {@link RoleRepository}.
*/
public void testAddRolePropertyYieldsEventOk() throws Exception {
m_latch = new CountDownLatch(1);
final Role role = m_roleRepository.addRole("john.doe", Role.USER);
new Thread(new Runnable() {
public void run() {
role.getProperties().put("key", "value");
}
}).start();
assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class RoleRepositoryTest method testGetUserAnyoneRoleByName.
/**
* Test method for {@link org.apache.felix.useradmin.impl.RoleRepository#getRoleByName(java.lang.String)}.
*/
public void testGetUserAnyoneRoleByName() {
Role anyone = m_roleRepository.getRoleByName(Role.USER_ANYONE);
assertEquals(Role.USER_ANYONE, anyone.getName());
assertEquals(Role.ROLE, anyone.getType());
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class UserAdminImplTest method testGetRolesWithFilterOk.
/**
* Tests that getting multiple roles based on a OSGi-filter works and yields the correct result.
*/
public void testGetRolesWithFilterOk() throws Exception {
Role user1 = m_userAdmin.createRole("user1", Role.USER);
user1.getProperties().put("key", "value1");
Role user2 = m_userAdmin.createRole("user2", Role.USER);
user2.getProperties().put("key", "value2");
Role group1 = m_userAdmin.createRole("group1", Role.GROUP);
group1.getProperties().put("key", "value3");
Role group2 = m_userAdmin.createRole("group2", Role.GROUP);
group2.getProperties().put("key", "otherValue3");
Role[] roles = m_userAdmin.getRoles("(key=value*)");
assertNotNull(roles);
assertEquals(3, roles.length);
List roleList = Arrays.asList(roles);
assertTrue(roleList.contains(user1));
assertTrue(roleList.contains(user2));
assertTrue(roleList.contains(group1));
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class UserAdminImplTest method testAddRolePropertyOfInvalidTypeFail.
/**
* Tests that adding a property of an invalid type to a role does not work and yields an exception.
*/
public void testAddRolePropertyOfInvalidTypeFail() {
Role user1 = m_userAdmin.createRole("user1", Role.USER);
try {
user1.getProperties().put("key", Integer.valueOf(1));
fail("Expected IllegalArgumentException!");
} catch (IllegalArgumentException e) {
// Ok; expected
}
}
Aggregations