test/org/openjdk/jigsaw/cli/JpkgArgsTest.java

Print this page

        

@@ -118,10 +118,15 @@
     }
 
     private void testIfFileArgIsNotReadable(boolean natlib,
                                             boolean natcmd, boolean config)
         throws Exception {
+        // File readability cannot be set to false in Windows
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            return;
+        }
+
         setUp("NPE if file argument is not readable: "
               + (natlib? " --natlib " : "")
               + (natcmd? " --natcmd " : "")
               + (config? " --config" : ""));
 

@@ -168,11 +173,11 @@
 
     private void testIfModulePathArgIsNotADirectory()
         throws Exception {
         setUp("Check if module path argument is not a directory");
 
-        File aFile = new File("tmp", "aFile");
+        File aFile = new File(testDir, "aFile");
         aFile.createNewFile();
         try {
             String [] args = {"-m", aFile.toString(), "jmod", "hello"};
             Packager.run(args);
         }

@@ -215,16 +220,19 @@
         throw new Exception("Should have caught an exception");
     }
 
     private void testIfModulePathArgIsNotReadable()
         throws Exception {
+        // File readability cannot be set to false in Windows
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            return;
+        }
         setUp("Check if module path argument is not readable");
 
-        File dir = new File("tmp", "notReadableDir");
+        File dir = new File(testDir, "notReadableDir");
         if (! (dir.mkdir() && dir.setReadable(false)))
             throw new Exception("Can't set up test");
-
         try {
             String [] args = {"-m", dir.toString(), "jmod", "hello"};
             Packager.run(args);
         }
         // The bug resulted in a NPE being thrown

@@ -418,13 +426,13 @@
         errors++;
     }
 
     private int count;
     private int errors;
-    // use "tmp" to help avoid accidents
-    private File srcDir = new File("tmp", "src");
-    private File classesDir = new File("tmp", "classes");
-    private File moduleDir = new File("tmp", "modules");
+    private File testDir = new File(System.getProperty("test.dir", "tmp"));
+    private File srcDir = new File(testDir, "src");
+    private File classesDir = new File(testDir, "classes");
+    private File moduleDir = new File(testDir, "modules");
     private File natlibDir = new File(srcDir, "natlib");
     private File natcmdDir = new File(srcDir, "natcmd");
     private File configDir = new File(srcDir, "config");
 }