[MENFORCER-267] Upgrade to make Maven 3+
Replace OperatingSystemProfileActivator
diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java
index a8f34f5..dc333b2 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireOS.java
@@ -28,7 +28,8 @@
 import org.apache.maven.model.ActivationOS;
 import org.apache.maven.model.Profile;
 import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.profiles.activation.OperatingSystemProfileActivator;
+import org.apache.maven.model.profile.activation.ProfileActivator;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.util.Os;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -42,6 +43,7 @@
 public class RequireOS
     extends AbstractStandardEnforcerRule
 {
+    private ProfileActivator activator;
 
     /**
      * The OS family type desired<br />
@@ -103,6 +105,13 @@
     {
 
     }
+    
+    // For testing
+    RequireOS( ProfileActivator activator ) 
+    {
+        this.activator = activator;
+    }
+    
 
     @Override
     public void execute( EnforcerRuleHelper helper )
@@ -117,6 +126,15 @@
                 + "You must pick at least one of (family, name, version, arch) "
                 + "or use -Denforcer.os.display=true to see the current OS information." );
         }
+        
+        try
+        {
+            activator = helper.getComponent( ProfileActivator.class, "os" );
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new EnforcerRuleException( e.getMessage() );
+        }
 
         if ( isValidFamily( this.family ) )
         {
@@ -185,9 +203,7 @@
      */
     public boolean isAllowed()
     {
-        OperatingSystemProfileActivator activator = new OperatingSystemProfileActivator();
-
-        return activator.isActive( createProfile() );
+        return activator.isActive( createProfile(), null, null );
     }
 
     /**
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java
index 65d1abd..353a763 100644
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java
@@ -19,14 +19,21 @@
  * under the License.
  */
 
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.util.Iterator;
 
-import junit.framework.TestCase;
-
 import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.model.profile.activation.OperatingSystemProfileActivator;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.logging.SystemStreamLog;
 import org.codehaus.plexus.util.Os;
+import org.junit.Test;
 
 /**
  * Exhaustively check the OS mojo.
@@ -34,17 +41,18 @@
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
  */
 public class TestRequireOS
-    extends TestCase
 {
 
     /**
      * Test os.
      */
+    @Test
     public void testOS()
     {
         Log log = new SystemStreamLog();
 
-        RequireOS rule = new RequireOS();
+        RequireOS rule = new RequireOS( new OperatingSystemProfileActivator() );
+        
         rule.displayOSInfo( log, true );
 
         Iterator<String> iter = Os.getValidFamilies().iterator();
@@ -73,17 +81,6 @@
         rule.setFamily( "!" + invalidFamily );
         assertTrue( rule.isAllowed() );
 
-        rule.setFamily( "junk" );
-        try
-        {
-            rule.execute( EnforcerTestUtils.getHelper() );
-            fail( "Expected MojoExecution Exception becuase of invalid family type" );
-        }
-        catch ( EnforcerRuleException e )
-        {
-            log.info( "Caught Expected Exception:" + e.getLocalizedMessage() );
-        }
-
         rule.setFamily( null );
         rule.setArch( Os.OS_ARCH );
         assertTrue( rule.isAllowed() );
@@ -116,10 +113,28 @@
         rule.setVersion( "!somecrazyversion" );
         assertTrue( rule.isAllowed() );
     }
+    
+    @Test
+    public void testInvalidFamily() throws Exception
+    {
+        RequireOS rule = new RequireOS();
+        
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
+        helper.getContainer().addComponent( new OperatingSystemProfileActivator(), "os" );
+        
+        rule.setFamily( "junk" );
+        try
+        {
+            rule.execute( helper );
+            fail( "Expected MojoExecution Exception because of invalid family type" );
+        }
+        catch ( EnforcerRuleException e )
+        {
+            assertThat( e.getMessage(), startsWith( "Invalid Family type used. Valid family types are: " ) );
+        } 
+    }
 
-    /**
-     * Test id.
-     */
+    @Test
     public void testId()
     {
         RequireOS rule = new RequireOS();