From 3ffd4d3762028b1b0a8f714297a21de37d0c5649 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 5 Sep 2021 20:04:16 +0200 Subject: [PATCH] [MPMD-308] Set Maven 3.1.0 as minimum version Remove now unnecessary maven-compat, fix test Downgrade wiremock, to use a with maven compatible guava version. Closes #46 --- pom.xml | 26 +++++++++++-------- .../pmd/CpdViolationCheckMojoTest.java | 15 ++++++++--- .../maven/plugins/pmd/PmdReportTest.java | 10 ++++--- .../maven/plugins/pmd/exec/ExecutorTest.java | 2 +- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index c5ccdee9..657f4ee8 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ under the License. - 3.0 + 3.1.0 1.9.1 1.9.2 8 @@ -131,12 +131,18 @@ under the License. org.apache.maven.shared maven-common-artifact-filters - 3.1.0 + ${mavenVersion} + + + org.sonatype.sisu + sisu-guice + + org.apache.maven maven-embedder - 3.1.0 + ${mavenVersion} provided @@ -238,22 +244,20 @@ under the License. - - org.apache.maven - maven-compat - ${mavenVersion} - test - org.apache.maven.plugin-testing maven-plugin-testing-harness - 2.1 + ${mavenVersion} test com.github.tomakehurst wiremock - 2.9.0 + + 1.49 test diff --git a/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java b/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java index 081da747..730a30aa 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/pmd/CpdViolationCheckMojoTest.java @@ -42,13 +42,22 @@ protected void setUp() public void testDefaultConfiguration() throws Exception { + File testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" ); + final CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom ); + mojo.execute(); + + // clear the output from previous pmd:cpd execution + CapturingPrintStream.init( true ); + try { - final File testPom = + testPom = new File( getBasedir(), "src/test/resources/unit/default-configuration/pmd-check-default-configuration-plugin-config.xml" ); - final CpdViolationCheckMojo mojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom ); - mojo.execute(); + final CpdViolationCheckMojo cpdViolationMojo = (CpdViolationCheckMojo) lookupMojo( "cpd-check", testPom ); + cpdViolationMojo.execute(); fail( "MojoFailureException should be thrown." ); } diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java index f8e46835..93f9f885 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java +++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java @@ -245,10 +245,11 @@ public void testFileURL() final String sonarProfileUrl = sonarBaseUrl + "/export?format=pmd&language=java&name=Sonar%2520way"; final String sonarExportRulesetUrl = "http://localhost:" + mockServer.port() + sonarProfileUrl; - mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarBaseUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type", + WireMock.configureFor( "localhost", port ); + WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( sonarBaseUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type", "text/html" ).withBody( sonarMainPageHtml ) ) ); - mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type", + WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) ).willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type", "text/xml" ).withBody( sonarRuleset ) ) ); URL url = getClass().getClassLoader().getResource( "rulesets/java/basic.xml" ); @@ -719,10 +720,11 @@ public void testPmdReportResolveRulesets() final String myRulesetBaseUrl = "/config/my-ruleset.xml"; final String myRulesetUrl = "http://localhost:" + mockServer.port() + myRulesetBaseUrl; - mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) ) + WireMock.configureFor( "localhost", port ); + WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( sonarProfileUrl ) ) .willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type", "text/xml" ).withBody( sonarRuleset ) ) ); - mockServer.stubFor( WireMock.get( WireMock.urlEqualTo( myRulesetBaseUrl ) ) + WireMock.stubFor( WireMock.get( WireMock.urlEqualTo( myRulesetBaseUrl ) ) .willReturn( WireMock.aResponse().withStatus( 200 ).withHeader( "Content-Type", "text/xml" ).withBody( sonarRuleset ) ) ); diff --git a/src/test/java/org/apache/maven/plugins/pmd/exec/ExecutorTest.java b/src/test/java/org/apache/maven/plugins/pmd/exec/ExecutorTest.java index 67dad92c..d63eecbb 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/exec/ExecutorTest.java +++ b/src/test/java/org/apache/maven/plugins/pmd/exec/ExecutorTest.java @@ -25,8 +25,8 @@ import java.net.URLClassLoader; import org.apache.commons.lang3.SystemUtils; -import org.junit.Assert; +import junit.framework.Assert; import junit.framework.TestCase; public class ExecutorTest extends TestCase