Skip to content
Merged
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
14 changes: 8 additions & 6 deletions src/test/JDJSTPTestcase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -2649,7 +2651,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;
Expand All @@ -2658,9 +2660,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('/');
Expand All @@ -2673,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();
}
Expand All @@ -2698,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;
Expand All @@ -2707,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('/');
Expand Down
Loading