Skip to content

Commit

Permalink
Make PackageUtils compliant with JPMS
Browse files Browse the repository at this point in the history
  • Loading branch information
krmahadevan committed Nov 2, 2022
1 parent 8ecef60 commit 3b84427
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Current
Fixed: GITHUB-2308: StringIndexOutOfBoundsException in findClassesInPackage - Surefire/Maven - JDK 11 fails (Krishnan Mahadevan)
Fixed: GITHUB:2788: TestResult.isSuccess() is TRUE when test fails due to expectedExceptions (Krishnan Mahadevan)
Fixed: GITHUB-2800: Running Test Classes with Inherited @Factory and @DataProvider Annotated Non-Static Methods Fail (Krishnan Mahadevan)
New: Ability to provide custom error message for assertThrows\expectThrows methods (Anatolii Yuzhakov)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.testng.internal;

import static java.nio.charset.StandardCharsets.UTF_8;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.JarURLConnection;
import java.net.URL;
Expand All @@ -25,7 +26,6 @@
* @author <a href="mailto:cedric@beust.com">Cedric Beust</a>
*/
public class PackageUtils {
private static final String UTF_8 = "UTF-8";
private static final String PACKAGE_UTILS = PackageUtils.class.getSimpleName();
private static String[] testClassPaths;

Expand All @@ -36,11 +36,6 @@ private PackageUtils() {
// Utility class. Defeat instantiation.
}

/** Add a class loader to the searchable loaders. */
public static void addClassLoader(final ClassLoader loader) {
classLoaders.add(loader);
}

/**
* @param packageName - The package name
* @param included - The inclusion list.
Expand Down Expand Up @@ -96,6 +91,9 @@ public static String[] findClassesInPackage(
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String name = entry.getName();
if (name.startsWith("module-info") || name.startsWith("META-INF")) {
continue;
}
if (name.charAt(0) == '/') {
name = name.substring(1);
}
Expand Down Expand Up @@ -183,11 +181,7 @@ private static boolean matchTestClasspath(URL url, String lastFragment, boolean
}

String fileName = "";
try {
fileName = URLDecoder.decode(url.getFile(), UTF_8);
} catch (UnsupportedEncodingException ueex) {
// ignore. should never happen
}
fileName = URLDecoder.decode(url.getFile(), UTF_8);

for (String classpathFrag : classpathFragments) {
String path = classpathFrag + lastFragment;
Expand Down

0 comments on commit 3b84427

Please sign in to comment.