diff --git a/pom.xml b/pom.xml
index 944721b..c0c4c87 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
JTOpen-test
JTOpen-test
jar
- 1.0.9
+ 1.0.10
JTOpen-test
Testcases for JTOpen
diff --git a/pomWar.xml b/pomWar.xml
index 24ddd52..db2ab45 100644
--- a/pomWar.xml
+++ b/pomWar.xml
@@ -5,7 +5,7 @@
JTOpen-test
JTOpen-test
war
- 1.0.9
+ 1.0.10
JTOpen-test-war
Testcases for JTOpen
diff --git a/src/test/JCIFSUtility.java b/src/test/JCIFSUtility.java
index 58da8d7..82d73f2 100644
--- a/src/test/JCIFSUtility.java
+++ b/src/test/JCIFSUtility.java
@@ -42,6 +42,9 @@
import java.util.Enumeration;
import java.util.Hashtable;
+// import org.codelibs.jcifs.smb.Config;
+// import org.codelibs.jcifs.smb.context.SingletonContext;
+
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400JDBCDriver;
import com.ibm.as400.access.ISeriesNetServer;
@@ -66,9 +69,10 @@ public class JCIFSUtility {
// Turn on extended security.
// SingletonContext config = org.codelibs.jcifs.smb.context.SingletonContext.getInstance();
- // config.setProperty("jcifs.util.loglevel", "3");
- // jcifs.Config.setProperty("jcifs.smb.client.useExtendedSecurity", "false");
- // jcifs.Config.setProperty("jcifs.smb.lmCompatibility", "0");
+ // config.set("jcifs.util.loglevel", "3");
+ // Config
+ // Config.setProperty("jcifs.smb.client.useExtendedSecurity", "false");
+ // Config.setProperty("jcifs.smb.lmCompatibility", "0");
}
diff --git a/src/test/JDJSTPTestcase.java b/src/test/JDJSTPTestcase.java
index 47a436b..2cb769c 100644
--- a/src/test/JDJSTPTestcase.java
+++ b/src/test/JDJSTPTestcase.java
@@ -30,7 +30,13 @@
import java.io.StringBufferInputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
-
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -2639,14 +2645,47 @@ public static boolean updateServerFile(String localFile, String serverPf, String
checkSetup();
+ //
+ // 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);
+ File file = new File(localFile);
+ long currentTime = file.lastModified();
+ long lastJarModifiedMs = 0;
+ if (url != null) {
+ // If url indicates a jar file, when we will copy to local filesystem
+ if (url.getProtocol().equals("jar")) {
+ URLConnection connection = url.openConnection();
+ lastJarModifiedMs = connection.getLastModified();
+ }
+ } else {
+ System.out.println("Resource not found.");
+ }
+ if (lastJarModifiedMs > currentTime) {
+ int lastSlashIndex = localFile.lastIndexOf('/');
+ if (lastSlashIndex > 0) {
+ String directory = localFile.substring(0,lastSlashIndex);
+ File directoryFile = new File(directory);
+ if (!directoryFile.exists()) {
+ directoryFile.mkdirs();
+ }
+ }
+
+ InputStream is = url.openStream();
+ FileSystem fsDefault = FileSystems.getDefault();
+ Files.copy(is, fsDefault.getPath(localFile), StandardCopyOption.REPLACE_EXISTING);
+ fsDefault.close();
+ is.close();
+ currentTime = file.lastModified();
+ }
+
//
// Determine if server file needs to be updated
//
- File file = new File(localFile);
- long currentTime = file.lastModified();
if (currentTime == 0L) {
- throw new Exception("File "+localFile+" not found");
+ throw new Exception("File "+localFile+" not found");
}
long lastTime = 0 ;
if (debug) System.out.println("JDJSTP.debug: updateServerFile: localFile="+localFile+" ts="+currentTime+" now="+System.currentTimeMillis());