This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
The following commit(s) were added to refs/heads/master by this push:
new 4a489b61 @MethodSource can't be refactored w/o scanning sources...
4a489b61 is described below
commit 4a489b61f13e481b40251e9894979e72465cbbd3
Author: Gary David Gregory (Code signing key) <[email protected]>
AuthorDate: Fri Oct 28 12:54:20 2022 -0400
@MethodSource can't be refactored w/o scanning sources...
---
.../java/org/apache/bcel/generic/JavaHome.java | 45 ++++++++++++++--------
.../bcel/util/ModularRuntimeImageTestCase.java | 8 ++--
2 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/src/test/java/org/apache/bcel/generic/JavaHome.java
b/src/test/java/org/apache/bcel/generic/JavaHome.java
index 04d4952a..76dcddb6 100644
--- a/src/test/java/org/apache/bcel/generic/JavaHome.java
+++ b/src/test/java/org/apache/bcel/generic/JavaHome.java
@@ -87,15 +87,6 @@ public class JavaHome {
return streamJavaHomes().flatMap(JavaHome::streamJars);
}
- /**
- * Used from {@code @MethodSource} for tests.
- *
- * @return a stream of Java jar paths.
- */
- public static Stream<Path> streamModulePaths() {
- return streamJavaHomes().flatMap(JavaHome::streamModules);
- }
-
/**
* Used from {@code @MethodSource} for tests.
*
@@ -104,7 +95,6 @@ public class JavaHome {
public static Stream<JavaHome> streamJavaHomes() {
return streamJavaHomeString().map(JavaHome::from);
}
-
public static Stream<String> streamJavaHomeString() {
final Stream<String> streamW = SystemUtils.IS_OS_WINDOWS ?
streamWindowsStrings() : Stream.empty();
final Stream<String> streamK = Stream.concat(streamW,
streamFromCustomKeys());
@@ -112,6 +102,25 @@ public class JavaHome {
return Stream.concat(streamK, streamJ);
}
+
+ /**
+ * Used from {@code @MethodSource} for tests.
+ *
+ * @return a stream of Java jar paths.
+ */
+ public static Stream<ModularRuntimeImage> streamModularRuntimeImages() {
+ return streamJavaHomes().map(JavaHome::getModularRuntimeImage);
+ }
+
+ /**
+ * Used from {@code @MethodSource} for tests.
+ *
+ * @return a stream of Java jar paths.
+ */
+ public static Stream<Path> streamModulePaths() {
+ return streamJavaHomes().flatMap(JavaHome::streamModules);
+ }
+
private static Stream<String> streamPropertyAndEnvVarValues(final String
key) {
return Stream.concat(toPathStringStream(System.getProperty(key)),
toPathStringStream(System.getenv(key)));
}
@@ -149,22 +158,26 @@ public class JavaHome {
return find(path, maxDepth, matcher, options);
}
+ ModularRuntimeImage getModularRuntimeImage() {
+ try {
+ return new ModularRuntimeImage(path.toString());
+ } catch (final IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
Path getPath() {
return path;
}
- ModularRuntimeImage getModularRuntimeImage() throws IOException {
- return new ModularRuntimeImage(path.toString());
+ private Stream<Path> streamEndsWith(final String suffix) {
+ return find(10, (p, a) -> p.toString().endsWith(suffix));
}
private Stream<Path> streamJars() {
return streamEndsWith(".jar");
}
- private Stream<Path> streamEndsWith(final String suffix) {
- return find(10, (p, a) -> p.toString().endsWith(suffix));
- }
-
private Stream<Path> streamModules() {
return streamEndsWith(".jmod");
}
diff --git
a/src/test/java/org/apache/bcel/util/ModularRuntimeImageTestCase.java
b/src/test/java/org/apache/bcel/util/ModularRuntimeImageTestCase.java
index 040a8853..19634479 100644
--- a/src/test/java/org/apache/bcel/util/ModularRuntimeImageTestCase.java
+++ b/src/test/java/org/apache/bcel/util/ModularRuntimeImageTestCase.java
@@ -42,7 +42,7 @@ public class ModularRuntimeImageTestCase {
}
@ParameterizedTest
-
@MethodSource("org.apache.bcel.generic.JdkGenericDumpTestCase#findJavaHomes")
+
@MethodSource("org.apache.bcel.generic.JavaHome#streamModularRuntimeImages")
public void testListJreModule(final ModularRuntimeImage
modularRuntimeImage) throws IOException {
final List<Path> listEntries =
modularRuntimeImage.list(ModularRuntimeImage.MODULES_PATH + "/java.base");
assertFalse(listEntries.isEmpty());
@@ -50,7 +50,7 @@ public class ModularRuntimeImageTestCase {
}
@ParameterizedTest
-
@MethodSource("org.apache.bcel.generic.JdkGenericDumpTestCase#findJavaHomes")
+
@MethodSource("org.apache.bcel.generic.JavaHome#streamModularRuntimeImages")
public void testListJreModulePackageDir(final ModularRuntimeImage
modularRuntimeImage) throws IOException {
final List<Path> listEntries =
modularRuntimeImage.list(ModularRuntimeImage.MODULES_PATH +
"/java.base/java/lang");
assertFalse(listEntries.isEmpty());
@@ -58,7 +58,7 @@ public class ModularRuntimeImageTestCase {
}
@ParameterizedTest
-
@MethodSource("org.apache.bcel.generic.JdkGenericDumpTestCase#findJavaHomes")
+
@MethodSource("org.apache.bcel.generic.JavaHome#streamModularRuntimeImages")
public void testListJreModules(final ModularRuntimeImage
modularRuntimeImage) throws IOException {
final List<Path> listEntries =
modularRuntimeImage.list(ModularRuntimeImage.MODULES_PATH);
assertFalse(listEntries.isEmpty());
@@ -66,7 +66,7 @@ public class ModularRuntimeImageTestCase {
}
@ParameterizedTest
-
@MethodSource("org.apache.bcel.generic.JdkGenericDumpTestCase#findJavaHomes")
+
@MethodSource("org.apache.bcel.generic.JavaHome#streamModularRuntimeImages")
public void testListJrePackages(final ModularRuntimeImage
modularRuntimeImage) throws IOException {
final List<Path> listEntries =
modularRuntimeImage.list(ModularRuntimeImage.PACKAGES_PATH);
assertFalse(listEntries.isEmpty());