[MENFORCER-219] Add m2e mapping
 Adding a real mapping to execute on import/incremental
 does not really work. At the moment it will be ignored
 as by default in m2e.


git-svn-id: https://svn.apache.org/repos/asf/maven/enforcer/trunk@1649118 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/enforcer-rules/pom.xml b/enforcer-rules/pom.xml
index e6857e4..b16ed5b 100644
--- a/enforcer-rules/pom.xml
+++ b/enforcer-rules/pom.xml
@@ -78,10 +78,12 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
diff --git a/maven-enforcer-plugin/pom.xml b/maven-enforcer-plugin/pom.xml
index ec32c3b..35052bc 100644
--- a/maven-enforcer-plugin/pom.xml
+++ b/maven-enforcer-plugin/pom.xml
@@ -85,6 +85,21 @@
       <artifactId>maven-plugin-annotations</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+    	<groupId>org.mockito</groupId>
+    	<artifactId>mockito-core</artifactId>
+    	<scope>test</scope>
+    </dependency>
+    <dependency>
+	  <groupId>org.hamcrest</groupId>
+	  <artifactId>hamcrest-core</artifactId>
+	  <scope>test</scope>
+	</dependency>
+    <dependency>
+    	<groupId>junit</groupId>
+    	<artifactId>junit</artifactId>
+    	<scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java b/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
index c3f7f46..2f1ea5e 100644
--- a/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
+++ b/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
@@ -22,8 +22,8 @@
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
-import org.apache.maven.enforcer.rule.api.EnforcerLevel;
 
+import org.apache.maven.enforcer.rule.api.EnforcerLevel;
 import org.apache.maven.enforcer.rule.api.EnforcerRule;
 import org.apache.maven.enforcer.rule.api.EnforcerRule2;
 import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
@@ -142,7 +142,8 @@
                             if ( ignoreCache || shouldExecute( rule ) )
                             {
                                 // execute the rule
-                                // noinspection SynchronizationOnLocalVariableOrMethodParameter
+                                // noinspection
+                                // SynchronizationOnLocalVariableOrMethodParameter
                                 synchronized ( rule )
                                 {
                                     rule.execute( helper );
@@ -180,6 +181,7 @@
                 }
 
                 // if we found anything
+                // CHECKSTYLE_OFF: LineLength
                 if ( !list.isEmpty() )
                 {
                     for ( String failure : list )
@@ -188,12 +190,11 @@
                     }
                     if ( fail && hasErrors )
                     {
-                        // CHECKSTYLE_OFF: LineLength
                         throw new MojoExecutionException(
                                                           "Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed." );
-                        // CHECKSTYLE_ON: LineLength
                     }
                 }
+                // CHECKSTYLE_ON: LineLength
             }
             else
             {
diff --git a/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
index da6769f..7c6401f 100644
--- a/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
+++ b/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -29,10 +29,7 @@
         </goals>
       </pluginExecutionFilter>
       <action>
-        <execute>
-          <runOnIncremental>false</runOnIncremental>
-          <runOnConfiguration>true</runOnConfiguration>
-        </execute>
+      	<ignore/>
       </action>
     </pluginExecution>
   </pluginExecutions>
diff --git a/maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/TestEnforceMojo.java b/maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/TestEnforceMojo.java
index 862c685..1e2ae42 100644
--- a/maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/TestEnforceMojo.java
+++ b/maven-enforcer-plugin/src/test/java/org/apache/maven/plugins/enforcer/TestEnforceMojo.java
@@ -19,25 +19,33 @@
  * under the License.
  */
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.apache.maven.enforcer.rule.api.EnforcerRule;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.runners.MockitoJUnitRunner;
 
 /**
  * Exhaustively check the enforcer mojo.
  * 
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * 
  */
+@RunWith( MockitoJUnitRunner.class )
 public class TestEnforceMojo
-    extends TestCase
 {
 
-    public void testEnforceMojo ()
+    @InjectMocks
+    EnforceMojo mojo;
+
+    @Test
+    public void testEnforceMojo()
         throws MojoExecutionException
     {
-        EnforceMojo mojo = new EnforceMojo();
         mojo.setFail( false );
         mojo.setSession( EnforcerTestUtils.getMavenSession() );
         mojo.setProject( new MockProject() );
@@ -89,27 +97,28 @@
 
     }
 
-    public void testCaching () throws MojoExecutionException
+    @Test
+    public void testCaching()
+        throws MojoExecutionException
     {
-        EnforceMojo mojo = new EnforceMojo();
         mojo.setFail( true );
         mojo.setSession( EnforcerTestUtils.getMavenSession() );
         mojo.setProject( new MockProject() );
 
         MockEnforcerRule[] rules = new MockEnforcerRule[10];
-        
-        //check that basic caching works.
+
+        // check that basic caching works.
         rules[0] = new MockEnforcerRule( false, "", true, true );
         rules[1] = new MockEnforcerRule( false, "", true, true );
         mojo.setRules( rules );
 
         EnforceMojo.cache.clear();
         mojo.execute();
-        
-        assertTrue( "Expected this rule to be executed.",rules[0].executed );
-        assertFalse( "Expected this rule not to be executed.",rules[1].executed);
-        
-        //check that skip caching works.
+
+        assertTrue( "Expected this rule to be executed.", rules[0].executed );
+        assertFalse( "Expected this rule not to be executed.", rules[1].executed );
+
+        // check that skip caching works.
         rules[0] = new MockEnforcerRule( false, "", true, true );
         rules[1] = new MockEnforcerRule( false, "", true, true );
         mojo.setRules( rules );
@@ -117,13 +126,13 @@
         EnforceMojo.cache.clear();
         mojo.ignoreCache = true;
         mojo.execute();
-        
-        assertTrue( "Expected this rule to be executed.",rules[0].executed );
-        assertTrue( "Expected this rule to be executed.",rules[1].executed );
-        
+
+        assertTrue( "Expected this rule to be executed.", rules[0].executed );
+        assertTrue( "Expected this rule to be executed.", rules[1].executed );
+
         mojo.ignoreCache = false;
-        
-        //check that different ids are compared.
+
+        // check that different ids are compared.
         rules[0] = new MockEnforcerRule( false, "1", true, true );
         rules[1] = new MockEnforcerRule( false, "2", true, true );
         rules[2] = new MockEnforcerRule( false, "2", true, true );
@@ -131,12 +140,12 @@
 
         EnforceMojo.cache.clear();
         mojo.execute();
-        
-        assertTrue( "Expected this rule to be executed.",rules[0].executed );
-        assertTrue( "Expected this rule to be executed.",rules[1].executed);
-        assertFalse( "Expected this rule not to be executed.",rules[2].executed);
-        
-        //check that future overrides are working
+
+        assertTrue( "Expected this rule to be executed.", rules[0].executed );
+        assertTrue( "Expected this rule to be executed.", rules[1].executed );
+        assertFalse( "Expected this rule not to be executed.", rules[2].executed );
+
+        // check that future overrides are working
         rules[0] = new MockEnforcerRule( false, "1", true, true );
         rules[1] = new MockEnforcerRule( false, "1", false, true );
         rules[2] = null;
@@ -144,11 +153,11 @@
 
         EnforceMojo.cache.clear();
         mojo.execute();
-        
-        assertTrue( "Expected this rule to be executed.",rules[0].executed );
-        assertTrue( "Expected this rule to be executed.",rules[1].executed);
 
-        //check that future isResultValid is used
+        assertTrue( "Expected this rule to be executed.", rules[0].executed );
+        assertTrue( "Expected this rule to be executed.", rules[1].executed );
+
+        // check that future isResultValid is used
         rules[0] = new MockEnforcerRule( false, "1", true, true );
         rules[1] = new MockEnforcerRule( false, "1", true, false );
         rules[2] = null;
@@ -156,59 +165,63 @@
 
         EnforceMojo.cache.clear();
         mojo.execute();
-        
-        assertTrue( "Expected this rule to be executed.",rules[0].executed );
-        assertTrue( "Expected this rule to be executed.",rules[1].executed);
+
+        assertTrue( "Expected this rule to be executed.", rules[0].executed );
+        assertTrue( "Expected this rule to be executed.", rules[1].executed );
 
     }
-    
-    public void testCachePersistence1() throws MojoExecutionException
+
+    @Test
+    public void testCachePersistence1()
+        throws MojoExecutionException
     {
-        EnforceMojo mojo = new EnforceMojo();
         mojo.setFail( true );
         mojo.setSession( EnforcerTestUtils.getMavenSession() );
         mojo.setProject( new MockProject() );
 
         MockEnforcerRule[] rules = new MockEnforcerRule[10];
-        
-        //check that basic caching works.
+
+        // check that basic caching works.
         rules[0] = new MockEnforcerRule( false, "", true, true );
         rules[1] = new MockEnforcerRule( false, "", true, true );
         mojo.setRules( rules );
 
         EnforceMojo.cache.clear();
         mojo.execute();
-        
-        assertTrue( "Expected this rule to be executed.",rules[0].executed );
-        assertFalse( "Expected this rule not to be executed.",rules[1].executed);
-        
+
+        assertTrue( "Expected this rule to be executed.", rules[0].executed );
+        assertFalse( "Expected this rule not to be executed.", rules[1].executed );
+
     }
-    
-    public void testCachePersistence2() throws MojoExecutionException
+
+    @Test
+    public void testCachePersistence2()
+        throws MojoExecutionException
     {
-        EnforceMojo mojo = new EnforceMojo();
         mojo.setFail( true );
         mojo.setSession( EnforcerTestUtils.getMavenSession() );
         mojo.setProject( new MockProject() );
 
         MockEnforcerRule[] rules = new MockEnforcerRule[10];
-        
-        //check that basic caching works.
+
+        // check that basic caching works.
         rules[0] = new MockEnforcerRule( false, "", true, true );
         rules[1] = new MockEnforcerRule( false, "", true, true );
         mojo.setRules( rules );
 
         mojo.execute();
-        
-        assertFalse( "Expected this rule not to be executed.",rules[0].executed);
-        assertFalse( "Expected this rule not to be executed.",rules[1].executed);
-        
+
+        assertFalse( "Expected this rule not to be executed.", rules[0].executed );
+        assertFalse( "Expected this rule not to be executed.", rules[1].executed );
+
     }
-    
-    public void testCachePersistence3() throws MojoExecutionException
+
+    @Test
+    public void testCachePersistence3()
+        throws MojoExecutionException
     {
         System.gc();
-        
+
         try
         {
             Thread.sleep( 1000 );
@@ -216,23 +229,22 @@
         catch ( InterruptedException e )
         {
         }
-        
-        EnforceMojo mojo = new EnforceMojo();
+
         mojo.setFail( true );
         mojo.setSession( EnforcerTestUtils.getMavenSession() );
         mojo.setProject( new MockProject() );
 
         MockEnforcerRule[] rules = new MockEnforcerRule[10];
-        
-        //check that basic caching works.
+
+        // check that basic caching works.
         rules[0] = new MockEnforcerRule( false, "", true, true );
         rules[1] = new MockEnforcerRule( false, "", true, true );
         mojo.setRules( rules );
 
         mojo.execute();
-        
-        assertFalse( "Expected this rule not to be executed.",rules[0].executed);
-        assertFalse( "Expected this rule not to be executed.",rules[1].executed);
-        
+
+        assertFalse( "Expected this rule not to be executed.", rules[0].executed );
+        assertFalse( "Expected this rule not to be executed.", rules[1].executed );
+
     }
 }
diff --git a/pom.xml b/pom.xml
index 89f4090..f750d94 100644
--- a/pom.xml
+++ b/pom.xml
@@ -121,15 +121,19 @@
         <version>3.0.20</version>
       </dependency>
       <dependency>
+		  <groupId>org.hamcrest</groupId>
+		  <artifactId>hamcrest-core</artifactId>
+		  <version>1.3</version>
+		</dependency>
+      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.11</version>
-        <scope>test</scope>
       </dependency>
       <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-core</artifactId>
-        <version>1.9.0</version>
+        <version>1.9.5</version>
         <scope>test</scope>
       </dependency>
       <dependency>