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/04/14 12:10:05 UTC
[maven-project-info-reports-plugin] branch MPIR-366 updated:
[MPIR-366] Drop Maven2 support Reduce stdout logging during unittests
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 e3b2475 [MPIR-366] Drop Maven2 support Reduce stdout logging during unittests
e3b2475 is described below
commit e3b24755849cbe8f72b769af3f4e0dc3e49b15e8
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Apr 14 14:09:57 2018 +0200
[MPIR-366] Drop Maven2 support
Reduce stdout logging during unittests
---
.../report/projectinfo/ModulesReportTest.java | 12 +++++
.../projectinfo/PluginManagementReportTest.java | 55 +++++++++++++++++++++-
2 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java
index f4577ea..3202960 100644
--- a/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java
+++ b/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java
@@ -25,6 +25,7 @@ import java.net.URL;
import java.util.Collections;
import org.apache.commons.io.FileUtils;
+import org.apache.maven.plugin.testing.SilentLog;
import org.apache.maven.report.projectinfo.stubs.SubProject1Stub;
import org.codehaus.plexus.util.ReflectionUtils;
@@ -45,6 +46,17 @@ public class ModulesReportTest
* WebConversation object
*/
private static final WebConversation WEB_CONVERSATION = new WebConversation();
+
+ @Override
+ protected AbstractProjectInfoReport createReportMojo( String goal, File pluginXmlFile )
+ throws Exception
+ {
+ AbstractProjectInfoReport mojo = super.createReportMojo( goal, pluginXmlFile );
+
+ mojo.setLog( new SilentLog() );
+
+ return mojo;
+ }
/**
* Test report
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..59f3bf0 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;
@@ -30,7 +43,6 @@ import com.meterware.httpunit.WebTable;
/**
* @author Nick Stolwijk
- * @version $Id$
* @since 2.1
*/
public class PluginManagementReportTest
@@ -41,6 +53,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 +118,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.