test/jdk/jdk/nio/zipfs/jarfs/JFSTester.java
author clanger
Fri, 22 Nov 2019 09:25:09 +0100
changeset 59216 47c879f478d2
parent 54630 04b17e84c87d
permissions -rw-r--r--
8234089: (zipfs) Remove classes JarFileSystemProvider and JarFileSystem Reviewed-by: lancea, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
     1
/*
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
     4
 *
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
     8
 *
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    13
 * accompanied this code).
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    14
 *
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    18
 *
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    21
 * questions.
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    22
 */
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    23
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    24
/*
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    25
 * @test
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    26
 * @bug 8164389 8222440
59216
47c879f478d2 8234089: (zipfs) Remove classes JarFileSystemProvider and JarFileSystem
clanger
parents: 54630
diff changeset
    27
 * @summary walk entries in a multi-release jar file via jdk.zipfs
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    28
 * @library /lib/testlibrary/java/util/jar
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    29
 * @modules jdk.jartool
40983
8f86bddfda46 8166126: Missing dependecies on jdk.zipfs module for jdk/nio/zipfs/jarfs/JFSTester.java
skovalev
parents: 40528
diff changeset
    30
 *          jdk.zipfs
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    31
 * @build Compiler JarBuilder
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    32
 * @run testng JFSTester
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    33
 */
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    34
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    35
import org.testng.Assert;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    36
import org.testng.annotations.BeforeClass;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    37
import org.testng.annotations.Test;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    38
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    39
import java.io.IOException;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    40
import java.io.UncheckedIOException;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    41
import java.net.URI;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    42
import java.nio.file.FileSystem;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    43
import java.nio.file.FileSystems;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    44
import java.nio.file.Files;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    45
import java.nio.file.Path;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    46
import java.nio.file.Paths;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    47
import java.util.HashMap;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    48
import java.util.Map;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    49
import java.util.Set;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    50
import java.util.stream.Collectors;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    51
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    52
public class JFSTester {
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    53
    private URI jarURI;
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    54
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    55
    final private String root_dir1_leaf1_txt = "This is leaf 1." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    56
    final private String root_dir1_leaf2_txt = "This is leaf 2." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    57
    final private String root_dir2_leaf3_txt = "This is leaf 3." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    58
    final private String root_dir2_leaf4_txt = "This is leaf 4." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    59
    final private String v9_root_dir2_leaf3_txt = "This is version 9 leaf 3." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    60
    final private String v9_root_dir2_leaf4_txt = "This is version 9 leaf 4." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    61
    final private String v9_root_dir3_leaf5_txt = "This is version 9 leaf 5." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    62
    final private String v9_root_dir3_leaf6_txt = "This is version 9 leaf 6." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    63
    final private String v10_root_dir3_leaf5_txt = "This is version 10 leaf 5." + System.lineSeparator();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    64
    final private String v10_root_dir3_leaf6_txt = "This is version 10 leaf 6." + System.lineSeparator();
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    65
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    66
    @BeforeClass
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    67
    public void initialize() throws Exception {
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    68
        Path jarfile = Paths.get("test.jar");
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    69
        JarBuilder jb = new JarBuilder(jarfile.toString());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    70
        jb.addAttribute("Multi-Release", "true");
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    71
        jb.addEntry("root/dir1/leaf1.txt", root_dir1_leaf1_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    72
        jb.addEntry("root/dir1/leaf2.txt", root_dir1_leaf2_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    73
        jb.addEntry("root/dir2/leaf3.txt", root_dir2_leaf3_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    74
        jb.addEntry("root/dir2/leaf4.txt", root_dir2_leaf4_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    75
        jb.addEntry("META-INF/versions/9/root/dir2/leaf3.txt", v9_root_dir2_leaf3_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    76
        jb.addEntry("META-INF/versions/9/root/dir2/leaf4.txt", v9_root_dir2_leaf4_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    77
        jb.addEntry("META-INF/versions/9/root/dir3/leaf5.txt", v9_root_dir3_leaf5_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    78
        jb.addEntry("META-INF/versions/9/root/dir3/leaf6.txt", v9_root_dir3_leaf6_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    79
        jb.addEntry("META-INF/versions/10/root/dir3/leaf5.txt", v10_root_dir3_leaf5_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    80
        jb.addEntry("META-INF/versions/10/root/dir3/leaf6.txt", v10_root_dir3_leaf6_txt.getBytes());
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    81
        jb.build();
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    82
        System.out.println("Created " + jarfile + ": " + Files.exists(jarfile));
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    83
        jarURI = new URI("jar", jarfile.toUri().toString(), null);
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    84
    }
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    85
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    86
    @Test
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    87
    public void testWalk() throws IOException {
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    88
        // treat multi-release jar as unversioned
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    89
        Map<String, String> env = new HashMap<>();
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    90
        Set<String> contents = doTest(env);
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    91
        Set<String> expectedContents = Set.of(
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    92
            root_dir1_leaf1_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    93
            root_dir1_leaf2_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    94
            root_dir2_leaf3_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    95
            root_dir2_leaf4_txt
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    96
        );
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    97
        Assert.assertEquals(contents, expectedContents);
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
    98
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
    99
        // open file as multi-release for version 9
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   100
        env.put("multi-release", "9");
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   101
        contents = doTest(env);
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   102
        expectedContents = Set.of(
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   103
            root_dir1_leaf1_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   104
            root_dir1_leaf2_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   105
            v9_root_dir2_leaf3_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   106
            v9_root_dir2_leaf4_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   107
            v9_root_dir3_leaf5_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   108
            v9_root_dir3_leaf6_txt
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   109
        );
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   110
        Assert.assertEquals(contents, expectedContents);
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   111
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   112
        // open file as multi-release for version 10
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   113
        env.put("multi-release", "10");
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   114
        contents = doTest(env);
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   115
        expectedContents = Set.of(
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   116
            root_dir1_leaf1_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   117
            root_dir1_leaf2_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   118
            v9_root_dir2_leaf3_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   119
            v9_root_dir2_leaf4_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   120
            v10_root_dir3_leaf5_txt,
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   121
            v10_root_dir3_leaf6_txt
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   122
        );
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   123
        Assert.assertEquals(contents, expectedContents);
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   124
    }
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   125
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   126
    private Set<String> doTest(Map<String,String> env) throws IOException {
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   127
        Set<String> contents;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   128
        try (FileSystem fs = FileSystems.newFileSystem(jarURI, env)) {
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   129
            Path root = fs.getPath("root");
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   130
            contents = Files.walk(root)
54630
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   131
                .filter(p -> !Files.isDirectory(p))
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   132
                .map(this::pathToContents)
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   133
                .sorted()
04b17e84c87d 8222440: (zipfs) JarFileSystem does not correctly handle versioned entries if no root entry is present
clanger
parents: 47216
diff changeset
   134
                .collect(Collectors.toSet());
40528
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   135
        }
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   136
        return contents;
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   137
    }
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   138
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   139
    private String pathToContents(Path path) {
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   140
        try {
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   141
            return new String(Files.readAllBytes(path));
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   142
        } catch (IOException x) {
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   143
            throw new UncheckedIOException(x);
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   144
        }
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   145
    }
c2d4a13ab15a 8164389: jdk.nio.zipfs.JarFileSystem does not completely traverse the versioned entries in a multi-release jar file
sdrach
parents:
diff changeset
   146
}