Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>JTOpen-test</groupId>
<artifactId>JTOpen-test</artifactId>
<packaging>jar</packaging>
<version>1.0.9</version>
<version>1.0.10</version>
<name>JTOpen-test</name>
<description>Testcases for JTOpen</description>
<build>
Expand Down
2 changes: 1 addition & 1 deletion pomWar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>JTOpen-test</groupId>
<artifactId>JTOpen-test</artifactId>
<packaging>war</packaging>
<version>1.0.9</version>
<version>1.0.10</version>
<name>JTOpen-test-war</name>
<description>Testcases for JTOpen</description>
<build>
Expand Down
10 changes: 7 additions & 3 deletions src/test/JCIFSUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");

}

Expand Down
47 changes: 43 additions & 4 deletions src/test/JDJSTPTestcase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Loading