changeset 16950:383a04a71b36

8177640: jdk/internal/util/jar/TestVersionedStream.java fails on Windows Reviewed-by: psandoz
author amlu
date Thu, 06 Apr 2017 09:33:47 +0800
parents cda91600a4bd
children fff71e4478c3
files test/ProblemList.txt test/jdk/internal/util/jar/TestVersionedStream.java
diffstat 2 files changed, 13 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/test/ProblemList.txt	Wed Apr 05 10:55:31 2017 -0700
+++ b/test/ProblemList.txt	Thu Apr 06 09:33:47 2017 +0800
@@ -284,8 +284,6 @@
 
 java/util/BitSet/BitSetStreamTest.java                          8079538 generic-all
 
-jdk/internal/util/jar/TestVersionedStream.java                  8177640 windows-all
-
 ############################################################################
 
 # jdk_instrument
--- a/test/jdk/internal/util/jar/TestVersionedStream.java	Wed Apr 05 10:55:31 2017 -0700
+++ b/test/jdk/internal/util/jar/TestVersionedStream.java	Thu Apr 06 09:33:47 2017 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UncheckedIOException;
-import java.net.URI;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -168,23 +167,23 @@
 
             // verify the contents
             Map<String,String> contents = new HashMap<>();
-            contents.put("p/Bar.class", "base/p/Bar.class\n");
-            contents.put("p/Main.class", "base/p/Main.class\n");
+            contents.put("p/Bar.class", "base/p/Bar.class");
+            contents.put("p/Main.class", "base/p/Main.class");
             switch (version.major()) {
                 case 8:
-                    contents.put("p/Foo.class", "base/p/Foo.class\n");
+                    contents.put("p/Foo.class", "base/p/Foo.class");
                     break;
                 case 9:
-                    contents.put("p/Foo.class", "v9/p/Foo.class\n");
+                    contents.put("p/Foo.class", "v9/p/Foo.class");
                     break;
                 case 10:
-                    contents.put("p/Foo.class", "v10/p/Foo.class\n");
-                    contents.put("q/Bar.class", "v10/q/Bar.class\n");
+                    contents.put("p/Foo.class", "v10/p/Foo.class");
+                    contents.put("q/Bar.class", "v10/q/Bar.class");
                     break;
                 case 11:
-                    contents.put("p/Bar.class", "v11/p/Bar.class\n");
-                    contents.put("p/Foo.class", "v11/p/Foo.class\n");
-                    contents.put("q/Bar.class", "v10/q/Bar.class\n");
+                    contents.put("p/Bar.class", "v11/p/Bar.class");
+                    contents.put("p/Foo.class", "v11/p/Foo.class");
+                    contents.put("q/Bar.class", "v10/q/Bar.class");
                     break;
                 default:
                     Assert.fail("Test out of date, please add more cases");
@@ -196,7 +195,7 @@
                 Assert.assertTrue(i != -1, name + " not in enames");
                 JarEntry je = versionedEntries.get(i);
                 try (InputStream is = jf.getInputStream(je)) {
-                    String s = new String(is.readAllBytes());
+                    String s = new String(is.readAllBytes()).replaceAll(System.lineSeparator(), "");
                     Assert.assertTrue(s.endsWith(e.getValue()), s);
                 } catch (IOException x) {
                     throw new UncheckedIOException(x);
@@ -208,16 +207,13 @@
     private void createFiles(String... files) {
         ArrayList<String> list = new ArrayList();
         Arrays.stream(files)
-                .map(f -> "file:///" + userdir + "/" + f)
-                .map(f -> URI.create(f))
-                .filter(u -> u != null)
-                .map(u -> Paths.get(u))
+                .map(f -> Paths.get(userdir.toAbsolutePath().toString(), f))
                 .forEach(p -> {
                     try {
                         Files.createDirectories(p.getParent());
                         Files.createFile(p);
                         list.clear();
-                        list.add(p.toString());
+                        list.add(p.toString().replace(File.separatorChar, '/'));
                         Files.write(p, list);
                     } catch (IOException x) {
                         throw new UncheckedIOException(x);