You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ad...@apache.org on 2017/12/17 12:14:18 UTC
[maven-pmd-plugin] branch master updated: Now really find a free
port. Wiremock internally just uses port 8080 if no port is given
This is an automated email from the ASF dual-hosted git repository.
adangel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 4db6385 Now really find a free port. Wiremock internally just uses port 8080 if no port is given
4db6385 is described below
commit 4db638500610b9ce28f4e7bc9248309db7302082
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Sun Dec 17 13:12:55 2017 +0100
Now really find a free port.
Wiremock internally just uses port 8080 if no port is given
---
.../java/org/apache/maven/plugins/pmd/PmdReportTest.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
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 f1a9b58..2ac342a 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -23,6 +23,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.net.ServerSocket;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
@@ -147,7 +148,8 @@ public class PmdReportTest
PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
// Additional test case for MPMD-174 (https://issues.apache.org/jira/browse/MPMD-174).
- WireMockServer mockServer = new WireMockServer();
+ int port = determineFreePort();
+ WireMockServer mockServer = new WireMockServer( port );
mockServer.start();
String sonarRuleset =
@@ -207,6 +209,15 @@ public class PmdReportTest
mockServer.stop();
}
+ private int determineFreePort()
+ {
+ try (ServerSocket socket = new ServerSocket(0)) {
+ return socket.getLocalPort();
+ } catch (IOException e) {
+ throw new RuntimeException( "Couldn't find a free port.", e );
+ }
+ }
+
/**
* With custom rulesets
*
--
To stop receiving notification emails like this one, please contact
['"commits@maven.apache.org" <co...@maven.apache.org>'].