Path: blob/master/test/jdk/java/lang/Package/PackageVersionTest.java
41149 views
/*1* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 819098726* @summary Test verifies that individual Package.VersionInfo elements can be27* supplied and retrieved even if no other elements are set.28* @run testng PackageVersionTest29*/303132import java.net.URL;33import org.testng.Assert;34import org.testng.annotations.Test;3536public class PackageVersionTest {3738@Test39public static void testSpecTitle() {40TestClassLoader loader = new TestClassLoader();41Package p = loader.definePackage("testSpecTitle", "SpecTitle",42null, null, null,43null, null, null);44Assert.assertEquals(p.getSpecificationTitle(), "SpecTitle",45"Package specification titles do not match!");46}4748@Test49public static void testSpecVersion() {50TestClassLoader loader = new TestClassLoader();51Package p = loader.definePackage("testSpecVersion", null,52"1.0", null, null,53null, null, null);54Assert.assertEquals(p.getSpecificationVersion(), "1.0",55"Package specification versions do not match!");56}5758@Test59public static void testSpecVendor() {60TestClassLoader loader = new TestClassLoader();61Package p = loader.definePackage("testSpecVendor", null,62null, "SpecVendor", null,63null, null, null);64Assert.assertEquals(p.getSpecificationVendor(), "SpecVendor",65"Package specification vendors do not match!");66}6768@Test69public static void testImplTitle() {70TestClassLoader loader = new TestClassLoader();71Package p = loader.definePackage("testImplTitle", null,72null, null, "ImplTitle",73null, null, null);74Assert.assertEquals(p.getImplementationTitle(), "ImplTitle",75"Package implementation titles do not match!");76}7778@Test79public static void testImplVersion() {80TestClassLoader loader = new TestClassLoader();81Package p = loader.definePackage("testImplVersion", null,82null, null, null,83"1.0", null, null);84Assert.assertEquals(p.getImplementationVersion(), "1.0",85"Package implementation versions do not match!");86}8788@Test89public static void testImplVendor() {90TestClassLoader loader = new TestClassLoader();91Package p = loader.definePackage("testImplVendor", null,92null, null, null,93null, "ImplVendor", null);94Assert.assertEquals(p.getImplementationVendor(), "ImplVendor",95"Package implementation vendors do not match!");96}97}9899class TestClassLoader extends ClassLoader {100@Override101protected Package definePackage(String name, String specTitle,102String specVersion, String specVendor,103String implTitle, String implVersion,104String implVendor, URL sealBase) {105return super.definePackage(name, specTitle, specVersion, specVendor,106implTitle, implVersion, implVendor, sealBase);107}108}109110111