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 2021/08/31 18:11:44 UTC

[maven-pmd-plugin] branch MPMD-320 updated: consider windows in unit test

This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch MPMD-320
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git


The following commit(s) were added to refs/heads/MPMD-320 by this push:
     new 205cca3  consider windows in unit test
205cca3 is described below

commit 205cca34861553c59bca7409008be81f9e9b8456
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Tue Aug 31 20:11:37 2021 +0200

    consider windows in unit test
---
 .../java/org/apache/maven/plugins/pmd/exec/ExecutorTest.java   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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 4898147..67dad92 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
@@ -24,6 +24,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 
+import org.apache.commons.lang3.SystemUtils;
 import org.junit.Assert;
 
 import junit.framework.TestCase;
@@ -31,12 +32,17 @@ import junit.framework.TestCase;
 public class ExecutorTest extends TestCase
 {
     public void testBuildClasspath() throws MalformedURLException {
-        String pathname = "/home/test/dir with space/mylib.jar";
+        String basename = "home/test/dir with space/mylib.jar";
+        String pathname = new File("/", basename).getPath();
+        if ( SystemUtils.IS_OS_WINDOWS )
+        {
+            pathname = new File( File.listRoots()[0], basename ).getPath();
+        }
         URL[] urls = new URL[] { new File(pathname).toURI().toURL() };
         URLClassLoader mockedClassLoader = new URLClassLoader( urls );
 
         StringBuilder classpath = new StringBuilder();
         Executor.buildClasspath(classpath, mockedClassLoader);
-        Assert.assertEquals( pathname + ":", classpath.toString() );
+        Assert.assertEquals( pathname + File.pathSeparator, classpath.toString() );
     }
 }