< prev index next >
test/jdk/java/util/jar/JarFile/mrjar/TestVersionedStream.java
Print this page
*** 1,7 ****
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2016, 2018, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 62,71 ****
--- 62,73 ----
public class TestVersionedStream {
private final Path userdir;
private final Set<String> unversionedEntryNames;
+ private static final int LATEST_VERSION = Runtime.version().feature();
+
public TestVersionedStream() throws IOException {
userdir = Paths.get(System.getProperty("user.dir", "."));
// These are not real class files even though they end with .class.
// They are resource files so jar tool validation won't reject them.
*** 77,92 ****
"base/p/Foo.class",
"base/p/Main.class",
"v9/p/Foo.class",
"v10/p/Foo.class",
"v10/q/Bar.class",
! "v11/p/Bar.class",
! "v11/p/Foo.class"
);
! jar("cf mmr.jar -C base . --release 9 -C v9 . " +
! "--release 10 -C v10 . --release 11 -C v11 .");
System.out.println("Contents of mmr.jar\n=======");
try(JarFile jf = new JarFile("mmr.jar")) {
unversionedEntryNames = jf.stream()
--- 79,96 ----
"base/p/Foo.class",
"base/p/Main.class",
"v9/p/Foo.class",
"v10/p/Foo.class",
"v10/q/Bar.class",
! "v" + LATEST_VERSION + "/p/Bar.class",
! "v" + LATEST_VERSION + "/p/Foo.class"
);
! jar("cf mmr.jar -C base . " +
! "--release 9 -C v9 . " +
! "--release 10 -C v10 . " +
! "--release " + LATEST_VERSION + " -C v" + LATEST_VERSION + " .");
System.out.println("Contents of mmr.jar\n=======");
try(JarFile jf = new JarFile("mmr.jar")) {
unversionedEntryNames = jf.stream()
*** 122,132 ****
public Object[][] data() {
return new Object[][] {
{Runtime.Version.parse("8")},
{Runtime.Version.parse("9")},
{Runtime.Version.parse("10")},
! {Runtime.Version.parse("11")},
{JarFile.baseVersion()},
{JarFile.runtimeVersion()}
};
}
--- 126,136 ----
public Object[][] data() {
return new Object[][] {
{Runtime.Version.parse("8")},
{Runtime.Version.parse("9")},
{Runtime.Version.parse("10")},
! {Runtime.Version.parse(Integer.toString(LATEST_VERSION))},
{JarFile.baseVersion()},
{JarFile.runtimeVersion()}
};
}
*** 171,181 ****
// value.[1] versioned path/real name
Map<String,String[]> expected = new HashMap<>();
expected.put("p/Bar.class", new String[] { "base/p/Bar.class", "p/Bar.class" });
expected.put("p/Main.class", new String[] { "base/p/Main.class", "p/Main.class" });
! switch (version.major()) {
case 8:
expected.put("p/Foo.class", new String[]
{ "base/p/Foo.class", "p/Foo.class" });
break;
case 9:
--- 175,186 ----
// value.[1] versioned path/real name
Map<String,String[]> expected = new HashMap<>();
expected.put("p/Bar.class", new String[] { "base/p/Bar.class", "p/Bar.class" });
expected.put("p/Main.class", new String[] { "base/p/Main.class", "p/Main.class" });
! int majorVersion = version.major();
! switch (majorVersion) {
case 8:
expected.put("p/Foo.class", new String[]
{ "base/p/Foo.class", "p/Foo.class" });
break;
case 9:
*** 187,207 ****
{ "v10/p/Foo.class", "META-INF/versions/10/p/Foo.class" });
expected.put("q/Bar.class", new String[]
{ "v10/q/Bar.class", "META-INF/versions/10/q/Bar.class" });
break;
- case 11:
- expected.put("p/Bar.class", new String[]
- { "v11/p/Bar.class", "META-INF/versions/11/p/Bar.class"});
- expected.put("p/Foo.class", new String[]
- { "v11/p/Foo.class", "META-INF/versions/11/p/Foo.class"});
- expected.put("q/Bar.class", new String[]
- { "q/Bar.class", "META-INF/versions/10/q/Bar.class"});
- break;
default:
Assert.fail("Test out of date, please add more cases");
}
expected.entrySet().stream().forEach(e -> {
String name = e.getKey();
int i = versionedNames.indexOf(name);
Assert.assertTrue(i != -1, name + " not in enames");
--- 192,215 ----
{ "v10/p/Foo.class", "META-INF/versions/10/p/Foo.class" });
expected.put("q/Bar.class", new String[]
{ "v10/q/Bar.class", "META-INF/versions/10/q/Bar.class" });
break;
default:
+ if (majorVersion == LATEST_VERSION) {
+ expected.put("p/Bar.class",
+ new String[] { "v" + LATEST_VERSION + "/p/Bar.class",
+ "META-INF/versions/" + LATEST_VERSION + "/p/Bar.class"});
+ expected.put("p/Foo.class",
+ new String[]{ "v" + LATEST_VERSION + "/p/Foo.class",
+ "META-INF/versions/" + LATEST_VERSION + "/p/Foo.class"});
+ expected.put("q/Bar.class",
+ new String[] { "q/Bar.class", "META-INF/versions/10/q/Bar.class"});
+ } else {
Assert.fail("Test out of date, please add more cases");
}
+ }
expected.entrySet().stream().forEach(e -> {
String name = e.getKey();
int i = versionedNames.indexOf(name);
Assert.assertTrue(i != -1, name + " not in enames");
< prev index next >