You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2018/03/31 14:50:51 UTC
[maven-project-info-reports-plugin] branch MPIR-366 updated:
[MPIR-366] Drop Maven2 support Remove exception from unittest
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MPIR-366
in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git
The following commit(s) were added to refs/heads/MPIR-366 by this push:
new 0e5e226 [MPIR-366] Drop Maven2 support Remove exception from unittest
0e5e226 is described below
commit 0e5e226be85d7a7860ce3850b22633b7b1649f2b
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Mar 31 16:50:45 2018 +0200
[MPIR-366] Drop Maven2 support
Remove exception from unittest
---
pom.xml | 8 +++-
.../projectinfo/AbstractProjectInfoTestCase.java | 2 -
.../projectinfo/PluginManagementReportTest.java | 54 ++++++++++++++++++++++
3 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index c775c9e..ae2f14f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -378,7 +378,13 @@ under the License.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>2.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/src/test/java/org/apache/maven/report/projectinfo/AbstractProjectInfoTestCase.java b/src/test/java/org/apache/maven/report/projectinfo/AbstractProjectInfoTestCase.java
index b0522d6..0b30746 100644
--- a/src/test/java/org/apache/maven/report/projectinfo/AbstractProjectInfoTestCase.java
+++ b/src/test/java/org/apache/maven/report/projectinfo/AbstractProjectInfoTestCase.java
@@ -219,6 +219,4 @@ public abstract class AbstractProjectInfoTestCase
return new File( outputDir, filename );
}
-
-
}
diff --git a/src/test/java/org/apache/maven/report/projectinfo/PluginManagementReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/PluginManagementReportTest.java
index 8548ab4..361a98e 100644
--- a/src/test/java/org/apache/maven/report/projectinfo/PluginManagementReportTest.java
+++ b/src/test/java/org/apache/maven/report/projectinfo/PluginManagementReportTest.java
@@ -19,8 +19,21 @@ package org.apache.maven.report.projectinfo;
* under the License.
*/
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.isA;
+
+import java.io.File;
import java.net.URL;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingResult;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.TextBlock;
import com.meterware.httpunit.WebConversation;
@@ -41,6 +54,33 @@ public class PluginManagementReportTest
*/
private static final WebConversation WEB_CONVERSATION = new WebConversation();
+
+
+ @Override
+ protected AbstractProjectInfoReport createReportMojo( String goal, File pluginXmlFile )
+ throws Exception
+ {
+ AbstractProjectInfoReport mojo = super.createReportMojo( goal, pluginXmlFile );
+
+ ProjectBuilder builder = mock( ProjectBuilder.class );
+
+ when( builder.build( isA( Artifact.class ),
+ isA( ProjectBuildingRequest.class ) ) ).thenAnswer( new Answer<ProjectBuildingResult>()
+ {
+ @Override
+ public ProjectBuildingResult answer( InvocationOnMock invocation )
+ throws Throwable
+ {
+ return createProjectBuildingResult( (Artifact) invocation.getArgument( 0 ),
+ "http://m.a.o/" );
+ }
+ } );
+
+ setVariableValueToObject( mojo, "projectBuilder", builder );
+
+ return mojo;
+ }
+
/**
* Test report
*
@@ -79,4 +119,18 @@ public class PluginManagementReportTest
TextBlock[] textBlocks = response.getTextBlocks();
assertEquals( getString( "report.plugin-management.title" ), textBlocks[0].getText() );
}
+
+ private static ProjectBuildingResult createProjectBuildingResult( Artifact artifact, String url )
+ {
+ ProjectBuildingResult result = mock( ProjectBuildingResult.class );
+ MavenProjectStub stub = new MavenProjectStub();
+ stub.setGroupId( artifact.getGroupId() );
+ stub.setArtifactId( artifact.getArtifactId() );
+ stub.setVersion( artifact.getVersion() );
+ stub.setUrl( url );
+
+ when( result.getProject() ).thenReturn( stub );
+
+ return result;
+ }
}
--
To stop receiving notification emails like this one, please contact
rfscholte@apache.org.