diff --git a/src/test/JDJSTPTestcase.java b/src/test/JDJSTPTestcase.java index 5f8a7e7..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) { @@ -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; @@ -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('/'); @@ -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(); } @@ -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; @@ -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('/');