[jboss-cvs] JBossAS SVN: r86218 - branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 23 12:44:52 EDT 2009
Author: emuckenhuber
Date: 2009-03-23 12:44:52 -0400 (Mon, 23 Mar 2009)
New Revision: 86218
Modified:
branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
Log:
test register/unregister profile behavior
Modified: branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java 2009-03-23 16:43:55 UTC (rev 86217)
+++ branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java 2009-03-23 16:44:52 UTC (rev 86218)
@@ -23,9 +23,12 @@
import java.io.File;
import java.net.URI;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.ProfileService;
@@ -86,14 +89,33 @@
// Clear jar suffixes.
JarUtils.clearSuffixes();
+ // 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
@@ -104,8 +126,17 @@
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);
+
// Assert default profile
assertActive("default");
// Assert bootstrap profile
@@ -129,16 +160,35 @@
for(ProfileKey key : profileService.getActiveProfileKeys())
{
+ profileService.deactivateProfile(key);
try
{
- profileService.deactivateProfile(key);
+ profileService.getActiveProfile(key);
+ fail("profile still active. " + key);
}
- catch(Exception e)
+ catch(NoSuchProfileException e)
{
- getLog().debug("error deactivating profile: " + key, e);
+ // OK
}
}
+ // No active profiles
+ assertTrue(profileService.getActiveProfileKeys().isEmpty());
+ for(ProfileKey key : profileService.getProfileKeys())
+ {
+ profileService.unregisterProfile(key);
+ try
+ {
+ profileService.getProfile(key);
+ fail("profile not unregistered " + key);
+ }
+ catch(NoSuchProfileException e)
+ {
+ // OK
+ }
+ }
+ // No registred profiles
+ assertTrue(profileService.getProfileKeys().isEmpty());
}
protected void assertActive(String profile) throws Exception
More information about the jboss-cvs-commits
mailing list