diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java index 0447270d99a..c88827c1a39 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java @@ -23,18 +23,20 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.CatalogReferCircularityTest + * @run junit/othervm catalog.CatalogReferCircularityTest * @summary Via nextCatalog entry, the catalog reference chain may be * a (partial) closed circuit. For instance, a catalog may use itself * as an additional catalog specified in its own nextCatalog entry. @@ -42,22 +44,19 @@ import org.testng.annotations.Test; */ public class CatalogReferCircularityTest { - @Test(dataProvider = "catalogName", - expectedExceptions = CatalogException.class) + @ParameterizedTest + @ValueSource(strings={ + // This catalog defines itself as next catalog. + "catalogReferCircle-itself.xml", + + // This catalog defines catalogReferCircle-right.xml as its next + // catalog. And catalogReferCircle-right.xml also defines + // catalogReferCircle-left.xml as its next catalog, too. + "catalogReferCircle-left.xml" }) public void testReferCircularity(String catalogFile) { - catalogResolver(catalogFile).resolveEntity(null, - "http://remote/dtd/ghost/docGhost.dtd"); - } - - @DataProvider(name = "catalogName") - public Object[][] catalogName() { - return new Object[][] { - // This catalog defines itself as next catalog. - { "catalogReferCircle-itself.xml" }, - - // This catalog defines catalogReferCircle-right.xml as its next - // catalog. And catalogReferCircle-right.xml also defines - // catalogReferCircle-left.xml as its next catalog, too. - { "catalogReferCircle-left.xml" } }; + CatalogResolver resolver = catalogResolver(catalogFile); + Assertions.assertThrows( + CatalogException.class, + () -> resolver.resolveEntity(null, "http://remote/dtd/ghost/docGhost.dtd")); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java index d76b56d7510..f17aa04ac76 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java @@ -23,42 +23,30 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogFeatures.Feature; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.DefaultFeaturesTest + * @run junit/othervm catalog.DefaultFeaturesTest * @summary This case tests if the default feature values are expected. */ public class DefaultFeaturesTest { - - private CatalogFeatures defaultFeature; - - @BeforeClass - public void init() { - defaultFeature = CatalogFeatures.defaults(); - } - - @Test(dataProvider="feature-value") + @ParameterizedTest + @MethodSource("defaultFeaturesData") public void testDefaultFeatures(Feature feature, String expected) { - String featureValue = defaultFeature.get(feature); - if (expected != null) { - Assert.assertEquals(featureValue, expected); - } else { - Assert.assertNull(featureValue); - } + CatalogFeatures defaultFeature = CatalogFeatures.defaults(); + assertEquals(expected, defaultFeature.get(feature)); } - @DataProvider(name = "feature-value") - public Object[][] data() { + public static Object[][] defaultFeaturesData() { return new Object[][] { { Feature.FILES, null }, { Feature.PREFER, CatalogTestUtils.PREFER_PUBLIC }, diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java index 2d5771557ad..36335cb586d 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java @@ -23,42 +23,43 @@ package catalog; -import static catalog.CatalogTestUtils.DEFER_FALSE; -import static catalog.CatalogTestUtils.DEFER_TRUE; -import static catalog.CatalogTestUtils.getCatalogPath; -import static javax.xml.catalog.CatalogFeatures.Feature.DEFER; - -import java.lang.reflect.Method; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.Catalog; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; +import java.lang.reflect.Method; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.DEFER_FALSE; +import static catalog.CatalogTestUtils.DEFER_TRUE; +import static catalog.CatalogTestUtils.getCatalogPath; +import static javax.xml.catalog.CatalogFeatures.Feature.DEFER; +import static org.junit.jupiter.api.Assertions.assertEquals; /* * @test * @bug 8077931 8176405 * @library /javax/xml/jaxp/libs * @modules java.xml/javax.xml.catalog:open - * @run testng/othervm catalog.DeferFeatureTest + * @run junit/othervm catalog.DeferFeatureTest * @summary This case tests whether the catalogs specified in delegateSystem, * delegatePublic, delegateURI and nextCatalog entries are used lazily * in resolution via defer feature. */ public class DeferFeatureTest { - @Test(dataProvider = "catalog-countOfLoadedCatalogFile") + @ParameterizedTest + @MethodSource("deferData") public void testDeferFeature(Catalog catalog, int catalogCount) throws Exception { - Assert.assertEquals(loadedCatalogCount(catalog), catalogCount); + assertEquals(catalogCount, loadedCatalogCount(catalog)); } - @Test(dataProvider = "testDeferFeatureByResolve") + @ParameterizedTest + @MethodSource("deferByResolveData") public void testDeferFeatureByResolve(Catalog catalog, int catalogCount) throws Exception { CatalogResolver cr = createResolver(catalog); @@ -67,41 +68,39 @@ public class DeferFeatureTest { cr.resolveEntity("-//REMOTE//DTD ALICE DOCALICE", "http://remote/dtd/alice/"); } catch (CatalogException ce) {} - Assert.assertEquals(loadedCatalogCount(catalog), catalogCount); + assertEquals(catalogCount, loadedCatalogCount(catalog)); } - @DataProvider(name = "catalog-countOfLoadedCatalogFile") - public Object[][] data() { - return new Object[][]{ - // By default, alternative catalogs are not loaded. - {createCatalog(CatalogFeatures.defaults()), 1}, - // Alternative catalogs are not loaded when DEFER is set to true. - {createCatalog(createDeferFeature(DEFER_TRUE)), 1}, - // The 3 alternative catalogs are pre-loaded along with the parent - //when DEFER is set to false. - {createCatalog(createDeferFeature(DEFER_FALSE)), 4}}; + public static Object[][] deferData() { + return new Object[][] { + // By default, alternative catalogs are not loaded. + { createCatalog(CatalogFeatures.defaults()), 1 }, + // Alternative catalogs are not loaded when DEFER is set to true. + { createCatalog(createDeferFeature(DEFER_TRUE)), 1 }, + // The 3 alternative catalogs are pre-loaded along with the parent + //when DEFER is set to false. + { createCatalog(createDeferFeature(DEFER_FALSE)), 4 } }; } - @DataProvider(name = "testDeferFeatureByResolve") - public Object[][] getData() { - return new Object[][]{ - {createCatalog(createDeferFeature(DEFER_TRUE)), 4} + public static Object[][] deferByResolveData() { + return new Object[][] { + { createCatalog(createDeferFeature(DEFER_TRUE)), 4 } }; } - private CatalogFeatures createDeferFeature(String defer) { + private static CatalogFeatures createDeferFeature(String defer) { return CatalogFeatures.builder().with(DEFER, defer).build(); } - private Catalog createCatalog(CatalogFeatures feature) { + private static Catalog createCatalog(CatalogFeatures feature) { return CatalogManager.catalog(feature, getCatalogPath("deferFeature.xml")); } - private CatalogResolver createResolver(Catalog catalog) { + private static CatalogResolver createResolver(Catalog catalog) { return CatalogManager.catalogResolver(catalog); } - private int loadedCatalogCount(Catalog catalog) throws Exception { + private static int loadedCatalogCount(Catalog catalog) throws Exception { Method method = catalog.getClass().getDeclaredMethod("loadedCatalogCount"); method.setAccessible(true); return (int) method.invoke(catalog); diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java index 43c6bf42f44..579140825c2 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java @@ -23,32 +23,32 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkPubIdResolution; -import static catalog.ResolutionChecker.expectExceptionOnPubId; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkPubIdResolution; +import static catalog.ResolutionChecker.expectExceptionOnPubId; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.DelegatePublicTest + * @run junit/othervm catalog.DelegatePublicTest * @summary Get matched URIs from DelegatePublic entries. */ public class DelegatePublicTest { - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String publicId, String matchedUri) { checkPubIdResolution(createResolver(), publicId, matchedUri); } - @DataProvider(name = "publicId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified public id is defined in // a delegate catalog file of the current catalog file. @@ -71,15 +71,15 @@ public class DelegatePublicTest { "http://local/base/dtd/carl/docCarlPub.dtd" } }; } - @Test(dataProvider = "publicId-expectedExceptionClass") + @ParameterizedTest + @MethodSource("dataOnException") public void testException(String publicId, Class expectedExceptionClass) { expectExceptionOnPubId(createResolver(), publicId, expectedExceptionClass); } - @DataProvider(name = "publicId-expectedExceptionClass") - public Object[][] dataOnException() { + public static Object[][] dataOnException() { return new Object[][] { // The matched delegatePublic entry of the specified public id // defines a non-existing delegate catalog file. That should @@ -93,7 +93,7 @@ public class DelegatePublicTest { CatalogException.class } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("delegatePublic.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java index 554d23776f9..27da1105b2c 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java @@ -23,32 +23,32 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkSysIdResolution; -import static catalog.ResolutionChecker.expectExceptionOnSysId; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static catalog.ResolutionChecker.expectExceptionOnSysId; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.DelegateSystemTest + * @run junit/othervm catalog.DelegateSystemTest * @summary Get matched URIs from delegateSystem entries. */ public class DelegateSystemTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in // a delegate catalog file of the current catalog file. @@ -71,15 +71,15 @@ public class DelegateSystemTest { "http://local/base/dtd/carl/docCarlDS.dtd"} }; } - @Test(dataProvider = "systemId-expectedExceptionClass") + @ParameterizedTest + @MethodSource("dataOnException") public void testException(String systemId, Class expectedExceptionClass) { expectExceptionOnSysId(createResolver(), systemId, expectedExceptionClass); } - @DataProvider(name = "systemId-expectedExceptionClass") - public Object[][] dataOnException() { + public static Object[][] dataOnException() { return new Object[][] { // The matched delegateSystem entry of the specified system id // defines a non-existing delegate catalog file. That should @@ -93,7 +93,7 @@ public class DelegateSystemTest { CatalogException.class } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("delegateSystem.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateUriTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateUriTest.java index 2a92149a730..0175a99f938 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateUriTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/DelegateUriTest.java @@ -23,32 +23,32 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkUriResolution; import static catalog.ResolutionChecker.expectExceptionOnUri; -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.DelegateUriTest + * @run junit/othervm catalog.DelegateUriTest * @summary Get matched URIs from delegateURI entries. */ public class DelegateUriTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String uri, String matchedUri) { checkUriResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] data() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a delegate catalog file of the current catalog file. @@ -71,14 +71,14 @@ public class DelegateUriTest { "http://local/base/dtd/carl/docCarlDU.dtd"} }; } - @Test(dataProvider = "uri-expectedExceptionClass") + @ParameterizedTest + @MethodSource("dataOnException") public void testException(String uri, Class expectedExceptionClass) { expectExceptionOnUri(createResolver(), uri, expectedExceptionClass); } - @DataProvider(name = "uri-expectedExceptionClass") - public Object[][] dataOnException() { + public static Object[][] dataOnException() { return new Object[][] { // The matched delegateURI entry of the specified URI reference // defines a non-existing delegate catalog file. That should @@ -92,7 +92,7 @@ public class DelegateUriTest { CatalogException.class } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver("delegateUri.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/GroupTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/GroupTest.java index 7516be7d560..37910c2b1f5 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/GroupTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/GroupTest.java @@ -23,22 +23,22 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkPubIdResolution; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.GroupTest + * @run junit/othervm catalog.GroupTest * @summary Get matched URIs from system, public and uri entries respectively, * and some of the entries are enclosed by group entries. */ @@ -46,13 +46,13 @@ public class GroupTest { private static final String CATALOG_GROUP = "group.xml"; - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataMatchSysId") public void testMatchOnSysId(String uri, String matchedUri) { checkSysIdResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnSysId() { + public static Object[][] dataMatchSysId() { return new Object[][] { // The matched URI of the specified system id is enclosed by a // group entry. @@ -72,13 +72,13 @@ public class GroupTest { "http://local/base/dtd/docCarlSys1.dtd" } }; } - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatchPubId") public void testMatchOnPubId(String uri, String matchedUri) { checkPubIdResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "publicId-matchedUri") - public Object[][] dataOnPubId() { + public static Object[][] dataOnMatchPubId() { return new Object[][] { // The matched URI of the specified public id is enclosed by a // group entry. @@ -98,13 +98,13 @@ public class GroupTest { "http://local/base/dtd/docCarlPub1.dtd" } }; } - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatchUri") public void testMatchOnUri(String uri, String matchedUri) { checkUriResolution(catalogUriResolver(CATALOG_GROUP), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnUri() { + public static Object[][] dataOnMatchUri() { return new Object[][] { // The matched URI of the specified URI reference is enclosed by // a group entry. @@ -124,7 +124,7 @@ public class GroupTest { "http://local/base/dtd/docAliceURI.dtd" } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver(CATALOG_GROUP); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java index 6a5248b8f9f..481c2fa1f83 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java @@ -23,6 +23,12 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.CATALOG_PUBLIC; import static catalog.CatalogTestUtils.CATALOG_SYSTEM; import static catalog.CatalogTestUtils.CATALOG_URI; @@ -30,18 +36,13 @@ import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.LoadCatalogTest + * @run junit/othervm catalog.LoadCatalogTest * @summary When catalog resolver loads catalog files, the current catalog file * and the catalog files specified by the nextCatalog entries may not * accessible. This case tests how does the resolver handle this issue. @@ -55,14 +56,14 @@ public class LoadCatalogTest { private static final String ID_ALICE_URI = "http://remote/dtd/uri/alice/docAlice.dtd"; private static final String ID_DUMMY = "http://remote/dtd/doc.dtd"; - @Test(dataProvider = "entityResolver") + @ParameterizedTest + @MethodSource("entityResolver") public void testMatchOnEntityResolver(CatalogResolver resolver) { checkSysIdResolution(resolver, ID_ALICE, "http://local/dtd/docAliceSys.dtd"); } - @DataProvider(name = "entityResolver") - public Object[][] entityResolver() { + public static Object[][] entityResolver() { return new Object[][] { // This EntityResolver loads multiple catalog files one by one. // All of the files are available. @@ -75,14 +76,14 @@ public class LoadCatalogTest { CATALOG_SYSTEM) } }; } - @Test(dataProvider = "uriResolver") + @ParameterizedTest + @MethodSource("uriResolver") public void testMatchOnUriResolver(CatalogResolver resolver) { checkUriResolution(resolver, ID_ALICE_URI, "http://local/dtd/docAliceURI.dtd"); } - @DataProvider(name = "uriResolver") - public Object[][] uriResolver() { + public static Object[][] uriResolver() { return new Object[][] { // This URIResolver loads multiple catalog files one by one. // All of the files are available. @@ -95,20 +96,21 @@ public class LoadCatalogTest { CATALOG_URI) } }; } - @Test(dataProvider = "catalogName", - expectedExceptions = CatalogException.class) - public void testExceptionOnEntityResolver(String[] catalogName) { - catalogResolver(catalogName).resolveEntity(null, ID_DUMMY); + @ParameterizedTest + @MethodSource("catalogName") + public void testException(String[] catalogName) { + CatalogResolver resolver = catalogResolver(catalogName); + assertThrows(CatalogException.class, () -> resolver.resolveEntity(null, ID_DUMMY)); } - @Test(dataProvider = "catalogName", - expectedExceptions = CatalogException.class) + @ParameterizedTest + @MethodSource("catalogName") public void testExceptionOnUriResolver(String[] catalogName) { - catalogUriResolver(catalogName).resolve(ID_DUMMY, null); + CatalogResolver resolver = catalogUriResolver(catalogName); + assertThrows(CatalogException.class, () -> resolver.resolve(ID_DUMMY, null)); } - @DataProvider(name = "catalogName") - public Object[][] catalogName() { + public static Object[][] catalogName() { return new Object[][] { // This catalog file set includes null catalog files. { (String[]) null }, diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/NextCatalogTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/NextCatalogTest.java index d7e0711636d..ff56b86a500 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/NextCatalogTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/NextCatalogTest.java @@ -23,22 +23,22 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkPubIdResolution; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.NextCatalogTest + * @run junit/othervm catalog.NextCatalogTest * @summary Get matched URIs from system, public and uri entries respectively, * but some of the entries are defined in none-current catalog files. */ @@ -49,13 +49,13 @@ public class NextCatalogTest { private static final String CATALOG_NEXTCATALOGRIGHT = "nextCatalog-right.xml"; - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnSysId") public void testNextCatalogOnSysId(String sytemId, String matchedUri) { checkSysIdResolution(createEntityResolver(), sytemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnSysId() { + public static Object[][] dataOnSysId() { return new Object[][] { // This matched URI of the specified system id is defined in a // next catalog file. @@ -81,13 +81,13 @@ public class NextCatalogTest { "http://local/base/dtd/docDuplicateLeftSys.dtd" } }; } - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnPubId") public void testNextCatalogOnPubId(String publicId, String matchedUri) { checkPubIdResolution(createEntityResolver(), publicId, matchedUri); } - @DataProvider(name = "publicId-matchedUri") - public Object[][] dataOnPubId() { + public static Object[][] dataOnPubId() { return new Object[][] { // This matched URI of the specified public id is defined in a // next catalog file. @@ -113,13 +113,13 @@ public class NextCatalogTest { "http://local/base/dtd/docDuplicateLeftPub.dtd" } }; } - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnUri") public void testNextCatalogOnUri(String uri, String matchedUri) { checkUriResolution(createUriResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnUri() { + public static Object[][] dataOnUri() { return new Object[][] { // This matched URI of the specified URI reference is defined in // a next catalog file. @@ -145,12 +145,12 @@ public class NextCatalogTest { "http://local/base/dtd/docDuplicateLeftURI.dtd" } }; } - private CatalogResolver createEntityResolver() { + private static CatalogResolver createEntityResolver() { return catalogResolver(CATALOG_NEXTCATALOGLEFT, CATALOG_NEXTCATALOGRIGHT); } - private CatalogResolver createUriResolver() { + private static CatalogResolver createUriResolver() { return catalogUriResolver(CATALOG_NEXTCATALOGLEFT, CATALOG_NEXTCATALOGRIGHT); } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/NormalizationTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/NormalizationTest.java index 74fc25e90c1..0a112fd7426 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/NormalizationTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/NormalizationTest.java @@ -23,22 +23,22 @@ package catalog; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkPubIdResolution; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.NormalizationTest + * @run junit/othervm catalog.NormalizationTest * @summary Before matching identifiers and URI references, it has to normalize * the passed identifiers and URI references. And then the catalog * resolver uses the normalized stuff to search the counterparts in @@ -48,23 +48,25 @@ public class NormalizationTest { private static final String CATALOG_NORMALIZATION = "normalization.xml"; - @Test(dataProvider = "systemId_uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnSysIdAndUri") public void testNormalizationOnSysId(String sytemId, String matchedUri) { checkSysIdResolution(createEntityResolver(), sytemId, matchedUri); } - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnPubId") public void testNormalizationOnPubId(String publicId, String matchedUri) { checkPubIdResolution(createEntityResolver(), publicId, matchedUri); } - @Test(dataProvider = "systemId_uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnSysIdAndUri") public void testNormalizationOnUri(String uri, String matchedUri) { checkUriResolution(createUriResolver(), uri, matchedUri); } - @DataProvider(name = "systemId_uri-matchedUri") - public Object[][] dataOnSysIdAndUri() { + public static Object[][] dataOnSysIdAndUri() { return new Object[][] { // The specified system id/URI reference contains spaces. And // the counterparts in system/uri entries also contain spaces. @@ -85,8 +87,7 @@ public class NormalizationTest { "http://local/base/dtd/docBobSys.dtd" } }; } - @DataProvider(name = "publicId-matchedUri") - public Object[][] dataOnPubId() { + public static Object[][] dataOnPubId() { return new Object[][] { // The specified public id contains spaces. And the counterparts // in public entry also contains spaces. @@ -103,11 +104,11 @@ public class NormalizationTest { "http://local/base/dtd/docBobPub.dtd" } }; } - private CatalogResolver createEntityResolver() { + private static CatalogResolver createEntityResolver() { return catalogResolver(CATALOG_NORMALIZATION); } - private CatalogResolver createUriResolver() { + private static CatalogResolver createUriResolver() { return catalogUriResolver(CATALOG_NORMALIZATION); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java index 85cb2505244..4f9cfcd1f82 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java @@ -23,38 +23,38 @@ package catalog; -import static catalog.CatalogTestUtils.PREFER_PUBLIC; -import static catalog.CatalogTestUtils.PREFER_SYSTEM; -import static catalog.CatalogTestUtils.catalogResolver; -import static javax.xml.catalog.CatalogFeatures.Feature.PREFER; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.PREFER_PUBLIC; +import static catalog.CatalogTestUtils.PREFER_SYSTEM; +import static catalog.CatalogTestUtils.catalogResolver; +import static javax.xml.catalog.CatalogFeatures.Feature.PREFER; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.PreferFeatureTest + * @run junit/othervm catalog.PreferFeatureTest * @summary This case tests how does the feature affect the catalog resolution, * and tests the priority between this feature and attribute prefer * in catalog file. */ public class PreferFeatureTest { - @Test(dataProvider = "prefer-publicId-systemId", - expectedExceptions = CatalogException.class) - public void testPreferFeature(String prefer, String systemId, - String publicId) { - createResolver(prefer).resolveEntity(systemId, publicId); + @ParameterizedTest + @MethodSource("data") + public void testPreferFeature(String prefer, String systemId, String publicId) { + CatalogResolver resolver = createResolver(prefer); + assertThrows(CatalogException.class, () -> resolver.resolveEntity(systemId, publicId)); } - @DataProvider(name = "prefer-publicId-systemId") - public Object[][] data() { + public static Object[][] data() { return new Object[][] { // The feature prefer is system. There's a match for the // specified public id, and no match for the specified system id. @@ -72,7 +72,7 @@ public class PreferFeatureTest { "http://remote/dtd/bob/docBobDummy.dtd"} }; } - private CatalogResolver createResolver(String prefer) { + private static CatalogResolver createResolver(String prefer) { return catalogResolver( CatalogFeatures.builder().with(PREFER, prefer).build(), "preferFeature.xml"); diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/PreferTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/PreferTest.java index 6bcbd140466..c358ff85c62 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/PreferTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/PreferTest.java @@ -23,19 +23,19 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkExtIdResolution; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkExtIdResolution; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.PreferTest + * @run junit/othervm catalog.PreferTest * @summary Get matched URIs from system and public family entries, which * specify the prefer attribute. It tests how does the prefer attribute * affect the resolution procedure. The test rule is based on OASIS @@ -43,14 +43,14 @@ import org.testng.annotations.Test; */ public class PreferTest { - @Test(dataProvider = "publicId-systemId-matchedUri") + @ParameterizedTest + @MethodSource("data") public void testPrefer(String publicId, String systemId, String expected) { checkExtIdResolution(createResolver(), publicId, systemId, expected); } - @DataProvider(name = "publicId-systemId-matchedUri") - public Object[][] data() { + public static Object[][] data() { return new Object[][] { // The prefer attribute is public. Both of the specified public // id and system id have matches in the catalog file. But @@ -85,7 +85,7 @@ public class PreferTest { "http://local/base/dtd/docBobSys.dtd" } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("prefer.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java index 42dc6bbe215..44a0d46537f 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java @@ -23,20 +23,21 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkPubIdResolution; +import org.junit.jupiter.api.Test; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkPubIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.PublicFamilyTest + * @run junit/othervm catalog.PublicFamilyTest * @summary Get matched URIs from public and delegatePublic entries. * It tests the resolution priorities among the public family entries. * The test rule is based on OASIS Standard V1.1 section 7.1.2. @@ -58,12 +59,12 @@ public class PublicFamilyTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) - public void testNoMatched() { - checkNoMatch(createResolver()); + @Test + public void testNoMatch() { + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("publicFamily.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/PublicTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/PublicTest.java index d44dca87732..fe137eac6e9 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/PublicTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/PublicTest.java @@ -23,33 +23,35 @@ package catalog; -import static catalog.CatalogTestUtils.CATALOG_PUBLIC; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkPubIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.CATALOG_PUBLIC; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkPubIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.PublicTest + * @run junit/othervm catalog.PublicTest * @summary Get matched URIs from public entries. */ public class PublicTest { - @Test(dataProvider = "publicId-matchedUri") + @ParameterizedTest + @MethodSource("data") public void testPublic(String publicId, String matchedUri) { checkPubIdResolution(createResolver(), publicId, matchedUri); } - @DataProvider(name = "publicId-matchedUri") - public Object[][] data() { + public static Object[][] data() { return new Object[][] { // The matched URI of the specified public id is defined in a // public entry. The match is an absolute path. @@ -80,12 +82,12 @@ public class PublicTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver(CATALOG_PUBLIC); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java index 0626e83bed9..a642f751a7f 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java @@ -23,6 +23,13 @@ package catalog; +import org.junit.jupiter.api.Test; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogFeatures.Feature; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.CATALOG_SYSTEM; import static catalog.CatalogTestUtils.CATALOG_URI; import static catalog.CatalogTestUtils.RESOLVE_CONTINUE; @@ -33,19 +40,13 @@ import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; import static javax.xml.catalog.CatalogFeatures.builder; - -import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogFeatures; -import javax.xml.catalog.CatalogFeatures.Feature; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.ResolveFeatureTest + * @run junit/othervm catalog.ResolveFeatureTest * @summary This case tests how does resolve feature affect the catalog * resolution. */ @@ -55,20 +56,24 @@ public class ResolveFeatureTest { * For strict external identifier resolution, if no match is found, * it should throw CatalogException. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testStrictResolutionOnEntityResolver() { - createEntityResolver(RESOLVE_STRICT).resolveEntity(null, - "http://remote/dtd/alice/docAliceDummy.dtd"); + CatalogResolver resolver = createEntityResolver(RESOLVE_STRICT); + assertThrows( + CatalogException.class, + () -> resolver.resolveEntity(null, "http://remote/dtd/alice/docAliceDummy.dtd")); } /* * For strict URI reference resolution, if no match is found, * it should throw CatalogException. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testStrictResolutionOnUriResolver() { - createUriResolver(RESOLVE_STRICT).resolve( - "http://remote/dtd/alice/docAliceDummy.dtd", null); + CatalogResolver resolver = createUriResolver(RESOLVE_STRICT); + assertThrows( + CatalogException.class, + () -> resolver.resolve("http://remote/dtd/alice/docAliceDummy.dtd", null)); } /* @@ -115,15 +120,15 @@ public class ResolveFeatureTest { "http://remote/dtd/carl/docCarlDummy.dtd", null); } - private CatalogResolver createEntityResolver(String resolve) { + private static CatalogResolver createEntityResolver(String resolve) { return catalogResolver(createFeature(resolve), CATALOG_SYSTEM); } - private CatalogResolver createUriResolver(String resolve) { + private static CatalogResolver createUriResolver(String resolve) { return catalogUriResolver(createFeature(resolve), CATALOG_URI); } - private CatalogFeatures createFeature(String resolve) { + private static CatalogFeatures createFeature(String resolve) { return builder().with(Feature.RESOLVE, resolve).build(); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java index 647fccd49fb..6c6cc752b98 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java @@ -23,32 +23,34 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkSysIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.RewriteSystemTest + * @run junit/othervm catalog.RewriteSystemTest * @summary Get matched URIs from rewriteSystem entries. */ public class RewriteSystemTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in a // rewriteSystem entry. The match is an absolute path. @@ -83,12 +85,12 @@ public class RewriteSystemTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("rewriteSystem.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteUriTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteUriTest.java index d7b98b96f11..1498f866c11 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteUriTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/RewriteUriTest.java @@ -23,32 +23,34 @@ package catalog; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.RewriteUriTest + * @run junit/othervm catalog.RewriteUriTest * @summary Get matched URIs from rewriteURI entries. */ public class RewriteUriTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String uri, String matchedUri) { checkUriResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a rewriteURI entry. The match is an absolute path. @@ -83,12 +85,12 @@ public class RewriteUriTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoUriMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoUriMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver("rewriteUri.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java index 61c59d4049c..d1795f6a45d 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java @@ -23,7 +23,10 @@ package catalog; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; +import org.junit.jupiter.api.Test; + +import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogResolver; import static catalog.CatalogTestUtils.FEATURE_FILES; import static catalog.CatalogTestUtils.catalogResolver; @@ -31,19 +34,14 @@ import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.CatalogTestUtils.getCatalogPath; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; -import static javax.xml.catalog.CatalogFeatures.builder; import static javax.xml.catalog.CatalogFeatures.Feature.FILES; - -import javax.xml.catalog.CatalogFeatures; -import javax.xml.catalog.CatalogResolver; - -import org.testng.annotations.Test; +import static javax.xml.catalog.CatalogFeatures.builder; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.SpecifyCatalogTest + * @run junit/othervm catalog.SpecifyCatalogTest * @summary This case tests how to specify the catalog files. */ public class SpecifyCatalogTest { @@ -77,7 +75,7 @@ public class SpecifyCatalogTest { */ @Test public void specifyCatalogViaSysProps() { - setSystemProperty(FEATURE_FILES, + System.setProperty(FEATURE_FILES, getCatalogPath("specifyCatalog-sysProps.xml").toASCIIString()); checkResolutionOnEntityResolver(catalogResolver((String[]) null), @@ -93,13 +91,13 @@ public class SpecifyCatalogTest { "http://local/base/dtd/docAPIURI.dtd"); } - private void checkResolutionOnEntityResolver(CatalogResolver resolver, - String matchedUri) { + private static void checkResolutionOnEntityResolver(CatalogResolver resolver, + String matchedUri) { checkSysIdResolution(resolver, ID_SYS, matchedUri); } - private void checkResolutionOnUriResolver(CatalogResolver resolver, - String matchedUri) { + private static void checkResolutionOnUriResolver(CatalogResolver resolver, + String matchedUri) { checkUriResolution(resolver, ID_URI, matchedUri); } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java index ec614332207..927aa65db66 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java @@ -23,21 +23,23 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkSysIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.SystemFamilyTest + * @run junit/othervm catalog.SystemFamilyTest * @summary Get matched URIs from system, rewriteSystem, systemSuffix and * delegateSystem entries. It tests the resolution priorities among * the system family entries. The test rule is based on OASIS @@ -45,13 +47,13 @@ import org.testng.annotations.Test; */ public class SystemFamilyTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in a // system entry. @@ -72,12 +74,12 @@ public class SystemFamilyTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("systemFamily.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java index 2a40b581654..6890cc2a4c8 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java @@ -23,32 +23,34 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkSysIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.SystemSuffixTest + * @run junit/othervm catalog.SystemSuffixTest * @summary Get matched URIs from systemSuffix entries. */ public class SystemSuffixTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in a // systemIdSuffix entry. The match is an absolute path. @@ -83,12 +85,12 @@ public class SystemSuffixTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("systemSuffix.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemTest.java index 73c11340b29..53909c4bd5a 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/SystemTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/SystemTest.java @@ -23,33 +23,35 @@ package catalog; -import static catalog.CatalogTestUtils.CATALOG_SYSTEM; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkNoMatch; -import static catalog.ResolutionChecker.checkSysIdResolution; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.CATALOG_SYSTEM; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkSysIdResolution; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.SystemTest + * @run junit/othervm catalog.SystemTest * @summary Get matched URIs from system entries. */ public class SystemTest { - @Test(dataProvider = "systemId-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkSysIdResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "systemId-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified system id is defined in a // system entry. The match is an absolute path. @@ -80,12 +82,12 @@ public class SystemTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver(CATALOG_SYSTEM); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/UriFamilyTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/UriFamilyTest.java index 44c9afcfa13..36b8d98ee1f 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/UriFamilyTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/UriFamilyTest.java @@ -23,21 +23,23 @@ package catalog; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.UriFamilyTest + * @run junit/othervm catalog.UriFamilyTest * @summary Get matched URIs from uri, rewriteURI, uriSuffix and delegateURI * entries. It tests the resolution priorities among the uri family * entries. The test rule is based on OASIS Standard V1.1 section @@ -45,13 +47,13 @@ import org.testng.annotations.Test; */ public class UriFamilyTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String systemId, String matchedUri) { checkUriResolution(createResolver(), systemId, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a uri entry. @@ -72,12 +74,12 @@ public class UriFamilyTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoUriMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoUriMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver("uriFamily.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/UriSuffixTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/UriSuffixTest.java index 8feadb03fa2..2bbe63a374a 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/UriSuffixTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/UriSuffixTest.java @@ -23,32 +23,34 @@ package catalog; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.UriSuffixTest + * @run junit/othervm catalog.UriSuffixTest * @summary Get matched URIs from rewriteURI entries. */ public class UriSuffixTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String uri, String matchedUri) { checkUriResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a uriSuffix entry. The match is an absolute path. @@ -83,12 +85,12 @@ public class UriSuffixTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoUriMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoUriMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver("uriSuffix.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/UriTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/UriTest.java index cf76eada5e7..651b2753713 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/UriTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/UriTest.java @@ -23,35 +23,37 @@ package catalog; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogResolver; + import static catalog.CatalogTestUtils.CATALOG_URI; import static catalog.CatalogTestUtils.RESOLVE_CONTINUE; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogFeatures; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.UriTest + * @run junit/othervm catalog.UriTest * @summary Get matched URIs from uri entries. */ public class UriTest { - @Test(dataProvider = "uri-matchedUri") + @ParameterizedTest + @MethodSource("dataOnMatch") public void testMatch(String uri, String matchedUri) { checkUriResolution(createResolver(), uri, matchedUri); } - @DataProvider(name = "uri-matchedUri") - public Object[][] dataOnMatch() { + public static Object[][] dataOnMatch() { return new Object[][] { // The matched URI of the specified URI reference is defined in // a uri entry. The match is an absolute path. @@ -92,12 +94,12 @@ public class UriTest { /* * If no match is found, a CatalogException should be thrown. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void testNoMatch() { - checkNoUriMatch(createResolver()); + assertThrows(CatalogException.class, () -> checkNoUriMatch(createResolver())); } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogUriResolver(CATALOG_URI); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java index f3b99074e98..765e315bd6e 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java @@ -23,32 +23,32 @@ package catalog; -import static catalog.CatalogTestUtils.catalogResolver; -import static catalog.ResolutionChecker.checkPubIdResolution; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import javax.xml.catalog.CatalogResolver; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static catalog.CatalogTestUtils.catalogResolver; +import static catalog.ResolutionChecker.checkPubIdResolution; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.UrnUnwrappingTest + * @run junit/othervm catalog.UrnUnwrappingTest * @summary If the passed public identifier is started with "urn:publicid:", * it has to be regarded as URN and normalized. And then the catalog * resolver uses the normalized stuff to do matching. */ public class UrnUnwrappingTest { - @Test(dataProvider = "urn-matchedUri") + @ParameterizedTest + @MethodSource("data") public void testUnwrapping(String urn, String matchedUri) { checkPubIdResolution(createResolver(), urn, matchedUri); } - @DataProvider(name = "urn-matchedUri") - public Object[][] data() { + public static Object[][] data() { return new Object[][] { // The specified public id is URN format. { "urn:publicid:-:REMOTE:DTD+ALICE+DOCALICE+XML:EN", @@ -60,7 +60,7 @@ public class UrnUnwrappingTest { "http://local/base/dtd/docBobPub.dtd" } }; } - private CatalogResolver createResolver() { + private static CatalogResolver createResolver() { return catalogResolver("urnUnwrapping.xml"); } } diff --git a/test/jaxp/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java b/test/jaxp/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java index 04676557ea4..c8316c085a2 100644 --- a/test/jaxp/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java +++ b/test/jaxp/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java @@ -23,22 +23,23 @@ package catalog; +import org.junit.jupiter.api.Test; + +import javax.xml.catalog.CatalogException; + import static catalog.CatalogTestUtils.CATALOG_SYSTEM; import static catalog.CatalogTestUtils.CATALOG_URI; import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.ResolutionChecker.checkSysIdResolution; import static catalog.ResolutionChecker.checkUriResolution; - -import javax.xml.catalog.CatalogException; - -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * @test * @bug 8077931 * @library /javax/xml/jaxp/libs - * @run testng/othervm catalog.ValidateCatalogTest + * @run junit/othervm catalog.ValidateCatalogTest * @summary A legal catalog file must be well-formed XML, the root element * must be catalog, and the naming space of the root element must be * urn:oasis:names:tc:entity:xmlns:xml:catalog. @@ -52,36 +53,36 @@ public class ValidateCatalogTest { * EntityResolver tries to load catalog with wrong root, * it should throw CatalogException. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void validateWrongRootCatalogOnEntityResolver() { - catalogResolver(CATALOG_WRONGROOT); + assertThrows(CatalogException.class, () -> catalogResolver(CATALOG_WRONGROOT)); } /* * URIResolver tries to load catalog with wrong root, * it should throw CatalogException. */ - @Test(expectedExceptions = CatalogException.class) + @Test public void validateWrongRootCatalogOnUriResolver() { - catalogUriResolver(CATALOG_WRONGROOT); + assertThrows(CatalogException.class, () -> catalogUriResolver(CATALOG_WRONGROOT)); } /* * EntityResolver tries to load malformed catalog, * it should throw RuntimeException. */ - @Test(expectedExceptions = RuntimeException.class) + @Test public void validateMalformedCatalogOnEntityResolver() { - catalogResolver(CATALOG_MALFORMED); + assertThrows(RuntimeException.class, () -> catalogResolver(CATALOG_MALFORMED)); } /* * UriResolver tries to load malformed catalog, * it should throw RuntimeException. */ - @Test(expectedExceptions = RuntimeException.class) + @Test public void validateMalformedCatalogOnUriResolver() { - catalogUriResolver(CATALOG_MALFORMED); + assertThrows(RuntimeException.class, () -> catalogUriResolver(CATALOG_MALFORMED)); } /* diff --git a/test/jaxp/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java b/test/jaxp/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java index 6253e26d6e4..a6ab94b9d7e 100644 --- a/test/jaxp/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java +++ b/test/jaxp/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java @@ -30,12 +30,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; -import jaxp.library.JAXPTestUtilities; /* * Utilities for testing XML Catalog API. @@ -69,6 +67,9 @@ final class CatalogTestUtils { private static final String JAXP_PROPS = "jaxp.properties"; private static final String JAXP_PROPS_BAK = JAXP_PROPS + ".bak"; + private static final Path CATALOG_DIR = + Path.of(System.getProperty("test.src")).resolve("catalogFiles").normalize().toAbsolutePath(); + private CatalogTestUtils() { } /* ********** create resolver ********** */ @@ -109,19 +110,12 @@ final class CatalogTestUtils { // Gets the paths of the specified catalogs. private static URI[] getCatalogPaths(String... catalogNames) { - return catalogNames == null - ? null - : Stream.of(catalogNames).map( - catalogName -> getCatalogPath(catalogName)).collect( - Collectors.toList()).toArray(new URI[0]); + return Stream.of(catalogNames).map(CatalogTestUtils::getCatalogPath).toList().toArray(new URI[0]); } // Gets the paths of the specified catalogs. static URI getCatalogPath(String catalogName) { - return catalogName == null - ? null - : Paths.get(JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles") - + catalogName).toUri(); + return CATALOG_DIR.resolve(catalogName).toUri(); } /* ********** jaxp.properties ********** */ diff --git a/test/jaxp/javax/xml/jaxp/libs/catalog/ResolutionChecker.java b/test/jaxp/javax/xml/jaxp/libs/catalog/ResolutionChecker.java index 81013a5a7bd..1e06a353c24 100644 --- a/test/jaxp/javax/xml/jaxp/libs/catalog/ResolutionChecker.java +++ b/test/jaxp/javax/xml/jaxp/libs/catalog/ResolutionChecker.java @@ -25,12 +25,13 @@ package catalog; import javax.xml.catalog.CatalogResolver; -import org.testng.Assert; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * Utilities for checking catalog resolution. */ -class ResolutionChecker { +final class ResolutionChecker { /* ********** Checks normal resolution ********** */ @@ -38,8 +39,8 @@ class ResolutionChecker { * Checks the resolution result for specified external identifier. */ static void checkExtIdResolution(CatalogResolver resolver, - String publicId, String systemId, String matchedUri) { - Assert.assertEquals( + String publicId, String systemId, String matchedUri) { + assertEquals( resolver.resolveEntity(publicId, getNotSpecified(systemId)).getSystemId(), matchedUri); } @@ -65,8 +66,8 @@ class ResolutionChecker { * with the specified base location. */ static void checkUriResolution(CatalogResolver resolver, - String href, String base, String matchedUri) { - Assert.assertEquals(resolver.resolve(href, base).getSystemId(), + String href, String base, String matchedUri) { + assertEquals(resolver.resolve(href, base).getSystemId(), matchedUri); } @@ -106,9 +107,9 @@ class ResolutionChecker { static void expectExceptionOnExtId( CatalogResolver resolver, String publicId, String systemId, Class expectedExceptionClass) { - expectThrows(expectedExceptionClass, () -> { - resolver.resolveEntity(publicId, getNotSpecified(systemId)); - }); + assertThrows( + expectedExceptionClass, + () -> resolver.resolveEntity(publicId, getNotSpecified(systemId))); } /* @@ -140,9 +141,7 @@ class ResolutionChecker { static void expectExceptionOnUri( CatalogResolver resolver, String href, String base, Class expectedExceptionClass) { - expectThrows(expectedExceptionClass, () -> { - resolver.resolve(href, base); - }); + assertThrows(expectedExceptionClass, () -> resolver.resolve(href, base)); } /* @@ -155,31 +154,6 @@ class ResolutionChecker { expectExceptionOnUri(resolver, href, null, expectedExceptionClass); } - // The TestNG distribution in current JTREG build doesn't support - // method Assert.expectThrows(). - private static T expectThrows(Class throwableClass, - ThrowingRunnable runnable) { - try { - runnable.run(); - } catch (Throwable t) { - if (throwableClass.isInstance(t)) { - return throwableClass.cast(t); - } else { - String mismatchMessage = String.format( - "Expected %s to be thrown, but %s was thrown", - throwableClass.getSimpleName(), - t.getClass().getSimpleName()); - - throw new AssertionError(mismatchMessage, t); - } - } - - String message = String.format( - "Expected %s to be thrown, but nothing was thrown", - throwableClass.getSimpleName()); - throw new AssertionError(message); - } - /* * SystemId can never be null in XML. For publicId tests, if systemId is null, * it will be considered as not-specified instead. A non-existent systemId @@ -191,8 +165,4 @@ class ResolutionChecker { } return systemId; } - - private interface ThrowingRunnable { - void run() throws Throwable; - } }