From 4a03d888c36466bc9a1e580a6bcbd1ea8b3887e6 Mon Sep 17 00:00:00 2001 From: Michael Bouschen Date: Sun, 26 Nov 2023 11:56:11 +0100 Subject: [PATCH] JDO-830: Migrate JUnit tests in tck to version 5 skip test classes in comments --- .../main/java/org/apache/jdo/exectck/PropertyUtils.java | 2 +- exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java | 4 +++- .../src/main/java/org/apache/jdo/exectck/Utilities.java | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java b/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java index 71224127..7aeeaa66 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java @@ -36,7 +36,7 @@ private PropertyUtils() { * @param col collection to contain String items */ public static void string2Collection(String names, Collection col) { - String[] items = names.split("[ \t\n,;]+"); + String[] items = names.split(Utilities.DELIMITER_REGEX); col.addAll(Arrays.asList(items)); } diff --git a/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java b/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java index 22f208d6..8a8d1ec2 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java @@ -29,6 +29,7 @@ import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -479,7 +480,8 @@ private List getTestClasses(Properties props, String cfg, String exclude classes = Utilities.removeSubstrs(classes, excludeList); List classesList = new ArrayList(); PropertyUtils.string2Collection(classes, classesList); - return classesList; + // skip test classes in comments + return classesList.stream().filter(n -> !n.startsWith("#")).collect(Collectors.toList()); } /** diff --git a/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java b/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java index ef4bf7e5..65669f79 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java @@ -30,10 +30,13 @@ public class Utilities { - private Utilities() {} + static final String DELIMITER_REGEX = "[ \t\n,;]+"; private static final String DATE_FORMAT_NOW = "yyyyMMdd-HHmmss"; + private Utilities() { + // This method is deliberately left empty. + } /* * Return the current date/time as a String. */ @@ -58,7 +61,7 @@ public static String urls2ClasspathString(List urls) { } public static String removeSubstrs(String original, String exclude) { - String[] deleteThese = exclude.split(" "); + String[] deleteThese = exclude.split(DELIMITER_REGEX); String filtered = original; for (String sub : deleteThese) { filtered = filtered.replaceAll(sub.trim(), "");