You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2022/08/22 23:11:35 UTC

[commons-net] branch master updated: Use canonical name

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

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git


The following commit(s) were added to refs/heads/master by this push:
     new cdeee28a Use canonical name
cdeee28a is described below

commit cdeee28a87a3dc50743025964b6fbc13e4a52d12
Author: Sebb <se...@apache.org>
AuthorDate: Tue Aug 23 00:11:30 2022 +0100

    Use canonical name
    
    [skip ci]
---
 src/test/java/org/apache/commons/net/examples/MainTest.java | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/net/examples/MainTest.java b/src/test/java/org/apache/commons/net/examples/MainTest.java
index 321d15f4..d442e190 100644
--- a/src/test/java/org/apache/commons/net/examples/MainTest.java
+++ b/src/test/java/org/apache/commons/net/examples/MainTest.java
@@ -37,7 +37,7 @@ public class MainTest {
         System.out.println("Initial name " + name);
         name = name.replace(".class", "");
         name = name.replace("/", ".");
-        System.out.println("Updated name " + name);
+        name = name.replace("\\", "."); // Allow for Windows
         try {
             final Class<?> clazz = Class.forName(name, false, MainTest.class.getClassLoader());
             clazz.getMethod("main", String[].class);
@@ -109,7 +109,7 @@ public class MainTest {
     private Properties scanClasses() throws IOException {
         final CodeSource codeSource = Main.class.getProtectionDomain().getCodeSource();
         // ensure special characters are decoded OK by uing the charset
-        final String sourceFile = URLDecoder.decode(codeSource.getLocation().getFile(),"UTF-8");
+        final String sourceFile = new File(URLDecoder.decode(codeSource.getLocation().getFile(),"UTF-8")).getCanonicalPath();
         final Properties p = new Properties();
         if (sourceFile.endsWith(".jar")) {
             try (final JarFile jf = new JarFile(sourceFile)) {
@@ -124,8 +124,7 @@ public class MainTest {
             final File examples = new File(sourceFile, "org/apache/commons/net/examples"); // must match top level examples package name
             if (examples.exists()) {
                 System.out.println("sf="+sourceFile);
-                System.out.println("cp="+new File(sourceFile).getCanonicalPath());
-                scanForClasses(sourceFile.length(), examples, p);
+                scanForClasses(sourceFile.length() + 1, examples, p);
             } else {
                 fail("Could not find examples classes: " + examples.getCanonicalPath());
             }