http-client-branch: create temp test files in current working directory http-client-branch
authorchegar
Wed, 14 Mar 2018 09:01:15 +0000
branchhttp-client-branch
changeset 56300 13a2ec671e62
parent 56299 903ff8ec239d
child 56303 a82058c084ef
http-client-branch: create temp test files in current working directory
test/jdk/java/net/httpclient/HttpEchoHandler.java
test/jdk/java/net/httpclient/SmokeTest.java
test/jdk/java/net/httpclient/http2/server/EchoHandler.java
test/jdk/java/net/httpclient/http2/server/Http2EchoHandler.java
test/jdk/java/net/httpclient/http2/server/TestUtil.java
test/jdk/java/net/httpclient/security/Driver.java
--- a/test/jdk/java/net/httpclient/HttpEchoHandler.java	Tue Mar 13 20:17:12 2018 +0000
+++ b/test/jdk/java/net/httpclient/HttpEchoHandler.java	Wed Mar 14 09:01:15 2018 +0000
@@ -40,6 +40,8 @@
 import java.util.logging.Logger;
 
 public class HttpEchoHandler implements HttpHandler {
+    static final Path CWD = Paths.get(".");
+
     public HttpEchoHandler() {}
 
     @Override
@@ -53,7 +55,7 @@
             map1.add("X-Hello", "world");
             map1.add("X-Bye", "universe");
             String fixedrequest = map.getFirst("XFixed");
-            File outfile = File.createTempFile("foo", "bar");
+            File outfile = Files.createTempFile(CWD, "foo", "bar").toFile();
             FileOutputStream fos = new FileOutputStream(outfile);
             int count = (int) is.transferTo(fos);
             is.close();
--- a/test/jdk/java/net/httpclient/SmokeTest.java	Tue Mar 13 20:17:12 2018 +0000
+++ b/test/jdk/java/net/httpclient/SmokeTest.java	Wed Mar 14 09:01:15 2018 +0000
@@ -886,8 +886,10 @@
         }
     }
 
+    static final Path CWD = Paths.get(".");
+
     static Path getTempFile(int size) throws IOException {
-        File f = File.createTempFile("test", "txt");
+        File f = Files.createTempFile(CWD, "test", "txt").toFile();
         f.deleteOnExit();
         byte[] buf = new byte[2048];
         for (int i = 0; i < buf.length; i++)
--- a/test/jdk/java/net/httpclient/http2/server/EchoHandler.java	Tue Mar 13 20:17:12 2018 +0000
+++ b/test/jdk/java/net/httpclient/http2/server/EchoHandler.java	Wed Mar 14 09:01:15 2018 +0000
@@ -22,9 +22,15 @@
  */
 
 import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 import jdk.internal.net.http.common.HttpHeadersImpl;
 
 public class EchoHandler implements Http2Handler {
+    static final Path CWD = Paths.get(".");
+
     public EchoHandler() {}
 
     @Override
@@ -38,7 +44,7 @@
             map1.addHeader("X-Hello", "world");
             map1.addHeader("X-Bye", "universe");
             String fixedrequest = map.firstValue("XFixed").orElse(null);
-            File outfile = File.createTempFile("foo", "bar");
+            File outfile = Files.createTempFile(CWD, "foo", "bar").toFile();
             //System.err.println ("QQQ = " + outfile.toString());
             FileOutputStream fos = new FileOutputStream(outfile);
             int count = (int) is.transferTo(fos);
--- a/test/jdk/java/net/httpclient/http2/server/Http2EchoHandler.java	Tue Mar 13 20:17:12 2018 +0000
+++ b/test/jdk/java/net/httpclient/http2/server/Http2EchoHandler.java	Wed Mar 14 09:01:15 2018 +0000
@@ -22,9 +22,15 @@
  */
 
 import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 import jdk.internal.net.http.common.HttpHeadersImpl;
 
 public class Http2EchoHandler implements Http2Handler {
+    static final Path CWD = Paths.get(".");
+
     public Http2EchoHandler() {}
 
     @Override
@@ -39,7 +45,7 @@
             map1.addHeader("X-Hello", "world");
             map1.addHeader("X-Bye", "universe");
             String fixedrequest = map.firstValue("XFixed").orElse(null);
-            File outfile = File.createTempFile("foo", "bar");
+            File outfile = Files.createTempFile(CWD, "foo", "bar").toFile();
             //System.err.println ("QQQ = " + outfile.toString());
             FileOutputStream fos = new FileOutputStream(outfile);
             int count = (int) is.transferTo(fos);
--- a/test/jdk/java/net/httpclient/http2/server/TestUtil.java	Tue Mar 13 20:17:12 2018 +0000
+++ b/test/jdk/java/net/httpclient/http2/server/TestUtil.java	Wed Mar 14 09:01:15 2018 +0000
@@ -27,6 +27,7 @@
 
 public class TestUtil {
 
+    static final Path CWD = Paths.get(".");
     final static String fileContent = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // repeated
 
     public static Path getAFile(int size) throws IOException {
@@ -44,7 +45,7 @@
 
     public static Path tempFile() {
         try {
-            Path p = Files.createTempFile("foo", "test");
+            Path p = Files.createTempFile(CWD, "TestUtil_tmp_", "_HTTPClient");
             return p;
         } catch (IOException e) {
             throw new UncheckedIOException(e);
--- a/test/jdk/java/net/httpclient/security/Driver.java	Tue Mar 13 20:17:12 2018 +0000
+++ b/test/jdk/java/net/httpclient/security/Driver.java	Wed Mar 14 09:01:15 2018 +0000
@@ -49,6 +49,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -70,16 +73,18 @@
         System.out.println("DONE");
     }
 
+    static final Path CWD = Paths.get(".");
+
     static class Logger extends Thread {
         private final OutputStream ps;
         private final InputStream stdout;
 
-        Logger(String cmdLine, Process p, String dir) throws IOException {
+        Logger(String cmdLine, Process p) throws IOException {
             super();
             setDaemon(true);
             cmdLine = "Command line = [" + cmdLine + "]\n";
             stdout = p.getInputStream();
-            File f = File.createTempFile("debug", ".txt", new File(dir));
+            File f = Files.createTempFile(CWD, "debug", ".txt").toFile();
             ps = new FileOutputStream(f);
             ps.write(cmdLine.getBytes());
             ps.flush();
@@ -143,7 +148,7 @@
             String cmdLine = cmd.stream().collect(Collectors.joining(" "));
             long start = System.currentTimeMillis();
             Process child = processBuilder.start();
-            Logger log = new Logger(cmdLine, child, testClasses);
+            Logger log = new Logger(cmdLine, child);
             log.start();
             retval = child.waitFor();
             long elapsed = System.currentTimeMillis() - start;