maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject svn commit: r1651179 - in /maven/enforcer/trunk: .gitignore enforcer-rules/src/site/apt/banDistributionManagement.apt.vm enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BanDistributionManagementTest.java
Date Mon, 12 Jan 2015 19:40:47 GMT
Author: khmarbaise
Date: Mon Jan 12 19:40:46 2015
New Revision: 1651179

URL: http://svn.apache.org/r1651179
Log:
Improved test code.

Modified:
    maven/enforcer/trunk/.gitignore
    maven/enforcer/trunk/enforcer-rules/src/site/apt/banDistributionManagement.apt.vm
    maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BanDistributionManagementTest.java

Modified: maven/enforcer/trunk/.gitignore
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/.gitignore?rev=1651179&r1=1651178&r2=1651179&view=diff
==============================================================================
--- maven/enforcer/trunk/.gitignore (original)
+++ maven/enforcer/trunk/.gitignore Mon Jan 12 19:40:46 2015
@@ -3,6 +3,7 @@ target
 .classpath
 .settings
 .idea/
+.svn
 *.iml
 .settings
 .classpath

Modified: maven/enforcer/trunk/enforcer-rules/src/site/apt/banDistributionManagement.apt.vm
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/site/apt/banDistributionManagement.apt.vm?rev=1651179&r1=1651178&r2=1651179&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/site/apt/banDistributionManagement.apt.vm (original)
+++ maven/enforcer/trunk/enforcer-rules/src/site/apt/banDistributionManagement.apt.vm Mon
Jan 12 19:40:46 2015
@@ -75,7 +75,7 @@ Ban Distribution Management
 +---+
 
   The above configuration will prevent any declaration of distributionManagement
-  in your pom files at all whereas the parent is simply ignored.
+  in your pom files except in the parent.
   
   Let use take a look at the following project which is a typical multi-module project.
  

Modified: maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BanDistributionManagementTest.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BanDistributionManagementTest.java?rev=1651179&r1=1651178&r2=1651179&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BanDistributionManagementTest.java
(original)
+++ maven/enforcer/trunk/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/BanDistributionManagementTest.java
Mon Jan 12 19:40:46 2015
@@ -223,26 +223,18 @@ public class BanDistributionManagementTe
                                                                                     Site
site )
         throws ExpressionEvaluationException
     {
-        project = mock( MavenProject.class );
-        when( project.getPackaging() ).thenReturn( "jar" );
-        when( project.getDistributionManagement() ).thenReturn( null );
-
-        MavenProject parentProject = mock( MavenProject.class );
+        project = setupProject( null );
 
         DistributionManagement dmParent = mock( DistributionManagement.class );
         when( dmParent.getRepository() ).thenReturn( repository );
         when( dmParent.getSnapshotRepository() ).thenReturn( snapshotRepository );
         when( dmParent.getSite() ).thenReturn( site );
 
+        MavenProject parentProject = mock( MavenProject.class );
         when( parentProject.getDistributionManagement() ).thenReturn( dmParent );
-
         when( project.getParent() ).thenReturn( parentProject );
 
-        helper = mock( EnforcerRuleHelper.class );
-        when( helper.evaluate( "${project}" ) ).thenReturn( project );
-        BanDistributionManagement rule = new BanDistributionManagement();
-
-        when( helper.getLog() ).thenReturn( mock( Log.class ) );
+        BanDistributionManagement rule = setupEnforcerRule();
 
         return rule;
     }
@@ -250,15 +242,9 @@ public class BanDistributionManagementTe
     private BanDistributionManagement setupProjectWithoutDistributionManagement()
         throws ExpressionEvaluationException
     {
-        project = mock( MavenProject.class );
-        when( project.getPackaging() ).thenReturn( "jar" );
-        when( project.getDistributionManagement() ).thenReturn( null );
+        project = setupProject( null );
 
-        helper = mock( EnforcerRuleHelper.class );
-        when( helper.evaluate( "${project}" ) ).thenReturn( project );
-        BanDistributionManagement rule = new BanDistributionManagement();
-
-        when( helper.getLog() ).thenReturn( mock( Log.class ) );
+        BanDistributionManagement rule = setupEnforcerRule();
 
         return rule;
     }
@@ -268,21 +254,35 @@ public class BanDistributionManagementTe
                                                                               Site site )
         throws ExpressionEvaluationException
     {
-        project = mock( MavenProject.class );
-        when( project.getPackaging() ).thenReturn( "jar" );
         DistributionManagement dm = mock( DistributionManagement.class );
         when( dm.getRepository() ).thenReturn( repository );
         when( dm.getSnapshotRepository() ).thenReturn( snapshotRepository );
         when( dm.getSite() ).thenReturn( site );
 
-        when( project.getDistributionManagement() ).thenReturn( dm );
+        project = setupProject( dm );
+
+        BanDistributionManagement rule = setupEnforcerRule();
+
+        return rule;
+    }
+
+    private MavenProject setupProject( DistributionManagement distributionManagement )
+    {
+        MavenProject project = mock( MavenProject.class );
+        when( project.getPackaging() ).thenReturn( "jar" );
+        when( project.getDistributionManagement() ).thenReturn( distributionManagement );
+        return project;
+    }
 
+    private BanDistributionManagement setupEnforcerRule()
+        throws ExpressionEvaluationException
+    {
         helper = mock( EnforcerRuleHelper.class );
         when( helper.evaluate( "${project}" ) ).thenReturn( project );
         BanDistributionManagement rule = new BanDistributionManagement();
 
         when( helper.getLog() ).thenReturn( mock( Log.class ) );
-
         return rule;
     }
+
 }



Mime
View raw message