Java Code Examples for java.util.jar.JarFile#baseVersion()

The following examples show how to use java.util.jar.JarFile#baseVersion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiReleaseJarAPI.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider="versions")
public void testVersioning(Runtime.Version value, int xpected) throws Exception {
    Runtime.Version expected = Runtime.Version.parse(String.valueOf(xpected));
    Runtime.Version base = JarFile.baseVersion();

    // multi-release jar, opened as unversioned
    try (JarFile jar = new JarFile(multirelease)) {
        Assert.assertEquals(jar.getVersion(), base);
    }

    System.err.println("test versioning for Release " + value);
    try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, value)) {
        Assert.assertEquals(jf.getVersion(), expected);
    }

    // regular, unversioned, jar
    try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, value)) {
        Assert.assertEquals(jf.getVersion(), base);
    }
}
 
Example 2
Source File: MultiReleaseJarAPI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "versions")
public Object[][] createVersionData() throws Exception {
    return new Object[][]{
            {JarFile.baseVersion(), 8},
            {JarFile.runtimeVersion(), Runtime.version().major()},
            {Runtime.version(), Runtime.version().major()},
            {Runtime.Version.parse("7.1"), JarFile.baseVersion().major()},
            {Runtime.Version.parse("9"), 9},
            {Runtime.Version.parse("9.1.5-ea+200"), 9}
    };
}
 
Example 3
Source File: TestVersionedStream.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider
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()}
    };
}