// A list of profile keys
List<ProfileKey> keys = new ArrayList<ProfileKey>();
// Parse
Collection<Profile> profiles = profileFactory.createProfiles(new ProfileKey("default"), null);
for(Profile profile : profiles)
{
// Register
profileService.registerProfile(profile);
ProfileKey key = profile.getKey();
keys.add(key);
try
{
// This is the default behavior. For custom profiles this could be different
profileService.getActiveProfile(key);
fail("profile already registered "+ key);
}
catch(NoSuchProfileException e)
{
// ok
}
}
// All profiles should be registered now
for(ProfileKey key : keys)
profileService.getProfile(key);
try
{
// Activate profile
ProfileKey key = new ProfileKey("default");
profileService.activateProfile(key);
profileService.validateProfile(key);
}
catch(Exception e)
{
getLog().error("failed to activate: ", e);
throw e;
}
// Test the default profile
Profile active = profileService.getActiveProfile(new ProfileKey("default"));
assertNotNull(active);
// All profiles should be active now
for(ProfileKey key : keys)
profileService.getActiveProfile(key);