From 92e488bc1eae845c672d4eedda5edf958cb7fb51 Mon Sep 17 00:00:00 2001 From: John Eberhard Date: Thu, 23 Jul 2026 06:58:41 -0500 Subject: [PATCH 1/4] Update load from jar file Signed-off-by: John Eberhard --- src/test/JDJSTPTestcase.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/JDJSTPTestcase.java b/src/test/JDJSTPTestcase.java index 5f8a7e7..50bac2b 100644 --- a/src/test/JDJSTPTestcase.java +++ b/src/test/JDJSTPTestcase.java @@ -2649,7 +2649,7 @@ public static void refreshLocalFile(String localFile) throws Exception { // Determine if the local file needs to be extracted from the classpath // // Get the URL of the resource inside the JAR file - URL url = JDJSTPTestcase.class.getResource(localFile); + URL url = JDJSTPTestcase.class.getResource("/"+localFile); File file = new File(localFile); long currentTime = file.lastModified(); long lastJarModifiedMs = 0; @@ -2658,9 +2658,10 @@ public static void refreshLocalFile(String localFile) throws Exception { if (url.getProtocol().equals("jar")) { URLConnection connection = url.openConnection(); lastJarModifiedMs = connection.getLastModified(); + if (debug) System.out.println("Resource "+localFile+" found in jar."); } } else { - System.out.println("Resource not found."); + if (debug) System.out.println("Resource "+localFile+" not found in jar."); } if (lastJarModifiedMs > currentTime) { int lastSlashIndex = localFile.lastIndexOf('/'); From 461d7ee70a3157d8598025c2546cd5cb2f0cebbc Mon Sep 17 00:00:00 2001 From: John Eberhard Date: Thu, 23 Jul 2026 11:39:25 -0500 Subject: [PATCH 2/4] Fix extraction from Jar file Signed-off-by: John Eberhard --- src/test/JDJSTPTestcase.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/JDJSTPTestcase.java b/src/test/JDJSTPTestcase.java index 50bac2b..cef5c22 100644 --- a/src/test/JDJSTPTestcase.java +++ b/src/test/JDJSTPTestcase.java @@ -86,6 +86,8 @@ public class JDJSTPTestcase private static String HCLIConnect_ = null; private static String ZCLIConnect_ = null; private static String LCLIConnect_ = null; + @SuppressWarnings("resource") + static FileSystem fsDefault = FileSystems.getDefault(); public static String getGCLIConnect() { if (GCLIConnect_ == null) { @@ -2674,9 +2676,7 @@ public static void refreshLocalFile(String localFile) throws Exception { } InputStream is = url.openStream(); - FileSystem fsDefault = FileSystems.getDefault(); Files.copy(is, fsDefault.getPath(localFile), StandardCopyOption.REPLACE_EXISTING); - fsDefault.close(); is.close(); currentTime = file.lastModified(); } @@ -2699,7 +2699,7 @@ public static boolean updateServerFile(String localFile, String serverPf, String // Determine if the local file needs to be extracted from the classpath // // Get the URL of the resource inside the JAR file - URL url = JDJSTPTestcase.class.getResource(localFile); + URL url = JDJSTPTestcase.class.getResource("/"+localFile); File file = new File(localFile); long currentTime = file.lastModified(); long lastJarModifiedMs = 0; @@ -2708,9 +2708,10 @@ public static boolean updateServerFile(String localFile, String serverPf, String if (url.getProtocol().equals("jar")) { URLConnection connection = url.openConnection(); lastJarModifiedMs = connection.getLastModified(); + if (debug) System.out.println("Resource "+localFile+" copied from jar file."); } } else { - System.out.println("Resource not found."); + if (debug) System.out.println("Resource "+localFile+" not found."); } if (lastJarModifiedMs > currentTime) { int lastSlashIndex = localFile.lastIndexOf('/'); From f9504abafb7e916aa762b37f6872f459b69457b7 Mon Sep 17 00:00:00 2001 From: John Eberhard Date: Thu, 23 Jul 2026 13:54:19 -0500 Subject: [PATCH 3/4] Fix JDJSTPTestcase getExpectedOutput. Added debug message for data area locking. Signed-off-by: John Eberhard --- src/test/JD/JDDataAreaLock.java | 11 ++++++++-- src/test/JDJSTPTestcase.java | 38 +++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/test/JD/JDDataAreaLock.java b/src/test/JD/JDDataAreaLock.java index c4286b3..8afefd9 100644 --- a/src/test/JD/JDDataAreaLock.java +++ b/src/test/JD/JDDataAreaLock.java @@ -49,8 +49,6 @@ public JDDataAreaLock(Statement s, String library, String dataArea) throws SQLEx public void lock(String comment, int waitTime) throws SQLException { - - String sql="CALL QSYS2.QCMDEXC(' CRTDTAARA DTAARA("+library_+"/"+dataArea_+") TYPE(*CHAR) LEN(2000)')"; try { s_.execute(sql); @@ -68,8 +66,13 @@ public void lock(String comment, int waitTime) throws SQLException { } // Lock exclusive on the system and delay one second try { + sql="CALL SYSTOOLS.LPRINTF('ALLOCATING ("+library_+"/"+dataArea_+" *DTAARA *EXCLRD)')"; + s_.execute(sql); sql="CALL QSYS2.QCMDEXC(' ALCOBJ OBJ(("+library_+"/"+dataArea_+" *DTAARA *EXCLRD)) WAIT("+waitTime+") ')"; s_.execute(sql); + sql="CALL SYSTOOLS.LPRINTF('ALLOCATED ("+library_+"/"+dataArea_+" *DTAARA *EXCLRD)')"; + s_.execute(sql); + // Look at the data area to make sure it isn't already locked sql="select JOB_NAME, TRIM(INTERPRET(REPLACE(BINARY(DATA_AREA_VALUE),BX'00',BX'40') AS CHAR(2000) CCSID 37)) " + "from qsys2.data_area_info where DATA_AREA_LIBRARY='" + library_ @@ -145,6 +148,9 @@ public void unlock(String comment, Timestamp ts) throws SQLException { String sql="NOTSET"; try { + sql="CALL SYSTOOLS.LPRINTF('UNLOCKING ("+library_+"/"+dataArea_+" *DTAARA *EXCLRD)')"; + s_.execute(sql); + if (ts == null) ts = new Timestamp(System.currentTimeMillis()); String callerString = getCallString(); @@ -155,6 +161,7 @@ public void unlock(String comment, Timestamp ts) throws SQLException { sql = "CALL QSYS2.QCMDEXC(' DLCOBJ OBJ((" + library_ + "/" + dataArea_ + " *DTAARA *EXCLRD)) ')"; s_.execute(sql); + sql="CALL SYSTOOLS.LPRINTF('UNLOCKED ("+library_+"/"+dataArea_+" *DTAARA *EXCLRD)')"; } catch (SQLException e) { System.out.println("Error on " + sql); diff --git a/src/test/JDJSTPTestcase.java b/src/test/JDJSTPTestcase.java index cef5c22..fef36c4 100644 --- a/src/test/JDJSTPTestcase.java +++ b/src/test/JDJSTPTestcase.java @@ -5323,21 +5323,30 @@ public static String getJdkString(int jdk, int vrm1) throws Exception { throw new Exception("Unrecognized jdk"+jdk); } } + + + public static boolean resourceExists(String filename) { + File checkFile = new File(filename); + if (checkFile.exists()) { + return true; + } + URL url = JDJSTPTestcase.class.getResource("/"+filename); + if (url != null) return true; + return false; + } + public static String getExpectedOutputFile( String testbase, String inVariation, StringBuffer possibleOutputFiles) throws Exception { - - String expectedOutput; - File checkFile; String variationString="."+inVariation; if (inVariation.length() == 0) variationString = ""; expectedOutput = exppath + "/" + testbase + variationString + ".rxp" + vrm + ".jdkXX"; - checkFile = new File(expectedOutput); - if (!checkFile.exists()) { + + if (!resourceExists(expectedOutput)) { possibleOutputFiles.append(" " + expectedOutput); } @@ -5347,13 +5356,13 @@ public static String getExpectedOutputFile( int currentJdk = JVMInfo.getJDK(); - for (int i = 0; i < vrms.length && !checkFile.exists(); i++) { + for (int i = 0; i < vrms.length && !resourceExists(expectedOutput); i++) { if (vrm >= vrms[i]) { /* current vrm greater than loop vrm */ String vrmString = ""+vrms[i]; if (vrms[i] == 0) { vrmString=""; } - for (int j = 0; j < jdks.length && !checkFile.exists(); j++) { + for (int j = 0; j < jdks.length && !resourceExists(expectedOutput); j++) { if (currentJdk >= jdks[j]) { String jdkString = getJdkString(jdks[j], vrms[i]); /* * return .jdk @@ -5363,26 +5372,23 @@ public static String getExpectedOutputFile( // check for J9 expectedOutput = exppath + "/" + testbase + variationString + ".rxp" + vrmString + jdkString + ".j9"; - checkFile = new File(expectedOutput); - if (!checkFile.exists()) { + if (!resourceExists(expectedOutput)) { possibleOutputFiles.append(" " + expectedOutput); } - if (!checkFile.exists()) { + if (!resourceExists(expectedOutput)) { if (isToolbox) { // check for toolbox expectedOutput = exppath + "/" + testbase + variationString + ".rxpt" + vrmString + jdkString; - checkFile = new File(expectedOutput); - if (!checkFile.exists()) { + if (resourceExists(expectedOutput)) { possibleOutputFiles.append(" " + expectedOutput); } } - if (!checkFile.exists()) { + if (!resourceExists(expectedOutput)) { expectedOutput = exppath + "/" + testbase + variationString + ".rxp" + vrmString + jdkString; - checkFile = new File(expectedOutput); - if (!checkFile.exists()) { + if (!resourceExists(expectedOutput)) { /* Do not list old releases as possible output files */ if (vrmString.equals("610") || vrmString.equals("550") || vrmString.equals("540") @@ -5403,7 +5409,7 @@ public static String getExpectedOutputFile( } /* current vrm not less than loop vrm */ } /* for i -- vrms */ - if (!checkFile.exists()) { + if (!resourceExists(expectedOutput)) { System.out.println("Did not find file: Tried :"+possibleOutputFiles.toString()); } return expectedOutput; From 022100b1d485b307d7cc540bdfcc416a9ee757fe Mon Sep 17 00:00:00 2001 From: John Eberhard Date: Thu, 23 Jul 2026 14:20:09 -0500 Subject: [PATCH 4/4] Clarify testcaseHome and testcaseClasspath in JDRunit --- src/test/JDRunit.java | 51 ++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/src/test/JDRunit.java b/src/test/JDRunit.java index 99bc4a8..1727145 100644 --- a/src/test/JDRunit.java +++ b/src/test/JDRunit.java @@ -82,8 +82,8 @@ public class JDRunit { public static String JCIFS_JAR="jcifs-3.0.2.jar"; public static final String TMP = "/tmp"; - public static String testcaseCode = JTOpenTestEnvironment.testcaseHomeDirectory; - + public static String testcaseHome = JTOpenTestEnvironment.testcaseHomeDirectory; + public static String testcaseClasspath = testcaseHome+":"+testcaseHome+"/JTOpen-test.jar"; static Hashtable rdbToCreatedUserid = new Hashtable(); static Hashtable rdbToCreatedPassword = new Hashtable(); static boolean debug = false; @@ -216,10 +216,6 @@ public class JDRunit { on400open = JTOpenTestEnvironment.isOS400open; onLinux = JTOpenTestEnvironment.isLinux; - property = System.getProperty("useTestJar"); - if (property != null && (property.toUpperCase().indexOf('N')< 0)) { - testcaseCode = "JTOpen-test.jar"; - } } // @@ -976,7 +972,7 @@ public static void sendEMail(String toAddress, String fromAddress, String[] activationJarLocations = { userDir + sep + "jars" + sep + "activation.jar", "C:" + sep + "activation.jar", - testcaseCode+"/jars/activation.jar", + testcaseHome+"/jars/activation.jar", "/qibm/proddata/os400/java400/ext/activation.jar", "C:\\Documents and Settings\\Administrator\\workspace\\lib\\activation.jar", }; @@ -1002,7 +998,7 @@ public static void sendEMail(String toAddress, String fromAddress, String[] mailJarLocations = { userDir + sep + "jars" + sep + "mail.jar", "C:" + sep + "mail.jar", - testcaseCode+"/jars/mail.jar", + testcaseHome+"/jars/mail.jar", "/qibm/proddata/os400/java400/ext/mail.jar", "C:\\Documents and Settings\\Administrator\\workspace\\lib\\mail.jar", }; for (int i = 0; i < mailJarLocations.length && urls[1] == null; i++) { @@ -2128,13 +2124,13 @@ public void readIni(StringBuffer iniInfo) throws Exception { if (useJaCoCo) { if (toolboxJar.indexOf("java6") > 0) { - toolboxJar = testcaseCode+"/jacoco/java6/jt400.jar"; + toolboxJar = testcaseHome+"/jacoco/java6/jt400.jar"; } else if (toolboxJar.indexOf("java8") > 0) { - toolboxJar = testcaseCode+"/jacoco/java8/jt400.jar"; + toolboxJar = testcaseHome+"/jacoco/java8/jt400.jar"; } else if (toolboxJar.indexOf("java9") > 0) { - toolboxJar = testcaseCode+"/jacoco/java9/jt400.jar"; + toolboxJar = testcaseHome+"/jacoco/java9/jt400.jar"; } else { - toolboxJar = testcaseCode+"/jacoco/java0/jt400.jar"; + toolboxJar = testcaseHome+"/jacoco/java0/jt400.jar"; } } @@ -2270,7 +2266,8 @@ public JDRunitGoOutput go() throws Exception { if (JTOpenTestEnvironment.isWindows && (vmInitials.endsWith("3") || vmInitials.endsWith("6"))) { runNativeTestFromWindows = true; - testcaseCode="/home/jdbctest"; + testcaseHome="/home/jdbctest"; + testcaseClasspath="/home/jdbctest"; } @@ -2280,8 +2277,8 @@ public JDRunitGoOutput go() throws Exception { inputVector.addElement("echo input is " + runitInputFile); inputVector.addElement("echo output is " + runitOutputFile); inputVector.addElement(iniInfo.toString()); - inputVector.addElement("echo cd "+testcaseCode); - inputVector.addElement("cd "+testcaseCode); + inputVector.addElement("echo cd "+testcaseHome); + inputVector.addElement("cd "+testcaseHome); String javaExecPath = javaHome; // @@ -2326,18 +2323,18 @@ public JDRunitGoOutput go() throws Exception { String newTestJar = iniProperties.getProperty("testJar"); if (newTestJar != null) { - testcaseCode = newTestJar; + testcaseClasspath = newTestJar; } /* Use JTOpen-test.jar if exists in the classpath. */ /* Assume that the JTOpen-test.jar is in the current directory */ String currentClassPath=System.getProperty("java.class.path"); if (currentClassPath.indexOf("JTOpen-test.jar") >= 0) { - testcaseCode = "JTOpen-test.jar"; + testcaseClasspath = "JTOpen-test.jar"; } - String setClasspath = "CLASSPATH="+toolboxJar+":"+testcaseCode+":" + String setClasspath = "CLASSPATH="+toolboxJar+":"+testcaseClasspath+":" + ":/qibm/proddata/java400/ext/translator.zip:" + toolsJar + ":jars/googleauth-1.5.0.jar:jars/commons-codec-1.16.0.jar" @@ -2439,12 +2436,12 @@ public JDRunitGoOutput go() throws Exception { String currentClasspath = System.getProperty("java.class.path"); - if (testcaseCode.indexOf(".jar") < 0) { - testcaseCode=System.getProperty("user.dir"); + if (testcaseClasspath.indexOf(".jar") < 0) { + testcaseClasspath=System.getProperty("user.dir"); } else { - testcaseCode=System.getProperty("user.dir") +File.separator+testcaseCode; + testcaseClasspath=System.getProperty("user.dir") +File.separator+testcaseClasspath; } - setClasspath = "CLASSPATH=\"" + toolboxJar + ";" + testcaseCode+ ";" + setClasspath = "CLASSPATH=\"" + toolboxJar + ";" + testcaseClasspath+ ";" + currentClasspath+";" + toolsJar + ";" + System.getProperty("user.dir") + ""+File.separator+"jars"+File.separator+"db2_classes.jar;" + @@ -2475,7 +2472,7 @@ public JDRunitGoOutput go() throws Exception { } - setClasspath = "CLASSPATH=\""+testcaseCode+":" + toolboxJar + ":" + setClasspath = "CLASSPATH=\""+testcaseClasspath+":" + toolboxJar + ":" + toolsJar + ":" + System.getProperty("user.dir") + "/jars/fscontext.jar:" + System.getProperty("user.dir") + "/jars/providerutil.jar:" @@ -2742,11 +2739,11 @@ public JDRunitGoOutput go() throws Exception { + savefileName + " -Dtest.parentJob=" + parentJob + " " + javaArgs; if (useJaCoCo) { - File destDir = new File(testcaseCode+"/jacoco/"+initials); + File destDir = new File(testcaseHome+"/jacoco/"+initials); if (!destDir.exists()) { destDir.mkdir(); } - javaArgs = "-javaagent:"+testcaseCode+"/jacoco/lib/jacocoagent.jar=destfile="+testcaseCode+"/jacoco/"+initials+"/"+test+".exec,includes=com.ibm.as400.access.* " + javaArgs; + javaArgs = "-javaagent:"+testcaseHome+"/jacoco/lib/jacocoagent.jar=destfile="+testcaseHome+"/jacoco/"+initials+"/"+test+".exec,includes=com.ibm.as400.access.* " + javaArgs; } String javaCommand = "java " + javaArgs + " " + testArgs + " -lib " @@ -2967,7 +2964,7 @@ public JDRunitGoOutput go() throws Exception { // any environment variables. // This scenario should only typically happened on V6R1 if ((System.getProperty("java.home").indexOf("QOpenSys") > 0) && (javaHome.indexOf("QOpenSys") == -1)) { - String[] envp = { "PATH=/usr/bin:", "HOME=" + testcaseCode, }; + String[] envp = { "PATH=/usr/bin:", "HOME=" + testcaseHome, }; if (debug) System.out.println("Calling exec1 with envp and cmdArray[0]=" + cmdArray1[0]); shellTestProcess = runtime.exec(cmdArray1, envp); @@ -4288,7 +4285,7 @@ static void startProxyServer(String jt400jar) { try { - String command = "java -classpath "+testcaseCode+":"+jt400jar+" com.ibm.as400.access.ProxyServer"; + String command = "java -classpath "+testcaseClasspath+":"+jt400jar+" com.ibm.as400.access.ProxyServer"; System.out.println("JDRunit: starting ProxyServer on default port using: "+command); // Need to include testcaseCode because the source for the serialized // lobs is located there.