public void testFelix3735_StartStoreAfterUserAdminInitializesOk() throws Exception
{
final String userName = "anotherTestUser";
final String groupName = "anotherTestGroup";
UserAdmin userAdmin = awaitService(UserAdmin.class.getName());
Bundle fileStoreBundle = getFileStoreBundle();
// Start a suitable storage service...
fileStoreBundle.start();
// Fill the user admin with some data...
User testUser = (User) userAdmin.createRole(userName, Role.USER);
testUser.getProperties().put("key", "value");
Group testGroup = (Group) userAdmin.createRole(groupName, Role.GROUP);
testGroup.addMember(testUser);
// Stop the file store...
fileStoreBundle.stop();
Bundle userAdminBundle = findBundle(ORG_APACHE_FELIX_USERADMIN);
assertNotNull(userAdminBundle);
userAdminBundle.stop();
// Obtain user admin service again; shouldn't be available...
userAdmin = getService(UserAdmin.class.getName());
assertNull(userAdmin);
userAdminBundle.start();
// Obtain user admin service again; should be available now...
userAdmin = awaitService(UserAdmin.class.getName());
assertNotNull(userAdmin);
// Verify the user + group are gone (no store available)...
assertNull(userAdmin.getRole(userName));
assertNull(userAdmin.getRole(groupName));
// Start the file store...
fileStoreBundle.start();
// Verify the user + group are gone (no store available)...
User readUser = (User) userAdmin.getRole(userName);
assertNotNull(readUser);
assertEquals(userName, readUser.getName());
assertEquals("value", readUser.getProperties().get("key"));
Group readGroup = (Group) userAdmin.getRole(groupName);
assertNotNull(readGroup);
assertEquals(groupName, readGroup.getName());
assertEquals(1, readGroup.getMembers().length);
assertEquals(readUser, readGroup.getMembers()[0]);
}