You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2008/03/03 00:41:28 UTC

svn commit: r632882 [6/7] - in /maven/enforcer/trunk: ./ enforcer-api/ enforcer-api/src/custom-rule-sample/ enforcer-api/src/custom-rule-sample/src/ enforcer-api/src/custom-rule-sample/src/main/java/org/apache/maven/enforcer/rule/ enforcer-api/src/main...

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestAbstractVersionEnforcer.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestAbstractVersionEnforcer.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestAbstractVersionEnforcer.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestAbstractVersionEnforcer.java Sun Mar  2 15:41:23 2008
@@ -1,133 +1,133 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.plugin.logging.SystemStreamLog;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * 
- */
-public class TestAbstractVersionEnforcer
-    extends TestCase
-{
-    public void testContainsVersion()
-        throws InvalidVersionSpecificationException
-    {
-        ArtifactVersion version = new DefaultArtifactVersion( "2.0.5" );
-        // test ranges
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.5,)" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,)" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,2.0.5]" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,2.0.6]" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,2.0.6)" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0,)" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.0,)" ), version ) );
-        // not matching versions
-        assertFalse( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,2.0.5)" ), version ) );
-        assertFalse( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.6,)" ), version ) );
-        assertFalse( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "(2.0.5,)" ), version ) );
-
-        // test singular versions -> 2.0.5 == [2.0.5,) or x >= 2.0.5
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "2.0" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "2.0.4" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "2.0.5" ), version ) );
-
-        assertFalse( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "2.0.6" ), version ) );
-
-        version = new DefaultArtifactVersion( "1.5.0-7" );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[1.5.0,)" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[1.5,1.6)" ), version ) );
-
-        version = new DefaultArtifactVersion( RequireJavaVersion.normalizeJDKVersion( "1.5.0-07" ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[1.5.0,)" ), version ) );
-        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[1.5,1.6)" ), version ) );
-
-    }
-
-    private void enforceFalse( AbstractVersionEnforcer rule, Log log, String var, String range, ArtifactVersion version )
-    {
-        try
-        {
-            rule.enforceVersion( log, var, range, version );
-            fail( "Expected to receive EnforcerRuleException because:" + version + " is not contained by " + range );
-        }
-        catch ( Exception e )
-        {
-            if ( e instanceof EnforcerRuleException )
-            {
-                // log.info( "Caught Expected Exception: " +
-                // e.getLocalizedMessage() );
-            }
-            else
-            {
-                fail( "Received wrong exception. Expected EnforcerRuleExeption. Received:" + e.toString() );
-            }
-        }
-    }
-
-    public void testEnforceVersion()
-    {
-        RequireMavenVersion rule = new RequireMavenVersion();
-        ArtifactVersion version = new DefaultArtifactVersion( "2.0.5" );
-        SystemStreamLog log = new SystemStreamLog();
-        // test ranges
-
-        // not matching versions
-        try
-        {
-            rule.enforceVersion( log, "test", "[2.0.5,)", version );
-            rule.enforceVersion( log, "test", "[2.0.4,)", version );
-            rule.enforceVersion( log, "test", "[2.0.4,2.0.5]", version );
-            rule.enforceVersion( log, "test", "[2.0.4,2.0.6]", version );
-            rule.enforceVersion( log, "test", "[2.0.4,2.0.6)", version );
-            rule.enforceVersion( log, "test", "[2.0,)", version );
-            rule.enforceVersion( log, "test", "[2.0.0,)", version );
-
-            // test singular versions -> 2.0.5 == [2.0.5,) or x >= 2.0.5
-            rule.enforceVersion( log, "test", "2.0", version );
-            rule.enforceVersion( log, "test", "2.0.4", version );
-            rule.enforceVersion( log, "test", "2.0.5", version );
-        }
-        catch ( Exception e )
-        {
-            fail( "No Exception expected. Caught:" + e.getLocalizedMessage() );
-
-        }
-
-        enforceFalse( rule, log, "test", "[2.0.6,)", version );
-        enforceFalse( rule, log, "test", "(2.0.5,)", version );
-        enforceFalse( rule, log, "test", "2.0.6", version );
-
-        enforceFalse( rule, log, "test", "[2.0.4,2.0.5)", version );
-
-        // make sure to handle the invalid range specification
-        enforceFalse( rule, log, "test", "[[2.0.4,2.0.5)", version );
-
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugin.logging.SystemStreamLog;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * 
+ */
+public class TestAbstractVersionEnforcer
+    extends TestCase
+{
+    public void testContainsVersion()
+        throws InvalidVersionSpecificationException
+    {
+        ArtifactVersion version = new DefaultArtifactVersion( "2.0.5" );
+        // test ranges
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.5,)" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,)" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,2.0.5]" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,2.0.6]" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,2.0.6)" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0,)" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.0,)" ), version ) );
+        // not matching versions
+        assertFalse( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.4,2.0.5)" ), version ) );
+        assertFalse( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[2.0.6,)" ), version ) );
+        assertFalse( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "(2.0.5,)" ), version ) );
+
+        // test singular versions -> 2.0.5 == [2.0.5,) or x >= 2.0.5
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "2.0" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "2.0.4" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "2.0.5" ), version ) );
+
+        assertFalse( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "2.0.6" ), version ) );
+
+        version = new DefaultArtifactVersion( "1.5.0-7" );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[1.5.0,)" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[1.5,1.6)" ), version ) );
+
+        version = new DefaultArtifactVersion( RequireJavaVersion.normalizeJDKVersion( "1.5.0-07" ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[1.5.0,)" ), version ) );
+        assertTrue( AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( "[1.5,1.6)" ), version ) );
+
+    }
+
+    private void enforceFalse( AbstractVersionEnforcer rule, Log log, String var, String range, ArtifactVersion version )
+    {
+        try
+        {
+            rule.enforceVersion( log, var, range, version );
+            fail( "Expected to receive EnforcerRuleException because:" + version + " is not contained by " + range );
+        }
+        catch ( Exception e )
+        {
+            if ( e instanceof EnforcerRuleException )
+            {
+                // log.info( "Caught Expected Exception: " +
+                // e.getLocalizedMessage() );
+            }
+            else
+            {
+                fail( "Received wrong exception. Expected EnforcerRuleExeption. Received:" + e.toString() );
+            }
+        }
+    }
+
+    public void testEnforceVersion()
+    {
+        RequireMavenVersion rule = new RequireMavenVersion();
+        ArtifactVersion version = new DefaultArtifactVersion( "2.0.5" );
+        SystemStreamLog log = new SystemStreamLog();
+        // test ranges
+
+        // not matching versions
+        try
+        {
+            rule.enforceVersion( log, "test", "[2.0.5,)", version );
+            rule.enforceVersion( log, "test", "[2.0.4,)", version );
+            rule.enforceVersion( log, "test", "[2.0.4,2.0.5]", version );
+            rule.enforceVersion( log, "test", "[2.0.4,2.0.6]", version );
+            rule.enforceVersion( log, "test", "[2.0.4,2.0.6)", version );
+            rule.enforceVersion( log, "test", "[2.0,)", version );
+            rule.enforceVersion( log, "test", "[2.0.0,)", version );
+
+            // test singular versions -> 2.0.5 == [2.0.5,) or x >= 2.0.5
+            rule.enforceVersion( log, "test", "2.0", version );
+            rule.enforceVersion( log, "test", "2.0.4", version );
+            rule.enforceVersion( log, "test", "2.0.5", version );
+        }
+        catch ( Exception e )
+        {
+            fail( "No Exception expected. Caught:" + e.getLocalizedMessage() );
+
+        }
+
+        enforceFalse( rule, log, "test", "[2.0.6,)", version );
+        enforceFalse( rule, log, "test", "(2.0.5,)", version );
+        enforceFalse( rule, log, "test", "2.0.6", version );
+
+        enforceFalse( rule, log, "test", "[2.0.4,2.0.5)", version );
+
+        // make sure to handle the invalid range specification
+        enforceFalse( rule, log, "test", "[[2.0.4,2.0.5)", version );
+
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestAbstractVersionEnforcer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestBannedDependencies.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestBannedDependencies.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestBannedDependencies.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestBannedDependencies.java Sun Mar  2 15:41:23 2008
@@ -1,188 +1,188 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import junit.framework.TestCase;
-
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.plugin.testing.ArtifactStubFactory;
-
-/**
- * 
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * 
- */
-public class TestBannedDependencies
-    extends TestCase
-{
-
-    public void testRule()
-        throws IOException
-    {
-        ArtifactStubFactory factory = new ArtifactStubFactory();
-        MockProject project = new MockProject();
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
-        project.setArtifacts( factory.getMixedArtifacts() );
-        project.setDependencyArtifacts( factory.getScopedArtifacts() );
-        BannedDependencies rule = new BannedDependencies();
-
-        ArrayList excludes = new ArrayList();
-        rule.setSearchTransitive( false );
-
-        // test whole name
-        excludes.add( "testGroupId:release:1.0" );
-        rule.setExcludes( excludes );
-
-        execute( rule, helper, false );
-
-        // test group:artifact
-        excludes.clear();
-        excludes.add( "testGroupId:release" );
-        execute( rule, helper, false );
-
-        // test group
-        excludes.clear();
-        excludes.add( "testGroupId" );
-        execute( rule, helper, false );
-
-        // now check one that should be found in direct
-        // dependencies
-        excludes.clear();
-        excludes.add( "g:compile:1.0" );
-        execute( rule, helper, true );
-        rule.setSearchTransitive( true );
-
-        // whole name
-        excludes.clear();
-        excludes.add( "testGroupId:release:1.0" );
-        execute( rule, helper, true );
-
-        // group:artifact
-        excludes.clear();
-        excludes.add( "testGroupId:release" );
-        execute( rule, helper, true );
-
-        // group
-        excludes.clear();
-        excludes.add( "testGroupId" );
-        execute( rule, helper, true );
-
-        // now check wildcards
-        excludes.clear();
-        excludes.add( "*:release" );
-        execute( rule, helper, true );
-
-        // now check wildcards
-        excludes.clear();
-        excludes.add( "*:*:1.0" );
-        execute( rule, helper, true );
-
-        // now check wildcards
-        excludes.clear();
-        excludes.add( "*:release:*" );
-        execute( rule, helper, true );
-
-        // now check wildcards
-        excludes.clear();
-        excludes.add( "*:release:1.2" );
-        execute( rule, helper, false );
-        
-        //now check multiple excludes
-        excludes.add( "*:release:*");
-        execute( rule, helper, true );
-        
-        //now check space trimming
-        excludes.clear();
-        excludes.add( "  testGroupId  :  release   :   1.0    " );
-        execute( rule, helper, true );
-        
-        //now check weirdness
-        excludes.clear();
-        excludes.add( ":::" ); //null entry, won't match anything
-        execute( rule, helper, false );
-    }
-    
-    public void testIncludes() throws IOException
-    {
-        ArtifactStubFactory factory = new ArtifactStubFactory();
-        MockProject project = new MockProject();
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
-        project.setArtifacts( factory.getMixedArtifacts() );
-        project.setDependencyArtifacts( factory.getScopedArtifacts() );
-        BannedDependencies rule = new BannedDependencies();
-
-        ArrayList excludes = new ArrayList();
-        ArrayList includes = new ArrayList();
-        
-        rule.setSearchTransitive( false );
-        
-        excludes.add( "*" );
-        includes.add( "*" );
-        
-        rule.setExcludes( excludes );
-        rule.setIncludes( includes );
-        
-        execute( rule, helper, false );
-        
-        excludes.clear();
-        excludes.add( "*:runtime" );
-        rule.setExcludes( excludes );
-        
-        execute( rule, helper, false );
-        
-        includes.clear();
-        includes.add( "*:test" );
-        rule.setIncludes( includes );
-        execute( rule, helper, true );
-    }
-
-    /**
-     * Simpler wrapper to execute and deal with the expected
-     * result.
-     * 
-     * @param rule
-     * @param helper
-     * @param shouldFail
-     */
-    private void execute( BannedDependencies rule, EnforcerRuleHelper helper, boolean shouldFail )
-    {
-        try
-        {
-            rule.message = null;
-            rule.execute( helper );
-            if ( shouldFail )
-            {
-                fail( "Exception expected." );
-            }
-        }
-        catch ( EnforcerRuleException e )
-        {
-            if ( !shouldFail )
-            {
-                fail( "No Exception expected:" + e.getLocalizedMessage() );
-            }
-            //helper.getLog().debug(e.getMessage());
-        }
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.plugin.testing.ArtifactStubFactory;
+
+/**
+ * 
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * 
+ */
+public class TestBannedDependencies
+    extends TestCase
+{
+
+    public void testRule()
+        throws IOException
+    {
+        ArtifactStubFactory factory = new ArtifactStubFactory();
+        MockProject project = new MockProject();
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
+        project.setArtifacts( factory.getMixedArtifacts() );
+        project.setDependencyArtifacts( factory.getScopedArtifacts() );
+        BannedDependencies rule = new BannedDependencies();
+
+        ArrayList excludes = new ArrayList();
+        rule.setSearchTransitive( false );
+
+        // test whole name
+        excludes.add( "testGroupId:release:1.0" );
+        rule.setExcludes( excludes );
+
+        execute( rule, helper, false );
+
+        // test group:artifact
+        excludes.clear();
+        excludes.add( "testGroupId:release" );
+        execute( rule, helper, false );
+
+        // test group
+        excludes.clear();
+        excludes.add( "testGroupId" );
+        execute( rule, helper, false );
+
+        // now check one that should be found in direct
+        // dependencies
+        excludes.clear();
+        excludes.add( "g:compile:1.0" );
+        execute( rule, helper, true );
+        rule.setSearchTransitive( true );
+
+        // whole name
+        excludes.clear();
+        excludes.add( "testGroupId:release:1.0" );
+        execute( rule, helper, true );
+
+        // group:artifact
+        excludes.clear();
+        excludes.add( "testGroupId:release" );
+        execute( rule, helper, true );
+
+        // group
+        excludes.clear();
+        excludes.add( "testGroupId" );
+        execute( rule, helper, true );
+
+        // now check wildcards
+        excludes.clear();
+        excludes.add( "*:release" );
+        execute( rule, helper, true );
+
+        // now check wildcards
+        excludes.clear();
+        excludes.add( "*:*:1.0" );
+        execute( rule, helper, true );
+
+        // now check wildcards
+        excludes.clear();
+        excludes.add( "*:release:*" );
+        execute( rule, helper, true );
+
+        // now check wildcards
+        excludes.clear();
+        excludes.add( "*:release:1.2" );
+        execute( rule, helper, false );
+        
+        //now check multiple excludes
+        excludes.add( "*:release:*");
+        execute( rule, helper, true );
+        
+        //now check space trimming
+        excludes.clear();
+        excludes.add( "  testGroupId  :  release   :   1.0    " );
+        execute( rule, helper, true );
+        
+        //now check weirdness
+        excludes.clear();
+        excludes.add( ":::" ); //null entry, won't match anything
+        execute( rule, helper, false );
+    }
+    
+    public void testIncludes() throws IOException
+    {
+        ArtifactStubFactory factory = new ArtifactStubFactory();
+        MockProject project = new MockProject();
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
+        project.setArtifacts( factory.getMixedArtifacts() );
+        project.setDependencyArtifacts( factory.getScopedArtifacts() );
+        BannedDependencies rule = new BannedDependencies();
+
+        ArrayList excludes = new ArrayList();
+        ArrayList includes = new ArrayList();
+        
+        rule.setSearchTransitive( false );
+        
+        excludes.add( "*" );
+        includes.add( "*" );
+        
+        rule.setExcludes( excludes );
+        rule.setIncludes( includes );
+        
+        execute( rule, helper, false );
+        
+        excludes.clear();
+        excludes.add( "*:runtime" );
+        rule.setExcludes( excludes );
+        
+        execute( rule, helper, false );
+        
+        includes.clear();
+        includes.add( "*:test" );
+        rule.setIncludes( includes );
+        execute( rule, helper, true );
+    }
+
+    /**
+     * Simpler wrapper to execute and deal with the expected
+     * result.
+     * 
+     * @param rule
+     * @param helper
+     * @param shouldFail
+     */
+    private void execute( BannedDependencies rule, EnforcerRuleHelper helper, boolean shouldFail )
+    {
+        try
+        {
+            rule.message = null;
+            rule.execute( helper );
+            if ( shouldFail )
+            {
+                fail( "Exception expected." );
+            }
+        }
+        catch ( EnforcerRuleException e )
+        {
+            if ( !shouldFail )
+            {
+                fail( "No Exception expected:" + e.getLocalizedMessage() );
+            }
+            //helper.getLog().debug(e.getMessage());
+        }
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestBannedDependencies.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestEvaluateBeanshell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestMavenVersion.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestMavenVersion.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestMavenVersion.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestMavenVersion.java Sun Mar  2 15:41:23 2008
@@ -1,71 +1,71 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-import org.apache.commons.lang.SystemUtils;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * 
- */
-public class TestMavenVersion
-    extends TestCase
-{
-    public void testRule()
-        throws EnforcerRuleException
-    {
-
-        RequireMavenVersion rule = new RequireMavenVersion();
-        rule.setVersion( "2.0.5" );
-
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
-
-        // test the singular version
-        rule.execute( helper );
-
-        // exclude this version
-        rule.setVersion( "(2.0.5" );
-
-        try
-        {
-            rule.execute( helper );
-            fail( "Expected an exception." );
-        }
-        catch ( EnforcerRuleException e )
-        {
-            // expected to catch this.
-        }
-
-        // this shouldn't crash
-        rule.setVersion( SystemUtils.JAVA_VERSION_TRIMMED );
-        rule.execute( helper );
-
-    }
-    
-    public void testId ()
-    {
-        RequireMavenVersion rule = new RequireMavenVersion();
-        rule.getCacheId();
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * 
+ */
+public class TestMavenVersion
+    extends TestCase
+{
+    public void testRule()
+        throws EnforcerRuleException
+    {
+
+        RequireMavenVersion rule = new RequireMavenVersion();
+        rule.setVersion( "2.0.5" );
+
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
+
+        // test the singular version
+        rule.execute( helper );
+
+        // exclude this version
+        rule.setVersion( "(2.0.5" );
+
+        try
+        {
+            rule.execute( helper );
+            fail( "Expected an exception." );
+        }
+        catch ( EnforcerRuleException e )
+        {
+            // expected to catch this.
+        }
+
+        // this shouldn't crash
+        rule.setVersion( SystemUtils.JAVA_VERSION_TRIMMED );
+        rule.execute( helper );
+
+    }
+    
+    public void testId ()
+    {
+        RequireMavenVersion rule = new RequireMavenVersion();
+        rule.getCacheId();
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestMavenVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestNoSnapshots.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestNoSnapshots.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestNoSnapshots.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestNoSnapshots.java Sun Mar  2 15:41:23 2008
@@ -1,64 +1,64 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.plugin.testing.ArtifactStubFactory;
-import org.apache.maven.plugins.enforcer.utils.TestEnforcerRuleUtils;
-
-/**
- * 
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * 
- */
-public class TestNoSnapshots
-    extends TestCase
-{
-
-    public void testRule()
-        throws IOException
-    {
-        ArtifactStubFactory factory = new ArtifactStubFactory();
-        MockProject project = new MockProject();
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
-        project.setArtifacts( factory.getMixedArtifacts() );
-        project.setDependencyArtifacts( factory.getScopedArtifacts() );
-        RequireReleaseDeps rule = new RequireReleaseDeps();
-        rule.setSearchTransitive( false );
-
-        TestEnforcerRuleUtils.execute( rule, helper, false );
-
-        rule.setSearchTransitive( true );
-
-        TestEnforcerRuleUtils.execute( rule, helper, true );
-
-    } 
-
-   
-    public void testId ()
-    {
-        RequireReleaseDeps rule = new RequireReleaseDeps();
-        rule.getCacheId();
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.plugin.testing.ArtifactStubFactory;
+import org.apache.maven.plugins.enforcer.utils.TestEnforcerRuleUtils;
+
+/**
+ * 
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * 
+ */
+public class TestNoSnapshots
+    extends TestCase
+{
+
+    public void testRule()
+        throws IOException
+    {
+        ArtifactStubFactory factory = new ArtifactStubFactory();
+        MockProject project = new MockProject();
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
+        project.setArtifacts( factory.getMixedArtifacts() );
+        project.setDependencyArtifacts( factory.getScopedArtifacts() );
+        RequireReleaseDeps rule = new RequireReleaseDeps();
+        rule.setSearchTransitive( false );
+
+        TestEnforcerRuleUtils.execute( rule, helper, false );
+
+        rule.setSearchTransitive( true );
+
+        TestEnforcerRuleUtils.execute( rule, helper, true );
+
+    } 
+
+   
+    public void testId ()
+    {
+        RequireReleaseDeps rule = new RequireReleaseDeps();
+        rule.getCacheId();
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestNoSnapshots.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVersion.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVersion.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVersion.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVersion.java Sun Mar  2 15:41:23 2008
@@ -1,94 +1,94 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-import org.apache.commons.lang.SystemUtils;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * 
- */
-public class TestRequireJavaVersion
-    extends TestCase
-{
-    public void testFixJDKVersion()
-    {
-        // test that we only take the first 3 versions for
-        // comparision
-        assertEquals( "1.5.0-11", RequireJavaVersion.normalizeJDKVersion( "1.5.0_11" ) );
-        assertEquals( "1.5.1", RequireJavaVersion.normalizeJDKVersion( "1.5.1" ) );
-        assertEquals( "1.5.2-1", RequireJavaVersion.normalizeJDKVersion( "1.5.2-1.b11" ) );
-        assertEquals( "1.5.3-11", RequireJavaVersion.normalizeJDKVersion( "1.5.3_11" ) );
-        assertEquals( "1.5.4-5", RequireJavaVersion.normalizeJDKVersion( "1.5.4.5_11" ) );
-        assertEquals( "1.5.5-6", RequireJavaVersion.normalizeJDKVersion( "1.5.5.6_11.2" ) );
-
-        // test for non-standard versions
-        assertEquals( "1.5.0-11", RequireJavaVersion.normalizeJDKVersion( "1-5-0-11" ) );
-        assertEquals( "1.5.0-11", RequireJavaVersion.normalizeJDKVersion( "1-_5-_0-_11" ) );
-        assertEquals( "1.5.0-11", RequireJavaVersion.normalizeJDKVersion( "1_5_0_11" ) );
-        assertEquals( "1.5.0-7", RequireJavaVersion.normalizeJDKVersion( "1.5.0-07" ) );
-        assertEquals( "1.5.0-7", RequireJavaVersion.normalizeJDKVersion( "1.5.0-b7" ) );
-        assertEquals( "1.5.0-7", RequireJavaVersion.normalizeJDKVersion( "1.5.0-;7" ) );
-        assertEquals( "1.6.0", RequireJavaVersion.normalizeJDKVersion( "1.6.0-dp" ) );
-        assertEquals( "1.6.0-2", RequireJavaVersion.normalizeJDKVersion( "1.6.0-dp2" ) );
-    }
-
-    public void testRule()
-        throws EnforcerRuleException
-    {
-        String thisVersion = RequireJavaVersion.normalizeJDKVersion( SystemUtils.JAVA_VERSION_TRIMMED );
-
-        RequireJavaVersion rule = new RequireJavaVersion();
-        rule.setVersion( thisVersion );
-
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
-
-        // test the singular version
-        rule.execute( helper );
-
-        // exclude this version
-        rule.setVersion( "(" + thisVersion );
-
-        try
-        {
-            rule.execute( helper );
-            fail( "Expected an exception." );
-        }
-        catch ( EnforcerRuleException e )
-        {
-            // expected to catch this.
-        }
-
-        // this shouldn't crash
-        rule.setVersion( SystemUtils.JAVA_VERSION_TRIMMED );
-        rule.execute( helper );
-
-    }
-    
-    public void testId ()
-    {
-        RequireJavaVersion rule = new RequireJavaVersion();
-        rule.getCacheId();
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * 
+ */
+public class TestRequireJavaVersion
+    extends TestCase
+{
+    public void testFixJDKVersion()
+    {
+        // test that we only take the first 3 versions for
+        // comparision
+        assertEquals( "1.5.0-11", RequireJavaVersion.normalizeJDKVersion( "1.5.0_11" ) );
+        assertEquals( "1.5.1", RequireJavaVersion.normalizeJDKVersion( "1.5.1" ) );
+        assertEquals( "1.5.2-1", RequireJavaVersion.normalizeJDKVersion( "1.5.2-1.b11" ) );
+        assertEquals( "1.5.3-11", RequireJavaVersion.normalizeJDKVersion( "1.5.3_11" ) );
+        assertEquals( "1.5.4-5", RequireJavaVersion.normalizeJDKVersion( "1.5.4.5_11" ) );
+        assertEquals( "1.5.5-6", RequireJavaVersion.normalizeJDKVersion( "1.5.5.6_11.2" ) );
+
+        // test for non-standard versions
+        assertEquals( "1.5.0-11", RequireJavaVersion.normalizeJDKVersion( "1-5-0-11" ) );
+        assertEquals( "1.5.0-11", RequireJavaVersion.normalizeJDKVersion( "1-_5-_0-_11" ) );
+        assertEquals( "1.5.0-11", RequireJavaVersion.normalizeJDKVersion( "1_5_0_11" ) );
+        assertEquals( "1.5.0-7", RequireJavaVersion.normalizeJDKVersion( "1.5.0-07" ) );
+        assertEquals( "1.5.0-7", RequireJavaVersion.normalizeJDKVersion( "1.5.0-b7" ) );
+        assertEquals( "1.5.0-7", RequireJavaVersion.normalizeJDKVersion( "1.5.0-;7" ) );
+        assertEquals( "1.6.0", RequireJavaVersion.normalizeJDKVersion( "1.6.0-dp" ) );
+        assertEquals( "1.6.0-2", RequireJavaVersion.normalizeJDKVersion( "1.6.0-dp2" ) );
+    }
+
+    public void testRule()
+        throws EnforcerRuleException
+    {
+        String thisVersion = RequireJavaVersion.normalizeJDKVersion( SystemUtils.JAVA_VERSION_TRIMMED );
+
+        RequireJavaVersion rule = new RequireJavaVersion();
+        rule.setVersion( thisVersion );
+
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
+
+        // test the singular version
+        rule.execute( helper );
+
+        // exclude this version
+        rule.setVersion( "(" + thisVersion );
+
+        try
+        {
+            rule.execute( helper );
+            fail( "Expected an exception." );
+        }
+        catch ( EnforcerRuleException e )
+        {
+            // expected to catch this.
+        }
+
+        // this shouldn't crash
+        rule.setVersion( SystemUtils.JAVA_VERSION_TRIMMED );
+        rule.execute( helper );
+
+    }
+    
+    public void testId ()
+    {
+        RequireJavaVersion rule = new RequireJavaVersion();
+        rule.getCacheId();
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireJavaVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java Sun Mar  2 15:41:23 2008
@@ -1,123 +1,123 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.plugin.logging.SystemStreamLog;
-import org.codehaus.plexus.util.Os;
-
-/**
- * Exhaustively check the OS mojo.
- * 
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * 
- */
-public class TestRequireOS
-    extends TestCase
-{
-    public void testOS()
-    {
-        Log log = new SystemStreamLog();
-
-        RequireOS rule = new RequireOS();
-        rule.displayOSInfo( log, true );
-
-        Iterator iter = Os.getValidFamilies().iterator();
-        String validFamily = null;
-        String invalidFamily = null;
-        while ( iter.hasNext())
-        {
-            String fam = (String) iter.next();
-            if ( !Os.isFamily( fam ) )
-            {
-                invalidFamily = fam;
-                break;
-            }
-        }
-
-        validFamily = Os.OS_FAMILY;
-        
-        log.info( "Testing Mojo Using Valid Family: " + validFamily + " Invalid Family: " + invalidFamily );
-
-        rule.setFamily( validFamily );
-        assertTrue( rule.isAllowed() );
-
-        rule.setFamily( invalidFamily );
-        assertFalse( rule.isAllowed() );
-
-        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() );
-
-        rule.setArch( "somecrazyarch" );
-        assertFalse( rule.isAllowed() );
-
-        rule.setArch( "!somecrazyarch" );
-        assertTrue( rule.isAllowed() );
-
-        rule.setArch( null );
-
-        rule.setName( Os.OS_NAME );
-        assertTrue( rule.isAllowed() );
-
-        rule.setName( "somecrazyname" );
-        assertFalse( rule.isAllowed() );
-
-        rule.setName( "!somecrazyname" );
-        assertTrue( rule.isAllowed() );
-
-        rule.setName( null );
-
-        rule.setVersion( Os.OS_VERSION );
-        assertTrue( rule.isAllowed() );
-
-        rule.setVersion( "somecrazyversion" );
-        assertFalse( rule.isAllowed() );
-
-        rule.setVersion( "!somecrazyversion" );
-        assertTrue( rule.isAllowed() );
-    }
-    
-    public void testId ()
-    {
-        RequireOS rule = new RequireOS();
-        rule.getCacheId();
-    }
-
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.codehaus.plexus.util.Os;
+
+/**
+ * Exhaustively check the OS mojo.
+ * 
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * 
+ */
+public class TestRequireOS
+    extends TestCase
+{
+    public void testOS()
+    {
+        Log log = new SystemStreamLog();
+
+        RequireOS rule = new RequireOS();
+        rule.displayOSInfo( log, true );
+
+        Iterator iter = Os.getValidFamilies().iterator();
+        String validFamily = null;
+        String invalidFamily = null;
+        while ( iter.hasNext())
+        {
+            String fam = (String) iter.next();
+            if ( !Os.isFamily( fam ) )
+            {
+                invalidFamily = fam;
+                break;
+            }
+        }
+
+        validFamily = Os.OS_FAMILY;
+        
+        log.info( "Testing Mojo Using Valid Family: " + validFamily + " Invalid Family: " + invalidFamily );
+
+        rule.setFamily( validFamily );
+        assertTrue( rule.isAllowed() );
+
+        rule.setFamily( invalidFamily );
+        assertFalse( rule.isAllowed() );
+
+        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() );
+
+        rule.setArch( "somecrazyarch" );
+        assertFalse( rule.isAllowed() );
+
+        rule.setArch( "!somecrazyarch" );
+        assertTrue( rule.isAllowed() );
+
+        rule.setArch( null );
+
+        rule.setName( Os.OS_NAME );
+        assertTrue( rule.isAllowed() );
+
+        rule.setName( "somecrazyname" );
+        assertFalse( rule.isAllowed() );
+
+        rule.setName( "!somecrazyname" );
+        assertTrue( rule.isAllowed() );
+
+        rule.setName( null );
+
+        rule.setVersion( Os.OS_VERSION );
+        assertTrue( rule.isAllowed() );
+
+        rule.setVersion( "somecrazyversion" );
+        assertFalse( rule.isAllowed() );
+
+        rule.setVersion( "!somecrazyversion" );
+        assertTrue( rule.isAllowed() );
+    }
+    
+    public void testId ()
+    {
+        RequireOS rule = new RequireOS();
+        rule.getCacheId();
+    }
+
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireOS.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java Sun Mar  2 15:41:23 2008
@@ -1,297 +1,297 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtils;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- */
-public class TestRequirePluginVersions
-    extends AbstractMojoTestCase
-{
-
-    public void testHasVersionSpecified()
-    {
-        Plugin source = new Plugin();
-        source.setArtifactId( "foo" );
-        source.setGroupId( "group" );
-
-        // setup the plugins. I'm setting up the foo group
-        // with a few bogus entries and then a real one.
-        // this is to test that the list is exhaustively
-        // searched for versions before giving up.
-        // banLatest/Release will fail if it is found
-        // anywhere in the list
-        List plugins = new ArrayList();
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "a-artifact", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", null ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", "" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "b-artifact", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "c-artifact", "LATEST" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "c-artifact", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "d-artifact", "RELEASE" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "d-artifact", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "e-artifact", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "e-artifact", "RELEASE" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "LATEST" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "1.0-SNAPSHOT" ) );
-
-        RequirePluginVersions rule = new RequirePluginVersions();
-        rule.setBanLatest( false );
-        rule.setBanRelease( false );
-        rule.setBanSnapshots( false );
-
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
-
-        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        // check that LATEST is allowed
-        source.setArtifactId( "c-artifact" );
-        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        // check that LATEST is banned
-        rule.setBanLatest( true );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        // check that LATEST is exhausively checked
-        rule.setBanSnapshots( false );
-        source.setArtifactId( "f-artifact" );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        rule.setBanLatest( false );
-        rule.setBanSnapshots( true );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        // check that RELEASE is allowed
-        source.setArtifactId( "d-artifact" );
-        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        // check that RELEASE is banned
-        rule.setBanRelease( true );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        // check that RELEASE is exhaustively checked
-        source.setArtifactId( "e-artifact" );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-    }
-
-    
-    public void testHasVersionSpecifiedWithProperties()
-    {
-        Plugin source = new Plugin();
-        source.setGroupId( "group" );
-
-        // setup the plugins. 
-        List plugins = new ArrayList();
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "a-artifact", "1.0-${SNAPSHOT}" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "b-artifact", "${1.0}" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "c-artifact", "${LATEST}" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "d-artifact", "${RELEASE}" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "e-artifact", "${}" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "${   }" ) );
-        
-
-        RequirePluginVersions rule = new RequirePluginVersions();
-        rule.setBanLatest( false );
-        rule.setBanRelease( false );
-        rule.setBanSnapshots( false );
-
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper(true);
-
-        source.setArtifactId( "a-artifact" );
-        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        source.setArtifactId( "b-artifact" );
-        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
-        
-        source.setArtifactId( "c-artifact" );
-        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
-        
-        source.setArtifactId( "d-artifact" );
-        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
-
-        //this one checks empty property values
-        source.setArtifactId( "e-artifact" );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-        
-        // this one checks empty property values
-        source.setArtifactId( "f-artifact" );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-        
-        rule.setBanLatest( true );
-        source.setArtifactId( "c-artifact" );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-        
-        rule.setBanRelease( true );
-        source.setArtifactId( "d-artifact" );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-        
-        rule.setBanSnapshots( true );
-        source.setArtifactId( "a-artifact" );
-        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
-        
-        //release versions should pass everything
-        source.setArtifactId( "b-artifact" );
-        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
-    }
-
-    
-    public void testGetAllPlugins()
-        throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
-    {
-        RequirePluginVersions rule = new RequirePluginVersions();
-        String path = "target/test-classes/requirePluginVersions/getPomRecursively/b/c";
-
-        StringUtils.replace( path, "/", File.separator );
-
-        File projectDir = new File( getBasedir(), path );
-
-        MockProject project = new MockProject();
-        project.setArtifactId( "c" );
-        project.setGroupId( "group" );
-        project.setVersion( "1.0" );
-        project.setBaseDir( projectDir );
-
-        rule.setUtils( new EnforcerRuleUtils( EnforcerTestUtils.getHelper( project ) ) );
-        List plugins = rule.getAllPluginEntries( project );
-
-        // there should be 3
-        assertEquals( 3, plugins.size() );
-    }
-
-    public void testGetAdditionalPluginsNull()
-        throws MojoExecutionException
-    {
-        RequirePluginVersions rule = new RequirePluginVersions();
-        rule.addAdditionalPlugins( null, null );
-    }
-
-    public void testGetAdditionalPluginsInvalidFormat()
-    {
-        RequirePluginVersions rule = new RequirePluginVersions();
-
-        List additional = new ArrayList();
-
-        // invalid format (not enough sections)
-        additional.add( "group" );
-
-        Set plugins = new HashSet();
-        try
-        {
-            rule.addAdditionalPlugins( plugins, additional );
-            fail( "Expected Exception because the format is invalid" );
-        }
-        catch ( MojoExecutionException e )
-        {
-        }
-
-        // invalid format (too many sections)
-        additional.clear();
-        additional.add( "group:i:i" );
-        try
-        {
-            rule.addAdditionalPlugins( plugins, additional );
-            fail( "Expected Exception because the format is invalid" );
-        }
-        catch ( MojoExecutionException e )
-        {
-        }
-
-    }
-
-    public void testGetAdditionalPluginsEmptySet()
-        throws MojoExecutionException
-    {
-        RequirePluginVersions rule = new RequirePluginVersions();
-
-        Set plugins = new HashSet();
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "a-artifact", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", null ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo2", "" ) );
-
-        List additional = new ArrayList();
-        additional.add( "group:a-artifact" );
-        additional.add( "group:another-artifact" );
-
-        // make sure a null set can be handled
-        Set results = rule.addAdditionalPlugins( null, additional );
-
-        assertNotNull( results );
-        assertContainsPlugin( "group", "a-artifact", results );
-        assertContainsPlugin( "group", "another-artifact", results );
-
-    }
-
-    public void testGetAdditionalPlugins()
-        throws MojoExecutionException
-    {
-        RequirePluginVersions rule = new RequirePluginVersions();
-
-        Set plugins = new HashSet();
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "a-artifact", "1.0" ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", null ) );
-        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo2", "" ) );
-
-        List additional = new ArrayList();
-        additional.add( "group:a-artifact" );
-        additional.add( "group:another-artifact" );
-
-        Set results = rule.addAdditionalPlugins( plugins, additional );
-
-        // make sure only one new plugin has been added
-        assertNotNull( results );
-        assertEquals( 4, results.size() );
-        assertContainsPlugin( "group", "a-artifact", results );
-        assertContainsPlugin( "group", "another-artifact", results );
-
-    }
-
-    private void assertContainsPlugin( String group, String artifact, Set theSet )
-    {
-        Plugin p = new Plugin();
-        p.setGroupId( group );
-        p.setArtifactId( artifact );
-        assertTrue( theSet.contains( p ) );
-    }
-
-    public void testId()
-    {
-        RequirePluginVersions rule = new RequirePluginVersions();
-        rule.getCacheId();
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugins.enforcer.utils.EnforcerRuleUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ */
+public class TestRequirePluginVersions
+    extends AbstractMojoTestCase
+{
+
+    public void testHasVersionSpecified()
+    {
+        Plugin source = new Plugin();
+        source.setArtifactId( "foo" );
+        source.setGroupId( "group" );
+
+        // setup the plugins. I'm setting up the foo group
+        // with a few bogus entries and then a real one.
+        // this is to test that the list is exhaustively
+        // searched for versions before giving up.
+        // banLatest/Release will fail if it is found
+        // anywhere in the list
+        List plugins = new ArrayList();
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "a-artifact", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", null ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", "" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "b-artifact", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "c-artifact", "LATEST" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "c-artifact", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "d-artifact", "RELEASE" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "d-artifact", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "e-artifact", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "e-artifact", "RELEASE" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "LATEST" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "1.0-SNAPSHOT" ) );
+
+        RequirePluginVersions rule = new RequirePluginVersions();
+        rule.setBanLatest( false );
+        rule.setBanRelease( false );
+        rule.setBanSnapshots( false );
+
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
+
+        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        // check that LATEST is allowed
+        source.setArtifactId( "c-artifact" );
+        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        // check that LATEST is banned
+        rule.setBanLatest( true );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        // check that LATEST is exhausively checked
+        rule.setBanSnapshots( false );
+        source.setArtifactId( "f-artifact" );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        rule.setBanLatest( false );
+        rule.setBanSnapshots( true );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        // check that RELEASE is allowed
+        source.setArtifactId( "d-artifact" );
+        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        // check that RELEASE is banned
+        rule.setBanRelease( true );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        // check that RELEASE is exhaustively checked
+        source.setArtifactId( "e-artifact" );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+    }
+
+    
+    public void testHasVersionSpecifiedWithProperties()
+    {
+        Plugin source = new Plugin();
+        source.setGroupId( "group" );
+
+        // setup the plugins. 
+        List plugins = new ArrayList();
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "a-artifact", "1.0-${SNAPSHOT}" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "b-artifact", "${1.0}" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "c-artifact", "${LATEST}" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "d-artifact", "${RELEASE}" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "e-artifact", "${}" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "f-artifact", "${   }" ) );
+        
+
+        RequirePluginVersions rule = new RequirePluginVersions();
+        rule.setBanLatest( false );
+        rule.setBanRelease( false );
+        rule.setBanSnapshots( false );
+
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper(true);
+
+        source.setArtifactId( "a-artifact" );
+        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        source.setArtifactId( "b-artifact" );
+        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
+        
+        source.setArtifactId( "c-artifact" );
+        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
+        
+        source.setArtifactId( "d-artifact" );
+        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
+
+        //this one checks empty property values
+        source.setArtifactId( "e-artifact" );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+        
+        // this one checks empty property values
+        source.setArtifactId( "f-artifact" );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+        
+        rule.setBanLatest( true );
+        source.setArtifactId( "c-artifact" );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+        
+        rule.setBanRelease( true );
+        source.setArtifactId( "d-artifact" );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+        
+        rule.setBanSnapshots( true );
+        source.setArtifactId( "a-artifact" );
+        assertFalse( rule.hasValidVersionSpecified( helper, source, plugins ) );
+        
+        //release versions should pass everything
+        source.setArtifactId( "b-artifact" );
+        assertTrue( rule.hasValidVersionSpecified( helper, source, plugins ) );
+    }
+
+    
+    public void testGetAllPlugins()
+        throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
+    {
+        RequirePluginVersions rule = new RequirePluginVersions();
+        String path = "target/test-classes/requirePluginVersions/getPomRecursively/b/c";
+
+        StringUtils.replace( path, "/", File.separator );
+
+        File projectDir = new File( getBasedir(), path );
+
+        MockProject project = new MockProject();
+        project.setArtifactId( "c" );
+        project.setGroupId( "group" );
+        project.setVersion( "1.0" );
+        project.setBaseDir( projectDir );
+
+        rule.setUtils( new EnforcerRuleUtils( EnforcerTestUtils.getHelper( project ) ) );
+        List plugins = rule.getAllPluginEntries( project );
+
+        // there should be 3
+        assertEquals( 3, plugins.size() );
+    }
+
+    public void testGetAdditionalPluginsNull()
+        throws MojoExecutionException
+    {
+        RequirePluginVersions rule = new RequirePluginVersions();
+        rule.addAdditionalPlugins( null, null );
+    }
+
+    public void testGetAdditionalPluginsInvalidFormat()
+    {
+        RequirePluginVersions rule = new RequirePluginVersions();
+
+        List additional = new ArrayList();
+
+        // invalid format (not enough sections)
+        additional.add( "group" );
+
+        Set plugins = new HashSet();
+        try
+        {
+            rule.addAdditionalPlugins( plugins, additional );
+            fail( "Expected Exception because the format is invalid" );
+        }
+        catch ( MojoExecutionException e )
+        {
+        }
+
+        // invalid format (too many sections)
+        additional.clear();
+        additional.add( "group:i:i" );
+        try
+        {
+            rule.addAdditionalPlugins( plugins, additional );
+            fail( "Expected Exception because the format is invalid" );
+        }
+        catch ( MojoExecutionException e )
+        {
+        }
+
+    }
+
+    public void testGetAdditionalPluginsEmptySet()
+        throws MojoExecutionException
+    {
+        RequirePluginVersions rule = new RequirePluginVersions();
+
+        Set plugins = new HashSet();
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "a-artifact", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", null ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo2", "" ) );
+
+        List additional = new ArrayList();
+        additional.add( "group:a-artifact" );
+        additional.add( "group:another-artifact" );
+
+        // make sure a null set can be handled
+        Set results = rule.addAdditionalPlugins( null, additional );
+
+        assertNotNull( results );
+        assertContainsPlugin( "group", "a-artifact", results );
+        assertContainsPlugin( "group", "another-artifact", results );
+
+    }
+
+    public void testGetAdditionalPlugins()
+        throws MojoExecutionException
+    {
+        RequirePluginVersions rule = new RequirePluginVersions();
+
+        Set plugins = new HashSet();
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "a-artifact", "1.0" ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo", null ) );
+        plugins.add( EnforcerTestUtils.newPlugin( "group", "foo2", "" ) );
+
+        List additional = new ArrayList();
+        additional.add( "group:a-artifact" );
+        additional.add( "group:another-artifact" );
+
+        Set results = rule.addAdditionalPlugins( plugins, additional );
+
+        // make sure only one new plugin has been added
+        assertNotNull( results );
+        assertEquals( 4, results.size() );
+        assertContainsPlugin( "group", "a-artifact", results );
+        assertContainsPlugin( "group", "another-artifact", results );
+
+    }
+
+    private void assertContainsPlugin( String group, String artifact, Set theSet )
+    {
+        Plugin p = new Plugin();
+        p.setGroupId( group );
+        p.setArtifactId( artifact );
+        assertTrue( theSet.contains( p ) );
+    }
+
+    public void testId()
+    {
+        RequirePluginVersions rule = new RequirePluginVersions();
+        rule.getCacheId();
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequirePluginVersions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireProperty.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireProperty.java?rev=632882&r1=632881&r2=632882&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireProperty.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireProperty.java Sun Mar  2 15:41:23 2008
@@ -1,108 +1,108 @@
-package org.apache.maven.plugins.enforcer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
-
-/**
- * @author Paul Gier
- * 
- */
-public class TestRequireProperty
-    extends TestCase
-{
-    public void testRule ()
-        throws EnforcerRuleException
-    {
-        MockProject project = new MockProject();
-        project.setProperty( "testProp", "This is a test." );
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
-
-        RequireProperty rule = new RequireProperty();
-        // this property should not be set
-        rule.property = "testPropJunk";
-
-        try
-        {
-            rule.execute( helper );
-            fail( "Expected an exception." );
-        }
-        catch ( EnforcerRuleException e )
-        {
-            // expected to catch this.
-        }
-
-        // this property should be set by the surefire
-        // plugin
-        rule.property = "testProp";
-        try
-        {
-            rule.execute( helper );
-        }
-        catch ( EnforcerRuleException e )
-        {
-            fail( "This should not throw an exception" );
-        }
-    }
-
-    public void testRuleWithRegex ()
-        throws EnforcerRuleException
-    {
-        MockProject project = new MockProject();
-        project.setProperty( "testProp", "This is a test." );
-        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
-
-        RequireProperty rule = new RequireProperty();
-        rule.property = "testProp";
-        // This expression should not match the property
-        // value
-        rule.regex = "[^abc]";
-
-        try
-        {
-            rule.execute( helper );
-            fail( "Expected an exception." );
-        }
-        catch ( EnforcerRuleException e )
-        {
-            // expected to catch this.
-        }
-
-        // this expr should match the property
-        rule.regex = "[This].*[.]";
-        try
-        {
-            rule.execute( helper );
-        }
-        catch ( EnforcerRuleException e )
-        {
-            fail( "This should not throw an exception" );
-        }
-    }
-
-    public void testId ()
-    {
-        RequireProperty rule = new RequireProperty();
-        rule.getCacheId();
-    }
-}
+package org.apache.maven.plugins.enforcer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
+
+/**
+ * @author Paul Gier
+ * 
+ */
+public class TestRequireProperty
+    extends TestCase
+{
+    public void testRule ()
+        throws EnforcerRuleException
+    {
+        MockProject project = new MockProject();
+        project.setProperty( "testProp", "This is a test." );
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
+
+        RequireProperty rule = new RequireProperty();
+        // this property should not be set
+        rule.property = "testPropJunk";
+
+        try
+        {
+            rule.execute( helper );
+            fail( "Expected an exception." );
+        }
+        catch ( EnforcerRuleException e )
+        {
+            // expected to catch this.
+        }
+
+        // this property should be set by the surefire
+        // plugin
+        rule.property = "testProp";
+        try
+        {
+            rule.execute( helper );
+        }
+        catch ( EnforcerRuleException e )
+        {
+            fail( "This should not throw an exception" );
+        }
+    }
+
+    public void testRuleWithRegex ()
+        throws EnforcerRuleException
+    {
+        MockProject project = new MockProject();
+        project.setProperty( "testProp", "This is a test." );
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project );
+
+        RequireProperty rule = new RequireProperty();
+        rule.property = "testProp";
+        // This expression should not match the property
+        // value
+        rule.regex = "[^abc]";
+
+        try
+        {
+            rule.execute( helper );
+            fail( "Expected an exception." );
+        }
+        catch ( EnforcerRuleException e )
+        {
+            // expected to catch this.
+        }
+
+        // this expr should match the property
+        rule.regex = "[This].*[.]";
+        try
+        {
+            rule.execute( helper );
+        }
+        catch ( EnforcerRuleException e )
+        {
+            fail( "This should not throw an exception" );
+        }
+    }
+
+    public void testId ()
+    {
+        RequireProperty rule = new RequireProperty();
+        rule.getCacheId();
+    }
+}

Propchange: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native