[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-18 Thread via GitHub


mboapache commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1398242075


##
tck/src/main/java/org/apache/jdo/tck/util/ResultSummary.java:
##
@@ -36,9 +37,14 @@ public class ResultSummary implements Serializable {
   /** The name of the file to store a serialized instance of this class. */
   private static final String FILE_NAME_OF_RESULT_SUMMARY = 
"ResultSummary.ser";
 
+  private static final DecimalFormat THREE_DIGITS_FORMATTER = new 
DecimalFormat("000");

Review Comment:
   The two constants are leftovers. I remove them.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jdo-dev-unsubscr...@db.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-18 Thread via GitHub


mboapache commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1398241937


##
tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java:
##
@@ -35,29 +36,23 @@ public class IsDetached extends DetachTest {
   private static final String ASSERTION_FAILED =
   "Assertion A8.5.6-1 JDOHelper.isDetached(Object) failed: ";
 
-  /**

Review Comment:
   I do not think so that someone wants to call the main method. 
   To run a TCK test you have to use the RunTCK plugin, in oder to get 
everything initialized that is requied by the TCK test classes. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jdo-dev-unsubscr...@db.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-18 Thread via GitHub


mboapache commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1398237350


##
tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java:
##
@@ -35,29 +36,23 @@ public class IsDetached extends DetachTest {
   private static final String ASSERTION_FAILED =
   "Assertion A8.5.6-1 JDOHelper.isDetached(Object) failed: ";
 
-  /**
-   * The main is called when the class is directly executed from 
the command line.
-   *
-   * @param args The arguments passed to the program.
-   */
-  public static void main(String[] args) {
-BatchTestRunner.run(IsDetached.class);
-  }
-
+  @Test
   public void testNullTransientAndUndetachableIsDetachedFalse() {
 pm = getPM();
 pm.currentTransaction().begin();
 
-assertFalse(ASSERTION_FAILED + "null object is detached", 
JDOHelper.isDetached(null));
-assertFalse(
-ASSERTION_FAILED + "transient object is detached", 
JDOHelper.isDetached(new Cart("bob")));
-assertFalse(
-ASSERTION_FAILED + "object of class marked not detachabled is 
detached",
-JDOHelper.isDetached(new Undetachable()));
+Assertions.assertFalse(

Review Comment:
   For me this is a preferred style. 
   Good catch, i will check for static imports of static methods.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jdo-dev-unsubscr...@db.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-18 Thread via GitHub


mboapache commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1398237350


##
tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java:
##
@@ -35,29 +36,23 @@ public class IsDetached extends DetachTest {
   private static final String ASSERTION_FAILED =
   "Assertion A8.5.6-1 JDOHelper.isDetached(Object) failed: ";
 
-  /**
-   * The main is called when the class is directly executed from 
the command line.
-   *
-   * @param args The arguments passed to the program.
-   */
-  public static void main(String[] args) {
-BatchTestRunner.run(IsDetached.class);
-  }
-
+  @Test
   public void testNullTransientAndUndetachableIsDetachedFalse() {
 pm = getPM();
 pm.currentTransaction().begin();
 
-assertFalse(ASSERTION_FAILED + "null object is detached", 
JDOHelper.isDetached(null));
-assertFalse(
-ASSERTION_FAILED + "transient object is detached", 
JDOHelper.isDetached(new Cart("bob")));
-assertFalse(
-ASSERTION_FAILED + "object of class marked not detachabled is 
detached",
-JDOHelper.isDetached(new Undetachable()));
+Assertions.assertFalse(

Review Comment:
   For me this is a preferred style. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jdo-dev-unsubscr...@db.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-18 Thread via GitHub


tzaeschke commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1398193849


##
tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java:
##
@@ -35,29 +36,23 @@ public class IsDetached extends DetachTest {
   private static final String ASSERTION_FAILED =
   "Assertion A8.5.6-1 JDOHelper.isDetached(Object) failed: ";
 
-  /**
-   * The main is called when the class is directly executed from 
the command line.
-   *
-   * @param args The arguments passed to the program.
-   */
-  public static void main(String[] args) {
-BatchTestRunner.run(IsDetached.class);
-  }
-
+  @Test
   public void testNullTransientAndUndetachableIsDetachedFalse() {
 pm = getPM();
 pm.currentTransaction().begin();
 
-assertFalse(ASSERTION_FAILED + "null object is detached", 
JDOHelper.isDetached(null));
-assertFalse(
-ASSERTION_FAILED + "transient object is detached", 
JDOHelper.isDetached(new Cart("bob")));
-assertFalse(
-ASSERTION_FAILED + "object of class marked not detachabled is 
detached",
-JDOHelper.isDetached(new Undetachable()));
+Assertions.assertFalse(

Review Comment:
   Using `Assertions.` instead of static import, is that a preferred style or 
pragmatic/convenience (which also would be totally reasonable considering the 
amount of changes)?



##
tck/src/main/java/org/apache/jdo/tck/util/ResultSummary.java:
##
@@ -36,9 +37,14 @@ public class ResultSummary implements Serializable {
   /** The name of the file to store a serialized instance of this class. */
   private static final String FILE_NAME_OF_RESULT_SUMMARY = 
"ResultSummary.ser";
 
+  private static final DecimalFormat THREE_DIGITS_FORMATTER = new 
DecimalFormat("000");

Review Comment:
   What are these for? They don't appear to be used...?



##
tck/src/main/java/org/apache/jdo/tck/util/SystemCfgSummary.java:
##
@@ -78,7 +88,7 @@ static String getSystemInfo() {
* @param path the path
* @param message the message
*/
-  static void saveSystemInfo(String path, String message) {
+  private void saveSystemInfo(String path, String message) {

Review Comment:
   I think this could remain 'static'.



##
tck/src/main/java/org/apache/jdo/tck/util/SystemCfgSummary.java:
##
@@ -31,7 +31,9 @@ public class SystemCfgSummary {
   /** The name of the system configuration summary file. */
   private static final String SYSCFG_FILE_NAME = "system_config.txt";
 
-  private static String newLine;
+  private static String NL = System.getProperty("line.separator");

Review Comment:
   Make 'final'?



##
tck/src/main/java/org/apache/jdo/tck/util/ResultSummary.java:
##
@@ -135,23 +139,48 @@ private static ResultSummary load(String directory) {
*
* @param result the result object
*/
-  private void increment(TestResult result) {
+  private void increment(TestExecutionSummary result) {
+// total numbers
 this.nrOfTotalConfigurations++;
-this.totalTestCount += result.runCount();
-if (!result.wasSuccessful()) {
+this.totalTestCount += result.getTestsFoundCount();
+if (result.getTestsFailedCount() > 0) {
   this.nrOfFailedConfigurations++;
-  this.totalFailureCount += result.failureCount();
-  this.totalErrorCount += result.errorCount();
+  this.totalFailureCount += result.getTestsFailedCount();
 }
   }
 
+  private void appendTestResult(
+  String directory, String idtype, String config, TestExecutionSummary 
result) {
+String resultFileName = directory + File.separator + RESULT_FILE_NAME;
+String header = "Running tests for " + config + " with " + idtype + ":" + 
NEWLINE + "  ";
+StringBuilder builder = new StringBuilder(header);
+builder.append(getTestResult(result));
+appendTCKResultMessage(resultFileName, builder.toString());
+  }
+
+  private String getTestResult(TestExecutionSummary summary) {
+StringBuilder builder = new StringBuilder();
+builder.append(summary.getTestsFailedCount() == 0 ? "OK " : "** ");
+builder.append("Tests found: ").append(summary.getTestsFoundCount());
+builder.append(", started: ").append(summary.getTestsStartedCount());
+builder.append(", succeeded: ").append(summary.getTestsSucceededCount());
+builder.append(", failed: ").append(summary.getTestsFailedCount());
+builder.append(", skipped: ").append(summary.getTestsSkippedCount());
+builder.append(", aborted: ").append(summary.getTestsAbortedCount());
+builder
+.append(", time: ")
+.append(((double) (summary.getTimeFinished() - 
summary.getTimeStarted()) / 1000.0))

Review Comment:
   I think the cast to `double` is unnecessary.



##
tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java:
##
@@ -35,29 +36,23 @@ public class IsDetached extends DetachTest {
   private static final String ASSERTION_FAILED =
   "Assertion A8.5.6-1 JDOHelper.isDetached(Object

[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-08 Thread via GitHub


mboapache commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1387254461


##
exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java:
##
@@ -528,13 +693,14 @@ public void execute() throws MojoExecutionException, 
MojoFailureException {
   + File.separator;
   String[] metadataExtensions = {"jdo", "jdoquery", "orm", "xml", 
"properties"};
   String fromFileName = null;
+  File toFile = null;
   String pkgName = null;
   int startIdx = -1;
   // iterator over list of abs name of metadata files in src
   Iterator fi = FileUtils.iterateFiles(new File(fromDirName), 
metadataExtensions, true);
   while (fi.hasNext()) {
 try {
-  fromFile = fi.next();
+  File fromFile = fi.next();

Review Comment:
   - I agree the try clause should only contain the FileUtil.copy
   - The files should be copied, because the enhanced directory should be kept 
in case you want to run the next tck run without enhacement.
   - I agree to declare the variables in place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jdo-dev-unsubscr...@db.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-08 Thread via GitHub


mboapache commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1387252360


##
exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java:
##
@@ -263,231 +396,261 @@ public void execute() throws MojoExecutionException, 
MojoFailureException {
 } catch (IOException ex) {
   Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
 }
+  }
 
-// Get ClassLoader URLs to build classpath below
-URL[] cpURLs = ((URLClassLoader) 
Thread.currentThread().getContextClassLoader()).getURLs();
-ArrayList urlList = new ArrayList<>(Arrays.asList(cpURLs));
-
-// Get contents of pmf properties file to build new file below
-String pmfPropsReadFileName = confDirectory + File.separator + 
pmfProperties;
-String defaultPropsContents = "";
+  /**
+   * Get classpath string: add new entries to URLS from loader
+   *
+   * @param urlList ClassLoader URLs
+   * @param enhancedDir
+   * @return
+   */
+  private String getClasspathString(List urlList, File enhancedDir) {
+String cpString;
+ArrayList cpList = new ArrayList<>();
+cpList.addAll(urlList);
 try {
-  defaultPropsContents = Utilities.readFile(pmfPropsReadFileName);
-} catch (IOException ex) {
+  URL url1 = enhancedDir.toURI().toURL();
+  URL url2 =
+  new File(buildDirectory + File.separator + CLASSES_DIR_NAME + 
File.separator)
+  .toURI()
+  .toURL();
+  if (runtckVerbose) {
+System.out.println("url2 is " + url2.toString());
+  }
+  cpList.add(url1);
+  cpList.add(url2);
+  String[] jars = {"jar"};
+  Iterator fi = FileUtils.iterateFiles(new File(extLibsDirectory), 
jars, true);
+  while (fi.hasNext()) {
+cpList.add(fi.next().toURI().toURL());
+  }
+  for (String dependency : 
this.dependencyClasspath.split(File.pathSeparator)) {
+cpList.add(new File(dependency).toURI().toURL());
+  }
+} catch (MalformedURLException ex) {
+  ex.printStackTrace();
   Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
 }
+cpString = Utilities.urls2ClasspathString(cpList);
+if (runtckVerbose) {
+  System.out.println("\nClasspath is " + cpString);
+}
+return cpString;
+  }
 
-// Reset logfile content (may not be empty if previous run crashed)
-resetFileContent(implLogFile);
-resetFileContent(TCK_LOG_FILE);
-
-int failureCount = 0;
-for (String db : dbs) {
-  System.setProperty("jdo.tck.database", db);
-  alreadyran = false;
-
-  for (String idtype : idtypes) {
-List idPropsString = new ArrayList<>();
-idPropsString.addAll(propsString);
-idPropsString.add("-Djdo.tck.identitytype=" + idtype);
-String enhancedDirName =
-buildDirectory
-+ File.separator
-+ "enhanced"
-+ File.separator
-+ impl
-+ File.separator
-+ idtype
-+ File.separator;
-File enhancedDir = new File(enhancedDirName);
-if (!(enhancedDir.exists())) {
-  throw new MojoExecutionException(
-  "Could not find enhanced directory "
-  + enhancedDirName
-  + ". Execute Enhance goal before RunTCK.");
-}
-
-// Set classpath string: add new entries to URLS from loader
-ArrayList cpList = new ArrayList<>();
-cpList.addAll(urlList);
-try {
-  URL url1 = enhancedDir.toURI().toURL();
-  URL url2 =
-  new File(buildDirectory + File.separator + CLASSES_DIR_NAME + 
File.separator)
-  .toURI()
-  .toURL();
-  if (runtckVerbose) {
-System.out.println("url2 is " + url2.toString());
-  }
-  cpList.add(url1);
-  cpList.add(url2);
-  String[] jars = {"jar"};
-  Iterator fi = FileUtils.iterateFiles(new 
File(extLibsDirectory), jars, true);
-  while (fi.hasNext()) {
-cpList.add(fi.next().toURI().toURL());
-  }
-  for (String dependency : 
this.dependencyClasspath.split(File.pathSeparator)) {
-cpList.add(new File(dependency).toURI().toURL());
-  }
-} catch (MalformedURLException ex) {
-  ex.printStackTrace();
-  Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
-}
-cpString = Utilities.urls2ClasspathString(cpList);
-if (runtckVerbose) {
-  System.out.println("\nClasspath is " + cpString);
-}
-
-for (String cfg : cfgs) {
-  List cfgPropsString = new ArrayList<>();
-  cfgPropsString.addAll(idPropsString);
-  // Parse conf file and set properties String
-  props = PropertyUtils.getProperties(confDirectory + File.separator + 
cfg);
-  cfgPropsString.add(
-  "-Djdo.tck.testdata="

[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-08 Thread via GitHub


mboapache commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1387172217


##
exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java:
##
@@ -263,231 +396,261 @@ public void execute() throws MojoExecutionException, 
MojoFailureException {
 } catch (IOException ex) {
   Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
 }
+  }
 
-// Get ClassLoader URLs to build classpath below
-URL[] cpURLs = ((URLClassLoader) 
Thread.currentThread().getContextClassLoader()).getURLs();
-ArrayList urlList = new ArrayList<>(Arrays.asList(cpURLs));
-
-// Get contents of pmf properties file to build new file below
-String pmfPropsReadFileName = confDirectory + File.separator + 
pmfProperties;
-String defaultPropsContents = "";
+  /**
+   * Get classpath string: add new entries to URLS from loader
+   *
+   * @param urlList ClassLoader URLs
+   * @param enhancedDir
+   * @return
+   */
+  private String getClasspathString(List urlList, File enhancedDir) {
+String cpString;
+ArrayList cpList = new ArrayList<>();
+cpList.addAll(urlList);
 try {
-  defaultPropsContents = Utilities.readFile(pmfPropsReadFileName);
-} catch (IOException ex) {
+  URL url1 = enhancedDir.toURI().toURL();
+  URL url2 =
+  new File(buildDirectory + File.separator + CLASSES_DIR_NAME + 
File.separator)
+  .toURI()
+  .toURL();
+  if (runtckVerbose) {
+System.out.println("url2 is " + url2.toString());
+  }
+  cpList.add(url1);
+  cpList.add(url2);
+  String[] jars = {"jar"};
+  Iterator fi = FileUtils.iterateFiles(new File(extLibsDirectory), 
jars, true);
+  while (fi.hasNext()) {
+cpList.add(fi.next().toURI().toURL());
+  }
+  for (String dependency : 
this.dependencyClasspath.split(File.pathSeparator)) {
+cpList.add(new File(dependency).toURI().toURL());
+  }
+} catch (MalformedURLException ex) {
+  ex.printStackTrace();
   Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
 }
+cpString = Utilities.urls2ClasspathString(cpList);
+if (runtckVerbose) {
+  System.out.println("\nClasspath is " + cpString);
+}
+return cpString;
+  }
 
-// Reset logfile content (may not be empty if previous run crashed)
-resetFileContent(implLogFile);
-resetFileContent(TCK_LOG_FILE);
-
-int failureCount = 0;
-for (String db : dbs) {
-  System.setProperty("jdo.tck.database", db);
-  alreadyran = false;
-
-  for (String idtype : idtypes) {
-List idPropsString = new ArrayList<>();
-idPropsString.addAll(propsString);
-idPropsString.add("-Djdo.tck.identitytype=" + idtype);
-String enhancedDirName =
-buildDirectory
-+ File.separator
-+ "enhanced"
-+ File.separator
-+ impl
-+ File.separator
-+ idtype
-+ File.separator;
-File enhancedDir = new File(enhancedDirName);
-if (!(enhancedDir.exists())) {
-  throw new MojoExecutionException(
-  "Could not find enhanced directory "
-  + enhancedDirName
-  + ". Execute Enhance goal before RunTCK.");
-}
-
-// Set classpath string: add new entries to URLS from loader
-ArrayList cpList = new ArrayList<>();
-cpList.addAll(urlList);
-try {
-  URL url1 = enhancedDir.toURI().toURL();
-  URL url2 =
-  new File(buildDirectory + File.separator + CLASSES_DIR_NAME + 
File.separator)
-  .toURI()
-  .toURL();
-  if (runtckVerbose) {
-System.out.println("url2 is " + url2.toString());
-  }
-  cpList.add(url1);
-  cpList.add(url2);
-  String[] jars = {"jar"};
-  Iterator fi = FileUtils.iterateFiles(new 
File(extLibsDirectory), jars, true);
-  while (fi.hasNext()) {
-cpList.add(fi.next().toURI().toURL());
-  }
-  for (String dependency : 
this.dependencyClasspath.split(File.pathSeparator)) {
-cpList.add(new File(dependency).toURI().toURL());
-  }
-} catch (MalformedURLException ex) {
-  ex.printStackTrace();
-  Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
-}
-cpString = Utilities.urls2ClasspathString(cpList);
-if (runtckVerbose) {
-  System.out.println("\nClasspath is " + cpString);
-}
-
-for (String cfg : cfgs) {
-  List cfgPropsString = new ArrayList<>();
-  cfgPropsString.addAll(idPropsString);
-  // Parse conf file and set properties String
-  props = PropertyUtils.getProperties(confDirectory + File.separator + 
cfg);
-  cfgPropsString.add(
-  "-Djdo.tck.testdata="

[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-08 Thread via GitHub


mboapache commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1387168344


##
exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java:
##
@@ -140,37 +141,178 @@ private String getTrimmedPropertyValue(Properties props, 
String key) {
 return value == null ? "" : value.trim();
   }
 
+  private static String fileToString(String fileName) {
+try {
+  byte[] encoded = Files.readAllBytes(Paths.get(fileName));
+  return new String(encoded);
+} catch (IOException ex) {
+  return "Problems reading " + fileName + ": " + ex.getMessage();
+}
+  }
+
+  /** */
   @Override
-  public void execute() throws MojoExecutionException, MojoFailureException {
+  public void execute() throws MojoExecutionException {
 if (!doRunTCK) {
   System.out.println("Skipping RunTCK goal!");
   return;
 }
 
-Properties props = null;
 boolean alreadyran = false;
-String runonce = "false";
-List propsString = new ArrayList<>();
-List command;
+boolean runonce = false;
 String cpString = null;
-InvocationResult result;
-File fromFile = null;
-File toFile = null;
 
+List propsString = initTCKRun();
+String excludeFile = confDirectory + File.separator + exclude;
+propsString.add(
+"-Djdo.tck.exclude="
++ 
getTrimmedPropertyValue(PropertyUtils.getProperties(excludeFile), 
"jdo.tck.exclude"));
+
+// Create configuration log directory
+String thisLogDir = logsDirectory + File.separator + Utilities.now();
+String cfgDirName = thisLogDir + File.separator + "configuration";
+File cfgDir = new File(cfgDirName);
+if (!(cfgDir.exists()) && !(cfgDir.mkdirs())) {
+  throw new MojoExecutionException("Failed to create directory " + 
cfgDirName);
+}
+propsString.add("-Djdo.tck.log.directory=" + thisLogDir);
+
+copyConfigurationFiles();
+
+// Get ClassLoader URLs to build classpath below
+List urlList =
+new ArrayList<>(
+Arrays.asList(
+((URLClassLoader) 
Thread.currentThread().getContextClassLoader()).getURLs()));
+
+// Get contents of pmf properties file to build new file below
+String pmfPropsReadFileName = confDirectory + File.separator + 
pmfProperties;
+String defaultPropsContents = "";
+try {
+  defaultPropsContents = Utilities.readFile(pmfPropsReadFileName);
+} catch (IOException ex) {
+  Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
+}
+
+// Reset logfile content (may not be empty if previous run crashed)
+resetFileContent(implLogFile);
+resetFileContent(TCK_LOG_FILE);
+
+int failureCount = 0;
+for (String db : dbs) {
+  System.setProperty("jdo.tck.database", db);
+  alreadyran = false;

Review Comment:
   I renamed it to alreadyRan



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jdo-dev-unsubscr...@db.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GH] JDO-830: Migrate JUnit tests in tck to version 5 (db-jdo)

2023-11-06 Thread via GitHub


tzaeschke commented on code in PR #85:
URL: https://github.com/apache/db-jdo/pull/85#discussion_r1383891081


##
exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java:
##
@@ -140,37 +141,178 @@ private String getTrimmedPropertyValue(Properties props, 
String key) {
 return value == null ? "" : value.trim();
   }
 
+  private static String fileToString(String fileName) {
+try {
+  byte[] encoded = Files.readAllBytes(Paths.get(fileName));
+  return new String(encoded);
+} catch (IOException ex) {
+  return "Problems reading " + fileName + ": " + ex.getMessage();
+}
+  }
+
+  /** */
   @Override
-  public void execute() throws MojoExecutionException, MojoFailureException {
+  public void execute() throws MojoExecutionException {
 if (!doRunTCK) {
   System.out.println("Skipping RunTCK goal!");
   return;
 }
 
-Properties props = null;
 boolean alreadyran = false;
-String runonce = "false";
-List propsString = new ArrayList<>();
-List command;
+boolean runonce = false;
 String cpString = null;
-InvocationResult result;
-File fromFile = null;
-File toFile = null;
 
+List propsString = initTCKRun();
+String excludeFile = confDirectory + File.separator + exclude;
+propsString.add(
+"-Djdo.tck.exclude="
++ 
getTrimmedPropertyValue(PropertyUtils.getProperties(excludeFile), 
"jdo.tck.exclude"));
+
+// Create configuration log directory
+String thisLogDir = logsDirectory + File.separator + Utilities.now();

Review Comment:
   Why `this`?



##
exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java:
##
@@ -116,17 +117,17 @@ public class RunTCK extends AbstractTCKMojo {
 
   /** Class used to run a batch of tests. */
   @Parameter(
-  property = "jdo.tck.testrunnerclass",
-  defaultValue = "org.apache.jdo.tck.util.BatchTestRunner",
+  property = "jdo.tck.testrunner.class",
+  defaultValue = "org.junit.platform.console.ConsoleLauncher",
   required = true)
   private String testRunnerClass;
 
-  /** Class used to output test result and configuration information. */
-  @Parameter(
-  property = "jdo.tck.resultprinterclass",
-  defaultValue = "org.apache.jdo.tck.util.BatchResultPrinter",
-  required = true)
-  private String resultPrinterClass;
+  /**
+   * output details mode for test run. Use one of: none, summary, flat, tree, 
verbose, testfeed. If

Review Comment:
   Is this sentence complete? Maybe change to "Output mode for test run ..."



##
exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java:
##
@@ -140,37 +141,178 @@ private String getTrimmedPropertyValue(Properties props, 
String key) {
 return value == null ? "" : value.trim();
   }
 
+  private static String fileToString(String fileName) {
+try {
+  byte[] encoded = Files.readAllBytes(Paths.get(fileName));
+  return new String(encoded);
+} catch (IOException ex) {
+  return "Problems reading " + fileName + ": " + ex.getMessage();
+}
+  }
+
+  /** */
   @Override
-  public void execute() throws MojoExecutionException, MojoFailureException {
+  public void execute() throws MojoExecutionException {
 if (!doRunTCK) {
   System.out.println("Skipping RunTCK goal!");
   return;
 }
 
-Properties props = null;
 boolean alreadyran = false;
-String runonce = "false";
-List propsString = new ArrayList<>();
-List command;
+boolean runonce = false;
 String cpString = null;
-InvocationResult result;
-File fromFile = null;
-File toFile = null;
 
+List propsString = initTCKRun();
+String excludeFile = confDirectory + File.separator + exclude;
+propsString.add(
+"-Djdo.tck.exclude="
++ 
getTrimmedPropertyValue(PropertyUtils.getProperties(excludeFile), 
"jdo.tck.exclude"));
+
+// Create configuration log directory
+String thisLogDir = logsDirectory + File.separator + Utilities.now();
+String cfgDirName = thisLogDir + File.separator + "configuration";
+File cfgDir = new File(cfgDirName);
+if (!(cfgDir.exists()) && !(cfgDir.mkdirs())) {
+  throw new MojoExecutionException("Failed to create directory " + 
cfgDirName);
+}
+propsString.add("-Djdo.tck.log.directory=" + thisLogDir);
+
+copyConfigurationFiles();
+
+// Get ClassLoader URLs to build classpath below
+List urlList =
+new ArrayList<>(
+Arrays.asList(
+((URLClassLoader) 
Thread.currentThread().getContextClassLoader()).getURLs()));
+
+// Get contents of pmf properties file to build new file below
+String pmfPropsReadFileName = confDirectory + File.separator + 
pmfProperties;
+String defaultPropsContents = "";
+try {
+  defaultPropsContents = Utilities.readFile(pmfPropsReadFileName);
+} catch (IOException ex) {
+  Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
+}
+
+