8067170: Enable security manager on JAXP unit tests and make some improvement

8130494: [TESTBUG] 2 jaxp test cases are failing
8160216: jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java should clean up better

Reviewed-by: joehw, dfuchs, amlu
This commit is contained in:
Frank Yuan 2016-08-08 12:50:00 +08:00 committed by Frank Yuan
parent fd8a3a842d
commit 8ee163031b
465 changed files with 5252 additions and 2310 deletions

View File

@ -27,4 +27,4 @@ javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh 8147431 generic-
javax/xml/jaxp/unittest/common/TransformationWarningsTest.java 8150145 generic-all javax/xml/jaxp/unittest/common/TransformationWarningsTest.java 8150145 generic-all
javax/xml/jaxp/unittest/stream/FactoryFindTest.java 8156508 generic-all javax/xml/jaxp/unittest/common/ValidationWarningsTest.java 8150145 generic-all

View File

@ -14,6 +14,11 @@ keys=intermittent randomness
# Tests that must run in othervm mode # Tests that must run in othervm mode
othervm.dirs=javax/xml/jaxp othervm.dirs=javax/xml/jaxp
lib.dirs = /javax/xml/jaxp/libs
# Declare module dependency
modules=java.xml
# Group definitions # Group definitions
groups=TEST.groups groups=TEST.groups

View File

@ -1,12 +0,0 @@
# This file identifies root(s) of the test-ng hierarchy.
TestNG.dirs = .
lib.dirs = /javax/xml/jaxp/libs
# Tests that must run in othervm mode
othervm.dirs= /javax/xml/jaxp/functional
# Declare module dependency
modules=java.xml

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,17 +28,21 @@ import static catalog.CatalogTestUtils.catalogResolver;
import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogException;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.CatalogReferCircularityTest
* @run testng/othervm catalog.CatalogReferCircularityTest
* @summary Via nextCatalog entry, the catalog reference chain may be * @summary Via nextCatalog entry, the catalog reference chain may be
* a (partial) closed circuit. For instance, a catalog may use itself * a (partial) closed circuit. For instance, a catalog may use itself
* as an additional catalog specified in its own nextCatalog entry. * as an additional catalog specified in its own nextCatalog entry.
* This case tests if the implementation handles this issue. * This case tests if the implementation handles this issue.
* @compile ../../libs/catalog/CatalogTestUtils.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class CatalogReferCircularityTest { public class CatalogReferCircularityTest {
@Test(dataProvider = "catalogName", @Test(dataProvider = "catalogName",
@ -49,7 +53,7 @@ public class CatalogReferCircularityTest {
} }
@DataProvider(name = "catalogName") @DataProvider(name = "catalogName")
private Object[][] catalogName() { public Object[][] catalogName() {
return new Object[][] { return new Object[][] {
// This catalog defines itself as next catalog. // This catalog defines itself as next catalog.
{ "catalogReferCircle-itself.xml" }, { "catalogReferCircle-itself.xml" },
@ -60,3 +64,4 @@ public class CatalogReferCircularityTest {
{ "catalogReferCircle-left.xml" } }; { "catalogReferCircle-left.xml" } };
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,13 +29,18 @@ import javax.xml.catalog.CatalogFeatures.Feature;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.DefaultFeaturesTest
* @run testng/othervm catalog.DefaultFeaturesTest
* @summary This case tests if the default feature values are expected. * @summary This case tests if the default feature values are expected.
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class DefaultFeaturesTest { public class DefaultFeaturesTest {
private CatalogFeatures defaultFeature; private CatalogFeatures defaultFeature;
@ -56,7 +61,7 @@ public class DefaultFeaturesTest {
} }
@DataProvider(name = "feature-value") @DataProvider(name = "feature-value")
private Object[][] data() { public Object[][] data() {
return new Object[][] { return new Object[][] {
{ Feature.FILES, null }, { Feature.FILES, null },
{ Feature.PREFER, CatalogTestUtils.PREFER_PUBLIC }, { Feature.PREFER, CatalogTestUtils.PREFER_PUBLIC },
@ -64,3 +69,4 @@ public class DefaultFeaturesTest {
{ Feature.RESOLVE, CatalogTestUtils.RESOLVE_STRICT } }; { Feature.RESOLVE, CatalogTestUtils.RESOLVE_STRICT } };
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,8 @@ import static catalog.CatalogTestUtils.DEFER_TRUE;
import static catalog.CatalogTestUtils.getCatalogPath; import static catalog.CatalogTestUtils.getCatalogPath;
import static javax.xml.catalog.CatalogFeatures.Feature.DEFER; import static javax.xml.catalog.CatalogFeatures.Feature.DEFER;
import static javax.xml.catalog.CatalogManager.catalog; import static javax.xml.catalog.CatalogManager.catalog;
import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
import static jaxp.library.JAXPTestUtilities.tryRunWithAllPerm;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -36,16 +38,20 @@ import javax.xml.catalog.CatalogFeatures;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.DeferFeatureTest
* @run testng/othervm catalog.DeferFeatureTest
* @summary This case tests whether the catalogs specified in delegateSystem, * @summary This case tests whether the catalogs specified in delegateSystem,
* delegatePublic, delegateURI and nextCatalog entries are used lazily * delegatePublic, delegateURI and nextCatalog entries are used lazily
* in resolution via defer feature. * in resolution via defer feature.
* @compile ../../libs/catalog/CatalogTestUtils.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class DeferFeatureTest { public class DeferFeatureTest {
@Test(dataProvider = "catalog-countOfLoadedCatalogFile") @Test(dataProvider = "catalog-countOfLoadedCatalogFile")
@ -55,7 +61,7 @@ public class DeferFeatureTest {
} }
@DataProvider(name = "catalog-countOfLoadedCatalogFile") @DataProvider(name = "catalog-countOfLoadedCatalogFile")
private Object[][] data() { public Object[][] data() {
return new Object[][]{ return new Object[][]{
// By default, alternative catalogs are not loaded. // By default, alternative catalogs are not loaded.
{createCatalog(CatalogFeatures.defaults()), 0}, {createCatalog(CatalogFeatures.defaults()), 0},
@ -75,9 +81,9 @@ public class DeferFeatureTest {
} }
private int loadedCatalogCount(Catalog catalog) throws Exception { private int loadedCatalogCount(Catalog catalog) throws Exception {
Method method = catalog.getClass().getDeclaredMethod( Method method = tryRunWithAllPerm(() -> catalog.getClass().getDeclaredMethod("loadedCatalogCount"));
"loadedCatalogCount"); runWithAllPerm(() -> method.setAccessible(true));
method.setAccessible(true);
return (int) method.invoke(catalog); return (int) method.invoke(catalog);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,15 +31,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.DelegatePublicTest
* @run testng/othervm catalog.DelegatePublicTest
* @summary Get matched URIs from DelegatePublic entries. * @summary Get matched URIs from DelegatePublic entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class DelegatePublicTest { public class DelegatePublicTest {
@Test(dataProvider = "publicId-matchedUri") @Test(dataProvider = "publicId-matchedUri")
@ -48,7 +51,7 @@ public class DelegatePublicTest {
} }
@DataProvider(name = "publicId-matchedUri") @DataProvider(name = "publicId-matchedUri")
private Object[][] dataOnMatch() { public Object[][] dataOnMatch() {
return new Object[][] { return new Object[][] {
// The matched URI of the specified public id is defined in // The matched URI of the specified public id is defined in
// a delegate catalog file of the current catalog file. // a delegate catalog file of the current catalog file.
@ -79,7 +82,7 @@ public class DelegatePublicTest {
} }
@DataProvider(name = "publicId-expectedExceptionClass") @DataProvider(name = "publicId-expectedExceptionClass")
private Object[][] dataOnException() { public Object[][] dataOnException() {
return new Object[][] { return new Object[][] {
// The matched delegatePublic entry of the specified public id // The matched delegatePublic entry of the specified public id
// defines a non-existing delegate catalog file. That should // defines a non-existing delegate catalog file. That should
@ -97,3 +100,4 @@ public class DelegatePublicTest {
return catalogResolver("delegatePublic.xml"); return catalogResolver("delegatePublic.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,15 +31,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.DelegateSystemTest
* @run testng/othervm catalog.DelegateSystemTest
* @summary Get matched URIs from delegateSystem entries. * @summary Get matched URIs from delegateSystem entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class DelegateSystemTest { public class DelegateSystemTest {
@Test(dataProvider = "systemId-matchedUri") @Test(dataProvider = "systemId-matchedUri")
@ -48,7 +51,7 @@ public class DelegateSystemTest {
} }
@DataProvider(name = "systemId-matchedUri") @DataProvider(name = "systemId-matchedUri")
private Object[][] dataOnMatch() { public Object[][] dataOnMatch() {
return new Object[][] { return new Object[][] {
// The matched URI of the specified system id is defined in // The matched URI of the specified system id is defined in
// a delegate catalog file of the current catalog file. // a delegate catalog file of the current catalog file.
@ -79,7 +82,7 @@ public class DelegateSystemTest {
} }
@DataProvider(name = "systemId-expectedExceptionClass") @DataProvider(name = "systemId-expectedExceptionClass")
private Object[][] dataOnException() { public Object[][] dataOnException() {
return new Object[][] { return new Object[][] {
// The matched delegateSystem entry of the specified system id // The matched delegateSystem entry of the specified system id
// defines a non-existing delegate catalog file. That should // defines a non-existing delegate catalog file. That should
@ -97,3 +100,4 @@ public class DelegateSystemTest {
return catalogResolver("delegateSystem.xml"); return catalogResolver("delegateSystem.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,15 +31,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.DelegateUriTest
* @run testng/othervm catalog.DelegateUriTest
* @summary Get matched URIs from delegateURI entries. * @summary Get matched URIs from delegateURI entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class DelegateUriTest { public class DelegateUriTest {
@Test(dataProvider = "uri-matchedUri") @Test(dataProvider = "uri-matchedUri")
@ -48,7 +51,7 @@ public class DelegateUriTest {
} }
@DataProvider(name = "uri-matchedUri") @DataProvider(name = "uri-matchedUri")
private Object[][] data() { public Object[][] data() {
return new Object[][] { return new Object[][] {
// The matched URI of the specified URI reference is defined in // The matched URI of the specified URI reference is defined in
// a delegate catalog file of the current catalog file. // a delegate catalog file of the current catalog file.
@ -78,7 +81,7 @@ public class DelegateUriTest {
} }
@DataProvider(name = "uri-expectedExceptionClass") @DataProvider(name = "uri-expectedExceptionClass")
private Object[][] dataOnException() { public Object[][] dataOnException() {
return new Object[][] { return new Object[][] {
// The matched delegateURI entry of the specified URI reference // The matched delegateURI entry of the specified URI reference
// defines a non-existing delegate catalog file. That should // defines a non-existing delegate catalog file. That should
@ -96,3 +99,4 @@ public class DelegateUriTest {
return catalogUriResolver("delegateUri.xml"); return catalogUriResolver("delegateUri.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,16 +32,19 @@ import static catalog.ResolutionChecker.checkUriResolution;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.GroupTest
* @run testng/othervm catalog.GroupTest
* @summary Get matched URIs from system, public and uri entries respectively, * @summary Get matched URIs from system, public and uri entries respectively,
* and some of the entries are enclosed by group entries. * and some of the entries are enclosed by group entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class GroupTest { public class GroupTest {
private static final String CATALOG_GROUP = "group.xml"; private static final String CATALOG_GROUP = "group.xml";
@ -52,7 +55,7 @@ public class GroupTest {
} }
@DataProvider(name = "systemId-matchedUri") @DataProvider(name = "systemId-matchedUri")
private Object[][] dataOnSysId() { public Object[][] dataOnSysId() {
return new Object[][] { return new Object[][] {
// The matched URI of the specified system id is enclosed by a // The matched URI of the specified system id is enclosed by a
// group entry. // group entry.
@ -78,7 +81,7 @@ public class GroupTest {
} }
@DataProvider(name = "publicId-matchedUri") @DataProvider(name = "publicId-matchedUri")
private Object[][] dataOnPubId() { public Object[][] dataOnPubId() {
return new Object[][] { return new Object[][] {
// The matched URI of the specified public id is enclosed by a // The matched URI of the specified public id is enclosed by a
// group entry. // group entry.
@ -104,7 +107,7 @@ public class GroupTest {
} }
@DataProvider(name = "uri-matchedUri") @DataProvider(name = "uri-matchedUri")
private Object[][] dataOnUri() { public Object[][] dataOnUri() {
return new Object[][] { return new Object[][] {
// The matched URI of the specified URI reference is enclosed by // The matched URI of the specified URI reference is enclosed by
// a group entry. // a group entry.
@ -128,3 +131,4 @@ public class GroupTest {
return catalogResolver(CATALOG_GROUP); return catalogResolver(CATALOG_GROUP);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -36,17 +36,20 @@ import javax.xml.catalog.CatalogResolver;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.LoadCatalogTest
* @run testng/othervm catalog.LoadCatalogTest
* @summary When catalog resolver loads catalog files, the current catalog file * @summary When catalog resolver loads catalog files, the current catalog file
* and the catalog files specified by the nextCatalog entries may not * and the catalog files specified by the nextCatalog entries may not
* accessible. This case tests how does the resolver handle this issue. * accessible. This case tests how does the resolver handle this issue.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class LoadCatalogTest { public class LoadCatalogTest {
private static final String CATALOG_LOADCATALOGFILES = "loadCatalogFiles.xml"; private static final String CATALOG_LOADCATALOGFILES = "loadCatalogFiles.xml";
@ -62,7 +65,7 @@ public class LoadCatalogTest {
} }
@DataProvider(name = "entityResolver") @DataProvider(name = "entityResolver")
private Object[][] entityResolver() { public Object[][] entityResolver() {
return new Object[][] { return new Object[][] {
// This EntityResolver loads multiple catalog files one by one. // This EntityResolver loads multiple catalog files one by one.
// All of the files are available. // All of the files are available.
@ -82,7 +85,7 @@ public class LoadCatalogTest {
} }
@DataProvider(name = "uriResolver") @DataProvider(name = "uriResolver")
private Object[][] uriResolver() { public Object[][] uriResolver() {
return new Object[][] { return new Object[][] {
// This URIResolver loads multiple catalog files one by one. // This URIResolver loads multiple catalog files one by one.
// All of the files are available. // All of the files are available.
@ -108,7 +111,7 @@ public class LoadCatalogTest {
} }
@DataProvider(name = "catalogName") @DataProvider(name = "catalogName")
private Object[][] catalogName() { public Object[][] catalogName() {
return new Object[][] { return new Object[][] {
// This catalog file set includes null catalog files. // This catalog file set includes null catalog files.
{ (String[]) null }, { (String[]) null },
@ -118,3 +121,4 @@ public class LoadCatalogTest {
{ new String[] { CATALOG_LOADCATALOGFILES } } }; { new String[] { CATALOG_LOADCATALOGFILES } } };
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,16 +33,19 @@ import javax.xml.catalog.CatalogResolver;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.NextCatalogTest
* @run testng/othervm catalog.NextCatalogTest
* @summary Get matched URIs from system, public and uri entries respectively, * @summary Get matched URIs from system, public and uri entries respectively,
* but some of the entries are defined in none-current catalog files. * but some of the entries are defined in none-current catalog files.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class NextCatalogTest { public class NextCatalogTest {
private static final String CATALOG_NEXTCATALOGLEFT private static final String CATALOG_NEXTCATALOGLEFT
@ -56,7 +59,7 @@ public class NextCatalogTest {
} }
@DataProvider(name = "systemId-matchedUri") @DataProvider(name = "systemId-matchedUri")
private Object[][] dataOnSysId() { public Object[][] dataOnSysId() {
return new Object[][] { return new Object[][] {
// This matched URI of the specified system id is defined in a // This matched URI of the specified system id is defined in a
// next catalog file. // next catalog file.
@ -88,7 +91,7 @@ public class NextCatalogTest {
} }
@DataProvider(name = "publicId-matchedUri") @DataProvider(name = "publicId-matchedUri")
private Object[][] dataOnPubId() { public Object[][] dataOnPubId() {
return new Object[][] { return new Object[][] {
// This matched URI of the specified public id is defined in a // This matched URI of the specified public id is defined in a
// next catalog file. // next catalog file.
@ -120,7 +123,7 @@ public class NextCatalogTest {
} }
@DataProvider(name = "uri-matchedUri") @DataProvider(name = "uri-matchedUri")
private Object[][] dataOnUri() { public Object[][] dataOnUri() {
return new Object[][] { return new Object[][] {
// This matched URI of the specified URI reference is defined in // This matched URI of the specified URI reference is defined in
// a next catalog file. // a next catalog file.
@ -156,3 +159,4 @@ public class NextCatalogTest {
CATALOG_NEXTCATALOGRIGHT); CATALOG_NEXTCATALOGRIGHT);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,18 +33,21 @@ import javax.xml.catalog.CatalogResolver;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.NormalizationTest
* @run testng/othervm catalog.NormalizationTest
* @summary Before matching identifiers and URI references, it has to normalize * @summary Before matching identifiers and URI references, it has to normalize
* the passed identifiers and URI references. And then the catalog * the passed identifiers and URI references. And then the catalog
* resolver uses the normalized stuff to search the counterparts in * resolver uses the normalized stuff to search the counterparts in
* catalog files. * catalog files.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class NormalizationTest { public class NormalizationTest {
private static final String CATALOG_NORMALIZATION = "normalization.xml"; private static final String CATALOG_NORMALIZATION = "normalization.xml";
@ -65,7 +68,7 @@ public class NormalizationTest {
} }
@DataProvider(name = "systemId_uri-matchedUri") @DataProvider(name = "systemId_uri-matchedUri")
private Object[][] dataOnSysIdAndUri() { public Object[][] dataOnSysIdAndUri() {
return new Object[][] { return new Object[][] {
// The specified system id/URI reference contains spaces. And // The specified system id/URI reference contains spaces. And
// the counterparts in system/uri entries also contain spaces. // the counterparts in system/uri entries also contain spaces.
@ -87,7 +90,7 @@ public class NormalizationTest {
} }
@DataProvider(name = "publicId-matchedUri") @DataProvider(name = "publicId-matchedUri")
private Object[][] dataOnPubId() { public Object[][] dataOnPubId() {
return new Object[][] { return new Object[][] {
// The specified public id contains spaces. And the counterparts // The specified public id contains spaces. And the counterparts
// in public entry also contains spaces. // in public entry also contains spaces.
@ -112,3 +115,4 @@ public class NormalizationTest {
return catalogUriResolver(CATALOG_NORMALIZATION); return catalogUriResolver(CATALOG_NORMALIZATION);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -33,16 +33,20 @@ import javax.xml.catalog.CatalogFeatures;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.PreferFeatureTest
* @run testng/othervm catalog.PreferFeatureTest
* @summary This case tests how does the feature affect the catalog resolution, * @summary This case tests how does the feature affect the catalog resolution,
* and tests the priority between this feature and attribute prefer * and tests the priority between this feature and attribute prefer
* in catalog file. * in catalog file.
* @compile ../../libs/catalog/CatalogTestUtils.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class PreferFeatureTest { public class PreferFeatureTest {
@Test(dataProvider = "prefer-publicId-systemId", @Test(dataProvider = "prefer-publicId-systemId",
@ -53,7 +57,7 @@ public class PreferFeatureTest {
} }
@DataProvider(name = "prefer-publicId-systemId") @DataProvider(name = "prefer-publicId-systemId")
private Object[][] data() { public Object[][] data() {
return new Object[][] { return new Object[][] {
// The feature prefer is system. There's a match for the // The feature prefer is system. There's a match for the
// specified public id, and no match for the specified system id. // specified public id, and no match for the specified system id.
@ -77,3 +81,4 @@ public class PreferFeatureTest {
"preferFeature.xml"); "preferFeature.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,18 +29,21 @@ import static catalog.ResolutionChecker.checkExtIdResolution;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.PreferTest
* @run testng/othervm catalog.PreferTest
* @summary Get matched URIs from system and public family entries, which * @summary Get matched URIs from system and public family entries, which
* specify the prefer attribute. It tests how does the prefer attribute * specify the prefer attribute. It tests how does the prefer attribute
* affect the resolution procedure. The test rule is based on OASIS * affect the resolution procedure. The test rule is based on OASIS
* Standard V1.1 section 4.1.1. "The prefer attribute". * Standard V1.1 section 4.1.1. "The prefer attribute".
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class PreferTest { public class PreferTest {
@Test(dataProvider = "publicId-systemId-matchedUri") @Test(dataProvider = "publicId-systemId-matchedUri")
@ -50,7 +53,7 @@ public class PreferTest {
} }
@DataProvider(name = "publicId-systemId-matchedUri") @DataProvider(name = "publicId-systemId-matchedUri")
private Object[][] data() { public Object[][] data() {
return new Object[][] { return new Object[][] {
// The prefer attribute is public. Both of the specified public // The prefer attribute is public. Both of the specified public
// id and system id have matches in the catalog file. But // id and system id have matches in the catalog file. But
@ -89,3 +92,4 @@ public class PreferTest {
return catalogResolver("prefer.xml"); return catalogResolver("prefer.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,18 +30,21 @@ import static catalog.ResolutionChecker.checkPubIdResolution;
import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.PublicFamilyTest
* @run testng/othervm catalog.PublicFamilyTest
* @summary Get matched URIs from public and delegatePublic entries. * @summary Get matched URIs from public and delegatePublic entries.
* It tests the resolution priorities among the public family 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. * The test rule is based on OASIS Standard V1.1 section 7.1.2.
* "Resolution of External Identifiers". * "Resolution of External Identifiers".
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class PublicFamilyTest { public class PublicFamilyTest {
/* /*
@ -67,3 +70,4 @@ public class PublicFamilyTest {
return catalogResolver("publicFamily.xml"); return catalogResolver("publicFamily.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,15 +32,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.PublicTest
* @run testng/othervm catalog.PublicTest
* @summary Get matched URIs from public entries. * @summary Get matched URIs from public entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class PublicTest { public class PublicTest {
@Test(dataProvider = "publicId-matchedUri") @Test(dataProvider = "publicId-matchedUri")
@ -89,3 +92,4 @@ public class PublicTest {
return catalogResolver(CATALOG_PUBLIC); return catalogResolver(CATALOG_PUBLIC);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,16 +40,19 @@ import javax.xml.catalog.CatalogFeatures.Feature;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.ResolveFeatureTest
* @run testng/othervm catalog.ResolveFeatureTest
* @summary This case tests how does resolve feature affect the catalog * @summary This case tests how does resolve feature affect the catalog
* resolution. * resolution.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class ResolveFeatureTest { public class ResolveFeatureTest {
/* /*
@ -128,3 +131,4 @@ public class ResolveFeatureTest {
return builder().with(Feature.RESOLVE, resolve).build(); return builder().with(Feature.RESOLVE, resolve).build();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,15 +31,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.RewriteSystemTest
* @run testng/othervm catalog.RewriteSystemTest
* @summary Get matched URIs from rewriteSystem entries. * @summary Get matched URIs from rewriteSystem entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class RewriteSystemTest { public class RewriteSystemTest {
@Test(dataProvider = "systemId-matchedUri") @Test(dataProvider = "systemId-matchedUri")
@ -92,3 +95,4 @@ public class RewriteSystemTest {
return catalogResolver("rewriteSystem.xml"); return catalogResolver("rewriteSystem.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,15 +31,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.RewriteUriTest
* @run testng/othervm catalog.RewriteUriTest
* @summary Get matched URIs from rewriteURI entries. * @summary Get matched URIs from rewriteURI entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class RewriteUriTest { public class RewriteUriTest {
@Test(dataProvider = "uri-matchedUri") @Test(dataProvider = "uri-matchedUri")
@ -92,3 +95,4 @@ public class RewriteUriTest {
return catalogUriResolver("rewriteUri.xml"); return catalogUriResolver("rewriteUri.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,8 @@
package catalog; package catalog;
import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import static catalog.CatalogTestUtils.FEATURE_FILES; import static catalog.CatalogTestUtils.FEATURE_FILES;
import static catalog.CatalogTestUtils.catalogResolver; import static catalog.CatalogTestUtils.catalogResolver;
import static catalog.CatalogTestUtils.catalogUriResolver; import static catalog.CatalogTestUtils.catalogUriResolver;
@ -36,15 +38,18 @@ import javax.xml.catalog.CatalogFeatures;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.SpecifyCatalogTest
* @run testng/othervm catalog.SpecifyCatalogTest
* @summary This case tests how to specify the catalog files. * @summary This case tests how to specify the catalog files.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class SpecifyCatalogTest { public class SpecifyCatalogTest {
private static final String ID_URI = "http://remote/dtd/uri/doc.dtd"; private static final String ID_URI = "http://remote/dtd/uri/doc.dtd";
@ -76,7 +81,7 @@ public class SpecifyCatalogTest {
*/ */
@Test @Test
public void specifyCatalogViaSysProps() { public void specifyCatalogViaSysProps() {
System.setProperty(FEATURE_FILES, setSystemProperty(FEATURE_FILES,
getCatalogPath("specifyCatalog-sysProps.xml")); getCatalogPath("specifyCatalog-sysProps.xml"));
checkResolutionOnEntityResolver(catalogResolver((String[]) null), checkResolutionOnEntityResolver(catalogResolver((String[]) null),
@ -106,3 +111,4 @@ public class SpecifyCatalogTest {
return builder().with(FILES, getCatalogPath(catalogName)).build(); return builder().with(FILES, getCatalogPath(catalogName)).build();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,18 +31,21 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.SystemFamilyTest
* @run testng/othervm catalog.SystemFamilyTest
* @summary Get matched URIs from system, rewriteSystem, systemSuffix and * @summary Get matched URIs from system, rewriteSystem, systemSuffix and
* delegateSystem entries. It tests the resolution priorities among * delegateSystem entries. It tests the resolution priorities among
* the system family entries. The test rule is based on OASIS * the system family entries. The test rule is based on OASIS
* Standard V1.1 section 7.1.2. "Resolution of External Identifiers". * Standard V1.1 section 7.1.2. "Resolution of External Identifiers".
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class SystemFamilyTest { public class SystemFamilyTest {
@Test(dataProvider = "systemId-matchedUri") @Test(dataProvider = "systemId-matchedUri")
@ -81,3 +84,4 @@ public class SystemFamilyTest {
return catalogResolver("systemFamily.xml"); return catalogResolver("systemFamily.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,15 +31,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.SystemSuffixTest
* @run testng/othervm catalog.SystemSuffixTest
* @summary Get matched URIs from systemSuffix entries. * @summary Get matched URIs from systemSuffix entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class SystemSuffixTest { public class SystemSuffixTest {
@Test(dataProvider = "systemId-matchedUri") @Test(dataProvider = "systemId-matchedUri")
@ -92,3 +95,4 @@ public class SystemSuffixTest {
return catalogResolver("systemSuffix.xml"); return catalogResolver("systemSuffix.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,15 +32,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.SystemTest
* @run testng/othervm catalog.SystemTest
* @summary Get matched URIs from system entries. * @summary Get matched URIs from system entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class SystemTest { public class SystemTest {
@Test(dataProvider = "systemId-matchedUri") @Test(dataProvider = "systemId-matchedUri")
@ -89,3 +92,4 @@ public class SystemTest {
return catalogResolver(CATALOG_SYSTEM); return catalogResolver(CATALOG_SYSTEM);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,18 +31,21 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.UriFamilyTest
* @run testng/othervm catalog.UriFamilyTest
* @summary Get matched URIs from uri, rewriteURI, uriSuffix and delegateURI * @summary Get matched URIs from uri, rewriteURI, uriSuffix and delegateURI
* entries. It tests the resolution priorities among the uri family * entries. It tests the resolution priorities among the uri family
* entries. The test rule is based on OASIS Standard V1.1 section * entries. The test rule is based on OASIS Standard V1.1 section
* 7.2.2. "Resolution of External Identifiers". * 7.2.2. "Resolution of External Identifiers".
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class UriFamilyTest { public class UriFamilyTest {
@Test(dataProvider = "uri-matchedUri") @Test(dataProvider = "uri-matchedUri")
@ -81,3 +84,4 @@ public class UriFamilyTest {
return catalogUriResolver("uriFamily.xml"); return catalogUriResolver("uriFamily.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,15 +31,18 @@ import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.UriSuffixTest
* @run testng/othervm catalog.UriSuffixTest
* @summary Get matched URIs from rewriteURI entries. * @summary Get matched URIs from rewriteURI entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class UriSuffixTest { public class UriSuffixTest {
@Test(dataProvider = "uri-matchedUri") @Test(dataProvider = "uri-matchedUri")
@ -92,3 +95,4 @@ public class UriSuffixTest {
return catalogUriResolver("uriSuffix.xml"); return catalogUriResolver("uriSuffix.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,15 +34,18 @@ import javax.xml.catalog.CatalogFeatures;
import javax.xml.catalog.CatalogUriResolver; import javax.xml.catalog.CatalogUriResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.UriTest
* @run testng/othervm catalog.UriTest
* @summary Get matched URIs from uri entries. * @summary Get matched URIs from uri entries.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class UriTest { public class UriTest {
@Test(dataProvider = "uri-matchedUri") @Test(dataProvider = "uri-matchedUri")
@ -101,3 +104,4 @@ public class UriTest {
return catalogUriResolver(CATALOG_URI); return catalogUriResolver(CATALOG_URI);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,17 +29,20 @@ import static catalog.ResolutionChecker.checkPubIdResolution;
import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogResolver;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.UrnUnwrappingTest
* @run testng/othervm catalog.UrnUnwrappingTest
* @summary If the passed public identifier is started with "urn:publicid:", * @summary If the passed public identifier is started with "urn:publicid:",
* it has to be regarded as URN and normalized. And then the catalog * it has to be regarded as URN and normalized. And then the catalog
* resolver uses the normalized stuff to do matching. * resolver uses the normalized stuff to do matching.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class UrnUnwrappingTest { public class UrnUnwrappingTest {
@Test(dataProvider = "urn-matchedUri") @Test(dataProvider = "urn-matchedUri")
@ -48,7 +51,7 @@ public class UrnUnwrappingTest {
} }
@DataProvider(name = "urn-matchedUri") @DataProvider(name = "urn-matchedUri")
private Object[][] data() { public Object[][] data() {
return new Object[][] { return new Object[][] {
// The specified public id is URN format. // The specified public id is URN format.
{ "urn:publicid:-:REMOTE:DTD+ALICE+DOCALICE+XML:EN", { "urn:publicid:-:REMOTE:DTD+ALICE+DOCALICE+XML:EN",
@ -64,3 +67,4 @@ public class UrnUnwrappingTest {
return catalogResolver("urnUnwrapping.xml"); return catalogResolver("urnUnwrapping.xml");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,17 +32,20 @@ import static catalog.ResolutionChecker.checkUriResolution;
import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogException;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test * @test
* @bug 8077931 * @bug 8077931
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true catalog.ValidateCatalogTest
* @run testng/othervm catalog.ValidateCatalogTest
* @summary A legal catalog file must be well-formed XML, the root element * @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 * must be catalog, and the naming space of the root element must be
* urn:oasis:names:tc:entity:xmlns:xml:catalog. * urn:oasis:names:tc:entity:xmlns:xml:catalog.
* @compile ../../libs/catalog/CatalogTestUtils.java
* @compile ../../libs/catalog/ResolutionChecker.java
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class ValidateCatalogTest { public class ValidateCatalogTest {
private static final String CATALOG_WRONGROOT = "validateCatalog-wrongRoot.xml"; private static final String CATALOG_WRONGROOT = "validateCatalog-wrongRoot.xml";
@ -99,3 +102,4 @@ public class ValidateCatalogTest {
"http://local/dtd/docAliceURI.dtd"); "http://local/dtd/docAliceURI.dtd");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -44,17 +44,21 @@ import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration; import javax.xml.datatype.Duration;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import jaxp.library.JAXPBaseTest;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.datatype.ptests.DurationTest
* @run testng/othervm javax.xml.datatype.ptests.DurationTest
* @summary Class containing the test cases for Duration. * @summary Class containing the test cases for Duration.
*/ */
public class DurationTest extends JAXPBaseTest { @Listeners({jaxp.library.BasePolicy.class})
public class DurationTest {
private DatatypeFactory datatypeFactory; private DatatypeFactory datatypeFactory;
@ -583,3 +587,4 @@ public class DurationTest extends JAXPBaseTest {
private final BigInteger one = BigInteger.ONE; private final BigInteger one = BigInteger.ONE;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,15 +30,20 @@ import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration; import javax.xml.datatype.Duration;
import jaxp.library.JAXPDataProvider; import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.datatype.ptests.FactoryNewInstanceTest
* @run testng/othervm javax.xml.datatype.ptests.FactoryNewInstanceTest
* @summary Tests for DatatypeFactory.newInstance(factoryClassName , classLoader) * @summary Tests for DatatypeFactory.newInstance(factoryClassName , classLoader)
*/ */
public class FactoryNewInstanceTest extends JAXPBaseTest { @Listeners({jaxp.library.BasePolicy.class})
public class FactoryNewInstanceTest {
private static final String DATATYPE_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"; private static final String DATATYPE_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl";
@ -72,3 +77,4 @@ public class FactoryNewInstanceTest extends JAXPBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -39,18 +39,22 @@ import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration; import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;
import jaxp.library.JAXPBaseTest;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test
* @bug 5049592 5041845 5048932 5064587 5040542 5049531 5049528 * @bug 5049592 5041845 5048932 5064587 5040542 5049531 5049528
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.datatype.ptests.XMLGregorianCalendarTest
* @run testng/othervm javax.xml.datatype.ptests.XMLGregorianCalendarTest
* @summary Class containing the test cases for XMLGregorianCalendar * @summary Class containing the test cases for XMLGregorianCalendar
*/ */
public class XMLGregorianCalendarTest extends JAXPBaseTest { @Listeners({jaxp.library.BasePolicy.class})
public class XMLGregorianCalendarTest {
private DatatypeFactory datatypeFactory; private DatatypeFactory datatypeFactory;
@ -354,3 +358,4 @@ public class XMLGregorianCalendarTest extends JAXPBaseTest {
private final int undef = DatatypeConstants.FIELD_UNDEFINED; private final int undef = DatatypeConstants.FIELD_UNDEFINED;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,18 +23,21 @@
package javax.xml.parsers.ptests; package javax.xml.parsers.ptests;
import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.io.File; import java.io.File;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.SAXResult;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -42,7 +45,14 @@ import org.w3c.dom.Document;
* This tests DocumentBuilderFactory for namespace processing and no-namespace * This tests DocumentBuilderFactory for namespace processing and no-namespace
* processing. * processing.
*/ */
public class DBFNamespaceTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.DBFNamespaceTest
* @run testng/othervm javax.xml.parsers.ptests.DBFNamespaceTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class DBFNamespaceTest {
/** /**
* Provide input for the cases that supporting namespace or not. * Provide input for the cases that supporting namespace or not.
@ -95,3 +105,5 @@ public class DBFNamespaceTest extends JAXPFileBaseTest {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,6 @@ import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FilePermission;
import java.io.FileReader; import java.io.FileReader;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -55,9 +54,9 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.SAXResult;
import jaxp.library.JAXPDataProvider; import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -70,7 +69,14 @@ import org.xml.sax.helpers.DefaultHandler;
* @bug 8080907 * @bug 8080907
* This checks the methods of DocumentBuilderFactoryImpl. * This checks the methods of DocumentBuilderFactoryImpl.
*/ */
public class DocumentBuilderFactoryTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.DocumentBuilderFactoryTest
* @run testng/othervm javax.xml.parsers.ptests.DocumentBuilderFactoryTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class DocumentBuilderFactoryTest {
/** /**
* DocumentBuilderFactory implementation class name. * DocumentBuilderFactory implementation class name.
*/ */
@ -419,8 +425,6 @@ public class DocumentBuilderFactoryTest extends JAXPFileBaseTest {
@Test @Test
public void testCheckDocumentBuilderFactory13() throws Exception { public void testCheckDocumentBuilderFactory13() throws Exception {
// Accesing default working directory. // Accesing default working directory.
String workingDir = getSystemProperty("user.dir");
setPermissions(new FilePermission(workingDir + "/*", "read"));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbf.newDocumentBuilder(); DocumentBuilder docBuilder = dbf.newDocumentBuilder();
Document doc = docBuilder.parse(new File(XML_DIR + "dbf10import.xsl") Document doc = docBuilder.parse(new File(XML_DIR + "dbf10import.xsl")
@ -436,8 +440,6 @@ public class DocumentBuilderFactoryTest extends JAXPFileBaseTest {
@Test(expectedExceptions = SAXException.class) @Test(expectedExceptions = SAXException.class)
public void testCheckDocumentBuilderFactory14() throws Exception { public void testCheckDocumentBuilderFactory14() throws Exception {
// Accesing default working directory. // Accesing default working directory.
String workingDir = getSystemProperty("user.dir");
setPermissions(new FilePermission(workingDir, "read"));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbf.newDocumentBuilder(); DocumentBuilder docBuilder = dbf.newDocumentBuilder();
docBuilder.parse(""); docBuilder.parse("");
@ -529,3 +531,5 @@ public class DocumentBuilderFactoryTest extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,18 +23,21 @@
package javax.xml.parsers.ptests; package javax.xml.parsers.ptests;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
import static jaxp.library.JAXPTestUtilities.FILE_SEP; import static jaxp.library.JAXPTestUtilities.FILE_SEP;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FilePermission; import java.io.FilePermission;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.assertNotNull;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -42,8 +45,14 @@ import org.xml.sax.InputSource;
/** /**
* This checks for the methods of DocumentBuilder * This checks for the methods of DocumentBuilder
*/ */
public class DocumentBuilderImpl01 extends JAXPFileReadOnlyBaseTest /*
implements EntityResolver { * @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.DocumentBuilderImpl01
* @run testng/othervm javax.xml.parsers.ptests.DocumentBuilderImpl01
*/
@Listeners({jaxp.library.FilePolicy.class})
public class DocumentBuilderImpl01 implements EntityResolver {
/** /**
* Provide DocumentBuilder. * Provide DocumentBuilder.
* *
@ -82,7 +91,7 @@ public class DocumentBuilderImpl01 extends JAXPFileReadOnlyBaseTest
* @param docBuilder document builder instance. * @param docBuilder document builder instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "builder-provider") @Test(dataProvider = "builder-provider")
public void testCheckDocumentBuilderImpl04(DocumentBuilder docBuilder) public void testCheckDocumentBuilderImpl04(DocumentBuilder docBuilder)
throws Exception { throws Exception {
try (FileInputStream fis = new FileInputStream(new File(XML_DIR, try (FileInputStream fis = new FileInputStream(new File(XML_DIR,
@ -97,7 +106,7 @@ public class DocumentBuilderImpl01 extends JAXPFileReadOnlyBaseTest
* @param docBuilder document builder instance. * @param docBuilder document builder instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "builder-provider") @Test(dataProvider = "builder-provider")
public void testCheckDocumentBuilderImpl05(DocumentBuilder docBuilder) public void testCheckDocumentBuilderImpl05(DocumentBuilder docBuilder)
throws Exception { throws Exception {
assertNotNull(docBuilder.parse(new File(XML_DIR, assertNotNull(docBuilder.parse(new File(XML_DIR,
@ -109,11 +118,9 @@ public class DocumentBuilderImpl01 extends JAXPFileReadOnlyBaseTest
* @param docBuilder document builder instance. * @param docBuilder document builder instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "builder-provider") @Test(dataProvider = "builder-provider")
public void testCheckDocumentBuilderImpl06(DocumentBuilder docBuilder) public void testCheckDocumentBuilderImpl06(DocumentBuilder docBuilder)
throws Exception { throws Exception {
setPermissions(new FilePermission(XML_DIR + "../-",
"read"));
try (FileInputStream fis = new FileInputStream(new File(XML_DIR, try (FileInputStream fis = new FileInputStream(new File(XML_DIR,
"DocumentBuilderImpl02.xml"))) { "DocumentBuilderImpl02.xml"))) {
assertNotNull(docBuilder.parse(fis, new File(XML_DIR).toURI() assertNotNull(docBuilder.parse(fis, new File(XML_DIR).toURI()
@ -150,3 +157,5 @@ public class DocumentBuilderImpl01 extends JAXPFileReadOnlyBaseTest
return null; return null;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,20 +23,30 @@
package javax.xml.parsers.ptests; package javax.xml.parsers.ptests;
import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPBaseTest;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Class containing the test cases for SAXParserFactory/DocumentBuilderFactory * Class containing the test cases for SAXParserFactory/DocumentBuilderFactory
* newInstance methods. * newInstance methods.
*/ */
public class FactoryConfErrorTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.FactoryConfErrorTest
* @run testng/othervm javax.xml.parsers.ptests.FactoryConfErrorTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class FactoryConfErrorTest {
/** /**
* Set properties DocumentBuilderFactory and SAXParserFactory to invalid * Set properties DocumentBuilderFactory and SAXParserFactory to invalid
@ -54,8 +64,8 @@ public class FactoryConfErrorTest extends JAXPBaseTest {
*/ */
@AfterTest @AfterTest
public void cleanup() { public void cleanup() {
setSystemProperty("javax.xml.parsers.DocumentBuilderFactory", null); clearSystemProperty("javax.xml.parsers.DocumentBuilderFactory");
setSystemProperty("javax.xml.parsers.SAXParserFactory", null); clearSystemProperty("javax.xml.parsers.SAXParserFactory");
} }
/** /**
@ -76,3 +86,5 @@ public class FactoryConfErrorTest extends JAXPBaseTest {
DocumentBuilderFactory.newInstance(); DocumentBuilderFactory.newInstance();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,16 +31,21 @@ import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPDataProvider; import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.SAXFactoryNewInstanceTest
* @run testng/othervm javax.xml.parsers.ptests.SAXFactoryNewInstanceTest
* @summary Tests for SAXParserFactory.newInstance(factoryClassName , classLoader) * @summary Tests for SAXParserFactory.newInstance(factoryClassName , classLoader)
*/ */
public class SAXFactoryNewInstanceTest extends JAXPBaseTest { @Listeners({jaxp.library.BasePolicy.class})
public class SAXFactoryNewInstanceTest {
private static final String SAXPARSER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"; private static final String SAXPARSER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
@ -73,3 +78,5 @@ public class SAXFactoryNewInstanceTest extends JAXPBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,14 +24,23 @@
package javax.xml.parsers.ptests; package javax.xml.parsers.ptests;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPBaseTest;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Class containing the test cases for SAXParserFactory API. * Class containing the test cases for SAXParserFactory API.
*/ */
public class SAXParserFactTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.SAXParserFactTest
* @run testng/othervm javax.xml.parsers.ptests.SAXParserFactTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class SAXParserFactTest {
private static final String NAMESPACES = "http://xml.org/sax/features/namespaces"; private static final String NAMESPACES = "http://xml.org/sax/features/namespaces";
private static final String NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes"; private static final String NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes";
@ -220,3 +229,5 @@ public class SAXParserFactTest extends JAXPBaseTest {
assertFalse(spf.getFeature(EXTERNAL_P_ENTITIES)); assertFalse(spf.getFeature(EXTERNAL_P_ENTITIES));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,15 +23,23 @@
package javax.xml.parsers.ptests; package javax.xml.parsers.ptests;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FilePermission; import java.io.FilePermission;
import java.io.IOException; import java.io.IOException;
import java.util.PropertyPermission;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
import jaxp.library.JAXPFileReadOnlyBaseTest; import jaxp.library.JAXPTestUtilities;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.HandlerBase; import org.xml.sax.HandlerBase;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -41,7 +49,14 @@ import org.xml.sax.helpers.DefaultHandler;
/** /**
* Class contains the test cases for SAXParser API * Class contains the test cases for SAXParser API
*/ */
public class SAXParserTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.SAXParserTest
* @run testng/othervm javax.xml.parsers.ptests.SAXParserTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class SAXParserTest {
/** /**
* Provide SAXParser. * Provide SAXParser.
* *
@ -92,13 +107,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
@Test(expectedExceptions = { SAXException.class }, @Test(expectedExceptions = { SAXException.class },
dataProvider = "parser-provider") dataProvider = "parser-provider")
public void testParse03(SAXParser saxparser) throws Exception { public void testParse03(SAXParser saxparser) throws Exception {
String workingDir = getSystemProperty("user.dir"); saxparser.parse("", new HandlerBase());
setPermissions(new FilePermission(workingDir, "read"));
try {
saxparser.parse("", new HandlerBase());
} finally {
setPermissions();
}
} }
/** /**
@ -124,13 +133,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
*/ */
@Test(expectedExceptions = SAXException.class, dataProvider = "parser-provider") @Test(expectedExceptions = SAXException.class, dataProvider = "parser-provider")
public void testParse05(SAXParser saxparser) throws Exception { public void testParse05(SAXParser saxparser) throws Exception {
String workingDir = getSystemProperty("user.dir"); tryRunWithTmpPermission(() -> saxparser.parse(new File(""), new HandlerBase()), new PropertyPermission("user.dir", "read"));
setPermissions(new FilePermission(workingDir, "read"));
try {
saxparser.parse(new File(""), new HandlerBase());
} finally {
setPermissions();
}
} }
/** /**
@ -176,23 +179,18 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
} }
/** /**
* Test with non-existence URI, parsing should fail and throw * Test with non-existence URI, parsing should fail and throw SAXException
* SAXException or IOException. * or IOException.
* *
* @param saxparser a SAXParser instance. * @param saxparser
* @throws Exception If any errors occur. * a SAXParser instance.
* @throws Exception
* If any errors occur.
*/ */
@Test(expectedExceptions = { SAXException.class, IOException.class }, @Test(expectedExceptions = { SAXException.class, IOException.class }, dataProvider = "parser-provider")
dataProvider = "parser-provider")
public void testParse09(SAXParser saxparser) throws Exception { public void testParse09(SAXParser saxparser) throws Exception {
String workingDir = getSystemProperty("user.dir"); JAXPTestUtilities.tryRunWithTmpPermission(() -> saxparser.parse(" ", new DefaultHandler()),
setPermissions(new FilePermission(workingDir + "/../-", "read")); new FilePermission(USER_DIR + " ", "read"));
String uri = " ";
try {
saxparser.parse(uri, new DefaultHandler());
} finally {
setPermissions();
}
} }
/** /**
@ -204,14 +202,8 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
*/ */
@Test(expectedExceptions = SAXException.class, dataProvider = "parser-provider") @Test(expectedExceptions = SAXException.class, dataProvider = "parser-provider")
public void testParse10(SAXParser saxparser) throws Exception { public void testParse10(SAXParser saxparser) throws Exception {
String workingDir = getSystemProperty("user.dir");
setPermissions(new FilePermission(workingDir, "read"));
File file = new File(""); File file = new File("");
try { tryRunWithTmpPermission(() -> saxparser.parse(file, new DefaultHandler()), new PropertyPermission("user.dir", "read"));
saxparser.parse(file, new DefaultHandler());
} finally {
setPermissions();
}
} }
/** /**
@ -248,7 +240,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class, @Test(expectedExceptions = SAXException.class,
dataProvider = "parser-provider") dataProvider = "parser-provider")
public void testParse13(SAXParser saxparser) throws Exception { public void testParse13(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream(new File( try (FileInputStream instream = new FileInputStream(new File(
@ -263,7 +255,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse14(SAXParser saxparser) throws Exception { public void testParse14(SAXParser saxparser) throws Exception {
saxparser.parse(new File(XML_DIR, "parsertest.xml"), saxparser.parse(new File(XML_DIR, "parsertest.xml"),
new HandlerBase()); new HandlerBase());
@ -276,7 +268,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse15(SAXParser saxparser) throws Exception { public void testParse15(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream(new File(XML_DIR, try (FileInputStream instream = new FileInputStream(new File(XML_DIR,
"correct.xml"))) { "correct.xml"))) {
@ -291,7 +283,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse16(SAXParser saxparser) throws Exception { public void testParse16(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream( try (FileInputStream instream = new FileInputStream(
new File(XML_DIR, "parsertest.xml"))) { new File(XML_DIR, "parsertest.xml"))) {
@ -306,7 +298,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse17(SAXParser saxparser) throws Exception { public void testParse17(SAXParser saxparser) throws Exception {
File file = new File(XML_DIR, "correct.xml"); File file = new File(XML_DIR, "correct.xml");
saxparser.parse(file.toURI().toASCIIString(), new HandlerBase()); saxparser.parse(file.toURI().toASCIIString(), new HandlerBase());
@ -319,7 +311,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class, @Test(expectedExceptions = SAXException.class,
dataProvider = "parser-provider") dataProvider = "parser-provider")
public void testParse18(SAXParser saxparser) throws Exception { public void testParse18(SAXParser saxparser) throws Exception {
saxparser.parse(new File(XML_DIR, "valid.xml"), new HandlerBase()); saxparser.parse(new File(XML_DIR, "valid.xml"), new HandlerBase());
@ -332,7 +324,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse19(SAXParser saxparser) throws Exception { public void testParse19(SAXParser saxparser) throws Exception {
saxparser.parse(new File(XML_DIR, "correct.xml"), new HandlerBase()); saxparser.parse(new File(XML_DIR, "correct.xml"), new HandlerBase());
} }
@ -344,7 +336,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class, @Test(expectedExceptions = SAXException.class,
dataProvider = "parser-provider") dataProvider = "parser-provider")
public void testParse20(SAXParser saxparser) throws Exception { public void testParse20(SAXParser saxparser) throws Exception {
try(FileInputStream instream = new FileInputStream(new File(XML_DIR, try(FileInputStream instream = new FileInputStream(new File(XML_DIR,
@ -360,7 +352,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse21(SAXParser saxparser) throws Exception { public void testParse21(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream(new File(XML_DIR, try (FileInputStream instream = new FileInputStream(new File(XML_DIR,
"correct.xml"))) { "correct.xml"))) {
@ -375,7 +367,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class, @Test(expectedExceptions = SAXException.class,
dataProvider = "parser-provider") dataProvider = "parser-provider")
public void testParse22(SAXParser saxparser) throws Exception { public void testParse22(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream( try (FileInputStream instream = new FileInputStream(
@ -391,7 +383,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse23(SAXParser saxparser) throws Exception { public void testParse23(SAXParser saxparser) throws Exception {
DefaultHandler handler = new DefaultHandler(); DefaultHandler handler = new DefaultHandler();
saxparser.parse(new File(XML_DIR, "parsertest.xml"), handler); saxparser.parse(new File(XML_DIR, "parsertest.xml"), handler);
@ -404,7 +396,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse24(SAXParser saxparser) throws Exception { public void testParse24(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream(new File(XML_DIR, try (FileInputStream instream = new FileInputStream(new File(XML_DIR,
"correct.xml"))) { "correct.xml"))) {
@ -420,7 +412,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse25(SAXParser saxparser) throws Exception { public void testParse25(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream( try (FileInputStream instream = new FileInputStream(
new File(XML_DIR, "parsertest.xml"))) { new File(XML_DIR, "parsertest.xml"))) {
@ -435,7 +427,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse26(SAXParser saxparser) throws Exception { public void testParse26(SAXParser saxparser) throws Exception {
File file = new File(XML_DIR, "correct.xml"); File file = new File(XML_DIR, "correct.xml");
saxparser.parse(file.toURI().toASCIIString(), new DefaultHandler()); saxparser.parse(file.toURI().toASCIIString(), new DefaultHandler());
@ -448,7 +440,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class, @Test(expectedExceptions = SAXException.class,
dataProvider = "parser-provider") dataProvider = "parser-provider")
public void testParse27(SAXParser saxparser) throws Exception { public void testParse27(SAXParser saxparser) throws Exception {
saxparser.parse(new File(XML_DIR, "valid.xml"), new DefaultHandler()); saxparser.parse(new File(XML_DIR, "valid.xml"), new DefaultHandler());
@ -461,7 +453,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse28(SAXParser saxparser) throws Exception { public void testParse28(SAXParser saxparser) throws Exception {
saxparser.parse(new File(XML_DIR, "correct.xml"), new DefaultHandler()); saxparser.parse(new File(XML_DIR, "correct.xml"), new DefaultHandler());
} }
@ -472,7 +464,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class, @Test(expectedExceptions = SAXException.class,
dataProvider = "parser-provider") dataProvider = "parser-provider")
public void testParse29(SAXParser saxparser) throws Exception { public void testParse29(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream( try (FileInputStream instream = new FileInputStream(
@ -487,7 +479,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* @param saxparser a SAXParser instance. * @param saxparser a SAXParser instance.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider") @Test(dataProvider = "parser-provider")
public void testParse30(SAXParser saxparser) throws Exception { public void testParse30(SAXParser saxparser) throws Exception {
try (FileInputStream instream = new FileInputStream( try (FileInputStream instream = new FileInputStream(
new File(XML_DIR, "correct.xml"))) { new File(XML_DIR, "correct.xml"))) {
@ -500,7 +492,7 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testParse31() throws Exception { public void testParse31() throws Exception {
try (FileInputStream instream = new FileInputStream( try (FileInputStream instream = new FileInputStream(
new File(XML_DIR, "ns4.xml"))) { new File(XML_DIR, "ns4.xml"))) {
@ -510,3 +502,5 @@ public class SAXParserTest extends JAXPFileReadOnlyBaseTest {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,13 +24,15 @@
package javax.xml.parsers.ptests; package javax.xml.parsers.ptests;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertNotNull;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXNotSupportedException; import org.xml.sax.SAXNotSupportedException;
@ -40,7 +42,14 @@ import org.xml.sax.ext.LexicalHandler;
/** /**
* Class contains the test cases for SAXParser API * Class contains the test cases for SAXParser API
*/ */
public class SAXParserTest02 extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.SAXParserTest02
* @run testng/othervm javax.xml.parsers.ptests.SAXParserTest02
*/
@Listeners({jaxp.library.BasePolicy.class})
public class SAXParserTest02 {
private static final String DOM_NODE = "http://xml.org/sax/properties/dom-node"; private static final String DOM_NODE = "http://xml.org/sax/properties/dom-node";
private static final String XML_STRING = "http://xml.org/sax/properties/xml-string"; private static final String XML_STRING = "http://xml.org/sax/properties/xml-string";
private static final String DECL_HANDLER = "http://xml.org/sax/properties/declaration-handler"; private static final String DECL_HANDLER = "http://xml.org/sax/properties/declaration-handler";
@ -260,3 +269,5 @@ public class SAXParserTest02 extends JAXPBaseTest {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,25 +23,32 @@
package javax.xml.parsers.ptests; package javax.xml.parsers.ptests;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File; import java.io.File;
import java.io.FilePermission;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.fail;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* Class contains the test cases for SAXParser API * Class contains the test cases for SAXParser API
*/ */
public class SAXParserTest03 extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.SAXParserTest03
* @run testng/othervm javax.xml.parsers.ptests.SAXParserTest03
*/
@Listeners({jaxp.library.FilePolicy.class})
public class SAXParserTest03 {
/** /**
* Provide SAXParserFactory. * Provide SAXParserFactory.
@ -63,7 +70,7 @@ public class SAXParserTest03 extends JAXPFileReadOnlyBaseTest {
* @param handler an error handler for capturing events. * @param handler an error handler for capturing events.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "input-provider") @Test(dataProvider = "input-provider")
public void testParseValidate01(SAXParserFactory spf, MyErrorHandler handler) public void testParseValidate01(SAXParserFactory spf, MyErrorHandler handler)
throws Exception { throws Exception {
spf.newSAXParser().parse(new File(XML_DIR, "parsertest.xml"), handler); spf.newSAXParser().parse(new File(XML_DIR, "parsertest.xml"), handler);
@ -78,7 +85,7 @@ public class SAXParserTest03 extends JAXPFileReadOnlyBaseTest {
* @param handler an error handler for capturing events. * @param handler an error handler for capturing events.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "input-provider") @Test(dataProvider = "input-provider")
public void testParseValidate02(SAXParserFactory spf, MyErrorHandler handler) public void testParseValidate02(SAXParserFactory spf, MyErrorHandler handler)
throws Exception { throws Exception {
spf.setNamespaceAware(true); spf.setNamespaceAware(true);
@ -95,7 +102,7 @@ public class SAXParserTest03 extends JAXPFileReadOnlyBaseTest {
* @param handler an error handler for capturing events. * @param handler an error handler for capturing events.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, dataProvider = "input-provider") @Test(dataProvider = "input-provider")
public void testParseValidate03(SAXParserFactory spf, MyErrorHandler handler) public void testParseValidate03(SAXParserFactory spf, MyErrorHandler handler)
throws Exception { throws Exception {
try { try {
@ -109,3 +116,5 @@ public class SAXParserTest03 extends JAXPFileReadOnlyBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,20 +23,28 @@
package javax.xml.stream.ptests; package javax.xml.stream.ptests;
import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import javax.xml.stream.XMLEventFactory; import javax.xml.stream.XMLEventFactory;
import jaxp.library.JAXPDataProvider; import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.stream.ptests.XMLEventFactoryNewInstanceTest
* @run testng/othervm javax.xml.stream.ptests.XMLEventFactoryNewInstanceTest
* @summary Tests for XMLEventFactory.newFactory(factoryId , classLoader) * @summary Tests for XMLEventFactory.newFactory(factoryId , classLoader)
*/ */
public class XMLEventFactoryNewInstanceTest extends JAXPBaseTest { @Listeners({jaxp.library.BasePolicy.class})
public class XMLEventFactoryNewInstanceTest {
private static final String XMLEVENT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl"; private static final String XMLEVENT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl";
private static final String XMLEVENT_FACRORY_ID = "javax.xml.stream.XMLEventFactory"; private static final String XMLEVENT_FACRORY_ID = "javax.xml.stream.XMLEventFactory";
@ -59,7 +67,7 @@ public class XMLEventFactoryNewInstanceTest extends JAXPBaseTest {
XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader); XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader);
assertNotNull(xef); assertNotNull(xef);
} finally { } finally {
setSystemProperty(XMLEVENT_FACRORY_ID, null); clearSystemProperty(XMLEVENT_FACRORY_ID);
} }
} }
@ -74,3 +82,4 @@ public class XMLEventFactoryNewInstanceTest extends JAXPBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,20 +23,28 @@
package javax.xml.stream.ptests; package javax.xml.stream.ptests;
import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLInputFactory;
import jaxp.library.JAXPDataProvider; import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.stream.ptests.XMLInputFactoryNewInstanceTest
* @run testng/othervm javax.xml.stream.ptests.XMLInputFactoryNewInstanceTest
* @summary Tests for XMLInputFactory.newFactory(factoryId , classLoader) * @summary Tests for XMLInputFactory.newFactory(factoryId , classLoader)
*/ */
public class XMLInputFactoryNewInstanceTest extends JAXPBaseTest { @Listeners({jaxp.library.BasePolicy.class})
public class XMLInputFactoryNewInstanceTest {
private static final String XMLINPUT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.XMLInputFactoryImpl"; private static final String XMLINPUT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
private static final String XMLINPUT_FACRORY_ID = "javax.xml.stream.XMLInputFactory"; private static final String XMLINPUT_FACRORY_ID = "javax.xml.stream.XMLInputFactory";
@ -59,7 +67,7 @@ public class XMLInputFactoryNewInstanceTest extends JAXPBaseTest {
XMLInputFactory xif = XMLInputFactory.newFactory(factoryId, classLoader); XMLInputFactory xif = XMLInputFactory.newFactory(factoryId, classLoader);
assertNotNull(xif); assertNotNull(xif);
} finally { } finally {
setSystemProperty(XMLINPUT_FACRORY_ID, null); clearSystemProperty(XMLINPUT_FACRORY_ID);
} }
} }
@ -74,3 +82,4 @@ public class XMLInputFactoryNewInstanceTest extends JAXPBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,8 @@
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -34,17 +36,20 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileBaseTest; import org.testng.annotations.Listeners;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
/* /*
* @test
* @bug 6384418 * @bug 6384418
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.Bug6384418Test
* @run testng/othervm javax.xml.transform.ptests.Bug6384418Test
* @summary verify the transforming won't throw any exception * @summary verify the transforming won't throw any exception
*/ */
public class Bug6384418Test extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class Bug6384418Test {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
@ -62,3 +67,5 @@ public class Bug6384418Test extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,20 +23,23 @@
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
@ -50,7 +53,14 @@ import org.xml.sax.helpers.XMLReaderFactory;
* DOM parse on test file to be compared with golden output file. No Exception * DOM parse on test file to be compared with golden output file. No Exception
* is expected. * is expected.
*/ */
public class DOMResultTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.DOMResultTest
* @run testng/othervm javax.xml.transform.ptests.DOMResultTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class DOMResultTest {
/** /**
* Unit test for simple DOM parsing. * Unit test for simple DOM parsing.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
@ -108,3 +118,5 @@ public class DOMResultTest extends JAXPFileBaseTest {
writeNodes(kids.item(i), bWriter); writeNodes(kids.item(i), bWriter);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,23 +23,32 @@
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.io.File; import java.io.File;
import java.io.FilePermission;
import javax.xml.transform.ErrorListener; import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertEquals; import org.testng.annotations.Listeners;
import static org.testng.Assert.fail;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Class containing the test cases for ErrorListener interface * Class containing the test cases for ErrorListener interface
*/ */
public class ErrorListenerTest extends JAXPBaseTest implements ErrorListener { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.ErrorListenerTest
* @run testng/othervm javax.xml.transform.ptests.ErrorListenerTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class ErrorListenerTest implements ErrorListener {
/** /**
* Define ErrorListener's status. * Define ErrorListener's status.
*/ */
@ -60,7 +69,6 @@ public class ErrorListenerTest extends JAXPBaseTest implements ErrorListener {
try { try {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
tfactory.setErrorListener (listener); tfactory.setErrorListener (listener);
setPermissions(new FilePermission(XML_DIR + "invalid.xsl", "read"));
tfactory.newTransformer(new StreamSource( tfactory.newTransformer(new StreamSource(
new File(XML_DIR + "invalid.xsl"))); new File(XML_DIR + "invalid.xsl")));
fail("Expect TransformerConfigurationException here"); fail("Expect TransformerConfigurationException here");
@ -96,3 +104,5 @@ public class ErrorListenerTest extends JAXPBaseTest implements ErrorListener {
this.status = ListenerStatus.FATAL; this.status = ListenerStatus.FATAL;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,18 +23,21 @@
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMSource;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -42,7 +45,14 @@ import org.xml.sax.InputSource;
/** /**
* Unit test for SAXSource sourceToInputSource API. * Unit test for SAXSource sourceToInputSource API.
*/ */
public class SAXSourceTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.SAXSourceTest
* @run testng/othervm javax.xml.transform.ptests.SAXSourceTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class SAXSourceTest {
/** /**
* Test style-sheet file name * Test style-sheet file name
*/ */
@ -53,7 +63,7 @@ public class SAXSourceTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws IOException reading file error. * @throws IOException reading file error.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void source2inputsource01() throws IOException { public void source2inputsource01() throws IOException {
try (FileInputStream fis = new FileInputStream(TEST_FILE)) { try (FileInputStream fis = new FileInputStream(TEST_FILE)) {
StreamSource streamSource = new StreamSource(fis); StreamSource streamSource = new StreamSource(fis);
@ -68,7 +78,7 @@ public class SAXSourceTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void source2inputsource02() throws Exception { public void source2inputsource02() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true); dbf.setNamespaceAware(true);
@ -83,7 +93,7 @@ public class SAXSourceTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws IOException reading file error. * @throws IOException reading file error.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void source2inputsource03() throws IOException { public void source2inputsource03() throws IOException {
String SYSTEM_ID = "file:///" + XML_DIR; String SYSTEM_ID = "file:///" + XML_DIR;
try (FileInputStream fis = new FileInputStream(TEST_FILE)) { try (FileInputStream fis = new FileInputStream(TEST_FILE)) {
@ -95,3 +105,5 @@ public class SAXSourceTest extends JAXPFileReadOnlyBaseTest {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,27 +23,30 @@
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result; import javax.xml.transform.Result;
import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TemplatesHandler; import javax.xml.transform.sax.TemplatesHandler;
import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import org.testng.annotations.Listeners;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@ -56,7 +59,14 @@ import org.xml.sax.helpers.XMLReaderFactory;
* Test newTransformerhandler() method which takes StreamSource as argument can * Test newTransformerhandler() method which takes StreamSource as argument can
* be set to XMLReader. * be set to XMLReader.
*/ */
public class SAXTFactoryTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.SAXTFactoryTest
* @run testng/othervm javax.xml.transform.ptests.SAXTFactoryTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class SAXTFactoryTest {
/** /**
* Test style-sheet file. * Test style-sheet file.
*/ */
@ -421,3 +431,5 @@ public class SAXTFactoryTest extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,11 +22,16 @@
*/ */
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.failUnexpected;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Properties; import java.util.Properties;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -34,12 +39,10 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import org.testng.annotations.Listeners;
import static jaxp.library.JAXPTestUtilities.failUnexpected;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -48,7 +51,14 @@ import org.xml.sax.SAXException;
* Test a StreamResult using a file name that contains URL characters that need * Test a StreamResult using a file name that contains URL characters that need
* to be encoded. * to be encoded.
*/ */
public class StreamResultTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.StreamResultTest
* @run testng/othervm javax.xml.transform.ptests.StreamResultTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class StreamResultTest {
/** /**
* Unit test for StreamResult. * Unit test for StreamResult.
*/ */
@ -96,3 +106,5 @@ public class StreamResultTest extends JAXPFileBaseTest {
}); });
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,20 +22,23 @@
*/ */
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.assertEquals; import org.testng.annotations.Listeners;
import static org.testng.Assert.assertNull;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@ -44,7 +47,14 @@ import org.xml.sax.InputSource;
/** /**
* Class containing the test cases for SAXParserFactory API * Class containing the test cases for SAXParserFactory API
*/ */
public class TfClearParamTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TfClearParamTest
* @run testng/othervm javax.xml.transform.ptests.TfClearParamTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class TfClearParamTest {
/** /**
* Test style-sheet file name. * Test style-sheet file name.
*/ */
@ -128,7 +138,7 @@ public class TfClearParamTest extends JAXPFileReadOnlyBaseTest {
* @throws TransformerConfigurationException If for some reason the * @throws TransformerConfigurationException If for some reason the
* TransformerHandler can not be created. * TransformerHandler can not be created.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void clear05() throws TransformerConfigurationException { public void clear05() throws TransformerConfigurationException {
Transformer transformer = TransformerFactory.newInstance(). Transformer transformer = TransformerFactory.newInstance().
newTransformer(new StreamSource(new File(XSL_FILE))); newTransformer(new StreamSource(new File(XSL_FILE)));
@ -143,7 +153,7 @@ public class TfClearParamTest extends JAXPFileReadOnlyBaseTest {
* @throws TransformerConfigurationException If for some reason the * @throws TransformerConfigurationException If for some reason the
* TransformerHandler can not be created. * TransformerHandler can not be created.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void clear06() throws TransformerConfigurationException { public void clear06() throws TransformerConfigurationException {
Transformer transformer = TransformerFactory.newInstance(). Transformer transformer = TransformerFactory.newInstance().
newTransformer(new StreamSource(new File(XSL_FILE))); newTransformer(new StreamSource(new File(XSL_FILE)));
@ -157,7 +167,7 @@ public class TfClearParamTest extends JAXPFileReadOnlyBaseTest {
* the a name that set before. Value should be same as set one. * the a name that set before. Value should be same as set one.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void clear07() throws Exception { public void clear07() throws Exception {
try (FileInputStream fis = new FileInputStream(XSL_FILE)) { try (FileInputStream fis = new FileInputStream(XSL_FILE)) {
SAXSource saxSource = new SAXSource(); SAXSource saxSource = new SAXSource();
@ -174,7 +184,7 @@ public class TfClearParamTest extends JAXPFileReadOnlyBaseTest {
* the a name that wasn't set before. Null is expected. * the a name that wasn't set before. Null is expected.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void clear08() throws Exception { public void clear08() throws Exception {
try (FileInputStream fis = new FileInputStream(XSL_FILE)) { try (FileInputStream fis = new FileInputStream(XSL_FILE)) {
SAXSource saxSource = new SAXSource(); SAXSource saxSource = new SAXSource();
@ -192,7 +202,7 @@ public class TfClearParamTest extends JAXPFileReadOnlyBaseTest {
* the a name that set before. Value should be same as set one. * the a name that set before. Value should be same as set one.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void clear09() throws Exception { public void clear09() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
@ -213,7 +223,7 @@ public class TfClearParamTest extends JAXPFileReadOnlyBaseTest {
* the a name that wasn't set before. Null is expected. * the a name that wasn't set before. Null is expected.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void clear10() throws Exception { public void clear10() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
@ -229,3 +239,5 @@ public class TfClearParamTest extends JAXPFileReadOnlyBaseTest {
assertNull(transformer.getParameter(LONG_PARAM_NAME)); assertNull(transformer.getParameter(LONG_PARAM_NAME));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -38,7 +38,6 @@ import java.util.function.Supplier;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLOutputFactory;
@ -58,10 +57,9 @@ import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -71,10 +69,15 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TransformTest
* @run testng/othervm javax.xml.transform.ptests.TransformTest
* @summary Tests for variable combination of Transformer.transform(Source, Result) * @summary Tests for variable combination of Transformer.transform(Source, Result)
*/ */
@Test(singleThreaded = true) @Test(singleThreaded = true)
public class TransformTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class TransformTest {
/* /*
* Initialize the share objects. * Initialize the share objects.
@ -381,3 +384,5 @@ public class TransformTest extends JAXPFileBaseTest {
private Document xmlDoc; private Document xmlDoc;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,32 +22,40 @@
*/ */
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import java.io.File;
import java.io.FilePermission;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
import java.io.File;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Basic test for TransformerException specification. * Basic test for TransformerException specification.
*/ */
public class TransformerExcpTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TransformerExcpTest
* @run testng/othervm javax.xml.transform.ptests.TransformerExcpTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class TransformerExcpTest {
/** /**
* Transform an unformatted style-sheet file. TransformerException is thrown. * Transform an unformatted style-sheet file. TransformerException is thrown.
*/ */
@Test @Test
public void tfexception() { public void tfexception() {
try { try {
setPermissions(new FilePermission(XML_DIR + "-", "read"));
// invalid.xsl has well-formedness error. Therefore transform throws // invalid.xsl has well-formedness error. Therefore transform throws
// TransformerException // TransformerException
StreamSource streamSource StreamSource streamSource
@ -63,8 +71,6 @@ public class TransformerExcpTest extends JAXPBaseTest {
assertNotNull(e.getException()); assertNotNull(e.getException());
assertNull(e.getLocationAsString()); assertNull(e.getLocationAsString());
assertEquals(e.getMessageAndLocation(),e.getMessage()); assertEquals(e.getMessageAndLocation(),e.getMessage());
} finally {
setPermissions();
} }
} }
@ -99,3 +105,5 @@ public class TransformerExcpTest extends JAXPBaseTest {
assertNotNull(te.initCause(null)); assertNotNull(te.initCause(null));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,33 +22,45 @@
*/ */
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import java.io.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.stream.*;
import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import jaxp.library.JAXPDataProvider;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.*; import org.w3c.dom.Document;
/** /**
* Class containing the test cases for TransformerFactory API's * Class containing the test cases for TransformerFactory API's
* getAssociatedStyleSheet method and TransformerFactory.newInstance(factoryClassName , classLoader). * getAssociatedStyleSheet method and TransformerFactory.newInstance(factoryClassName , classLoader).
*/ */
public class TransformerFactoryTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TransformerFactoryTest
* @run testng/othervm javax.xml.transform.ptests.TransformerFactoryTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class TransformerFactoryTest {
/** /**
* TransformerFactory implementation class name. * TransformerFactory implementation class name.
*/ */
@ -129,3 +141,5 @@ public class TransformerFactoryTest extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,9 +22,15 @@
*/ */
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.util.Properties; import java.util.Properties;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.ErrorListener; import javax.xml.transform.ErrorListener;
@ -33,13 +39,10 @@ import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.assertEquals; import org.testng.annotations.Listeners;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -47,7 +50,14 @@ import org.xml.sax.InputSource;
/** /**
* Basic test cases for Transformer API * Basic test cases for Transformer API
*/ */
public class TransformerTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TransformerTest
* @run testng/othervm javax.xml.transform.ptests.TransformerTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class TransformerTest {
/** /**
* XSLT file serves every test method. * XSLT file serves every test method.
*/ */
@ -58,7 +68,7 @@ public class TransformerTest extends JAXPFileReadOnlyBaseTest {
* @throws TransformerConfigurationException If for some reason the * @throws TransformerConfigurationException If for some reason the
* TransformerHandler can not be created. * TransformerHandler can not be created.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void transformer01() throws TransformerConfigurationException { public void transformer01() throws TransformerConfigurationException {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
StreamSource streamSource = new StreamSource( StreamSource streamSource = new StreamSource(
@ -71,7 +81,7 @@ public class TransformerTest extends JAXPFileReadOnlyBaseTest {
* This tests if newTransformer(SAXSource) method returns Transformer. * This tests if newTransformer(SAXSource) method returns Transformer.
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void transformer02() throws Exception { public void transformer02() throws Exception {
try (FileInputStream fis = new FileInputStream(TEST_XSL)) { try (FileInputStream fis = new FileInputStream(TEST_XSL)) {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
@ -86,7 +96,7 @@ public class TransformerTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void transformer03() throws Exception { public void transformer03() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
@ -105,7 +115,7 @@ public class TransformerTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void transformer04() throws Exception { public void transformer04() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true); dbf.setNamespaceAware(true);
@ -125,7 +135,7 @@ public class TransformerTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void transformer05() throws Exception { public void transformer05() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true); dbf.setNamespaceAware(true);
@ -150,7 +160,7 @@ public class TransformerTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void transformer06() throws Exception { public void transformer06() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
@ -197,3 +207,5 @@ class MyErrorListener implements ErrorListener {
System.out.println(" In fatal"); System.out.println(" In fatal");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,21 +22,24 @@
*/ */
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import org.testng.annotations.Listeners;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -44,7 +47,14 @@ import org.testng.annotations.Test;
* Here a transformer is created using DOMSource. Some specific output property * Here a transformer is created using DOMSource. Some specific output property
* is set on transformer. Then transform(StreamSource, StreamResult) is tested. * is set on transformer. Then transform(StreamSource, StreamResult) is tested.
*/ */
public class TransformerTest02 extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TransformerTest02
* @run testng/othervm javax.xml.transform.ptests.TransformerTest02
*/
@Listeners({jaxp.library.FilePolicy.class})
public class TransformerTest02 {
/** /**
* Unit test for transform(StreamSource, StreamResult). * Unit test for transform(StreamSource, StreamResult).
* *
@ -75,3 +85,5 @@ public class TransformerTest02 extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,22 +22,25 @@
*/ */
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.util.Properties; import java.util.Properties;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import org.testng.annotations.Listeners;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -46,7 +49,14 @@ import org.testng.annotations.Test;
* for transformer. Then transform(StreamSource, StreamResult) is used for * for transformer. Then transform(StreamSource, StreamResult) is used for
* transformation. This tests the setOutputProperties() method. * transformation. This tests the setOutputProperties() method.
*/ */
public class TransformerTest03 extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TransformerTest03
* @run testng/othervm javax.xml.transform.ptests.TransformerTest03
*/
@Listeners({jaxp.library.FilePolicy.class})
public class TransformerTest03 {
/** /**
* Test for Transformer.setOutputProperties method. * Test for Transformer.setOutputProperties method.
* *
@ -84,3 +94,5 @@ public class TransformerTest03 extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,8 +22,13 @@
*/ */
package javax.xml.transform.ptests; package javax.xml.transform.ptests;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source; import javax.xml.transform.Source;
@ -31,13 +36,11 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.URIResolver; import javax.xml.transform.URIResolver;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import jaxp.library.JAXPFileBaseTest;
import static org.testng.Assert.assertEquals; import org.testng.annotations.Listeners;
import static org.testng.Assert.assertNotNull;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -45,7 +48,14 @@ import org.xml.sax.InputSource;
/** /**
* URIResolver should be invoked when transform happens. * URIResolver should be invoked when transform happens.
*/ */
public class URIResolverTest extends JAXPFileBaseTest implements URIResolver { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.URIResolverTest
* @run testng/othervm javax.xml.transform.ptests.URIResolverTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class URIResolverTest implements URIResolver {
/** /**
* System ID constant. * System ID constant.
*/ */
@ -115,7 +125,7 @@ public class URIResolverTest extends JAXPFileBaseTest implements URIResolver {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public static void resolver01() throws Exception { public static void resolver01() throws Exception {
try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)) { try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)) {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
@ -134,7 +144,7 @@ public class URIResolverTest extends JAXPFileBaseTest implements URIResolver {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public static void resolver02() throws Exception { public static void resolver02() throws Exception {
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
@ -155,7 +165,7 @@ public class URIResolverTest extends JAXPFileBaseTest implements URIResolver {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public static void resolver03() throws Exception { public static void resolver03() throws Exception {
try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)){ try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)){
URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
@ -174,7 +184,7 @@ public class URIResolverTest extends JAXPFileBaseTest implements URIResolver {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public static void resolver04() throws Exception { public static void resolver04() throws Exception {
try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)) { try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)) {
URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
@ -192,7 +202,7 @@ public class URIResolverTest extends JAXPFileBaseTest implements URIResolver {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public static void resolver05() throws Exception { public static void resolver05() throws Exception {
URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
TransformerFactory tfactory = TransformerFactory.newInstance(); TransformerFactory tfactory = TransformerFactory.newInstance();
@ -211,7 +221,7 @@ public class URIResolverTest extends JAXPFileBaseTest implements URIResolver {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public static void resolver06() throws Exception { public static void resolver06() throws Exception {
try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)){ try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)){
URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID); URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
@ -230,7 +240,7 @@ public class URIResolverTest extends JAXPFileBaseTest implements URIResolver {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public static void docResolver01() throws Exception { public static void docResolver01() throws Exception {
try (FileInputStream fis = new FileInputStream(XML_DIR + "doctest.xsl")) { try (FileInputStream fis = new FileInputStream(XML_DIR + "doctest.xsl")) {
URIResolverTest resolver = new URIResolverTest("temp/colors.xml", SYSTEM_ID); URIResolverTest resolver = new URIResolverTest("temp/colors.xml", SYSTEM_ID);
@ -252,3 +262,5 @@ public class URIResolverTest extends JAXPFileBaseTest implements URIResolver {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,15 +22,27 @@
*/ */
package javax.xml.transform.ptests.othervm; package javax.xml.transform.ptests.othervm;
import javax.xml.transform.*; import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Negative test for set invalid TransformerFactory property. * Negative test for set invalid TransformerFactory property.
*/ */
public class TFCErrorTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.othervm.TFCErrorTest
* @run testng/othervm javax.xml.transform.ptests.othervm.TFCErrorTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class TFCErrorTest {
@Test(expectedExceptions = ClassNotFoundException.class) @Test(expectedExceptions = ClassNotFoundException.class)
public void tfce01() throws Exception { public void tfce01() throws Exception {
try{ try{
@ -42,3 +54,5 @@ public class TFCErrorTest extends JAXPBaseTest {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -54,6 +54,7 @@ import jaxp.library.JAXPDataProvider;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler; import org.xml.sax.ErrorHandler;
@ -64,10 +65,15 @@ import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
/* /*
* @test
* @bug 8080907 * @bug 8080907
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.validation.ptests.SchemaFactoryTest
* @run testng/othervm javax.xml.validation.ptests.SchemaFactoryTest
* @summary Class containing the test cases for SchemaFactory * @summary Class containing the test cases for SchemaFactory
*/ */
@Test(singleThreaded = true) @Test(singleThreaded = true)
@Listeners({jaxp.library.FilePolicy.class})
public class SchemaFactoryTest { public class SchemaFactoryTest {
@BeforeClass @BeforeClass
@ -398,3 +404,4 @@ public class SchemaFactoryTest {
private Document xsdDoc2; private Document xsdDoc2;
private byte[] xml; private byte[] xml;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -39,8 +39,7 @@ import javax.xml.validation.SchemaFactory;
import javax.xml.validation.TypeInfoProvider; import javax.xml.validation.TypeInfoProvider;
import javax.xml.validation.ValidatorHandler; import javax.xml.validation.ValidatorHandler;
import jaxp.library.JAXPFileBaseTest; import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -49,9 +48,14 @@ import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.validation.ptests.TypeInfoProviderTest
* @run testng/othervm javax.xml.validation.ptests.TypeInfoProviderTest
* @summary test ValidatorHandler.getTypeInfoProvider() * @summary test ValidatorHandler.getTypeInfoProvider()
*/ */
public class TypeInfoProviderTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class TypeInfoProviderTest {
private ValidatorHandler validatorHandler; private ValidatorHandler validatorHandler;
@ -91,3 +95,4 @@ public class TypeInfoProviderTest extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,6 +37,7 @@ import javax.xml.validation.SchemaFactory;
import javax.xml.validation.ValidatorHandler; import javax.xml.validation.ValidatorHandler;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.ContentHandler; import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler; import org.xml.sax.ErrorHandler;
@ -46,8 +47,13 @@ import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.validation.ptests.ValidatorHandlerTest
* @run testng/othervm javax.xml.validation.ptests.ValidatorHandlerTest
* @summary Class containing the test cases for ValidatorHandler API * @summary Class containing the test cases for ValidatorHandler API
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class ValidatorHandlerTest { public class ValidatorHandlerTest {
@BeforeClass @BeforeClass
public void setup() throws SAXException { public void setup() throws SAXException {
@ -142,3 +148,4 @@ public class ValidatorHandlerTest {
private Schema schema; private Schema schema;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -45,10 +45,9 @@ import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory; import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator; import javax.xml.validation.Validator;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler; import org.xml.sax.ErrorHandler;
@ -59,9 +58,14 @@ import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.validation.ptests.ValidatorTest
* @run testng/othervm javax.xml.validation.ptests.ValidatorTest
* @summary Class containing the test cases for Validator API * @summary Class containing the test cases for Validator API
*/ */
public class ValidatorTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class ValidatorTest {
@BeforeClass @BeforeClass
public void setup() throws SAXException, IOException, ParserConfigurationException { public void setup() throws SAXException, IOException, ParserConfigurationException {
@ -205,3 +209,4 @@ public class ValidatorTest extends JAXPFileBaseTest {
private Document xmlDoc; private Document xmlDoc;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,26 +23,28 @@
package javax.xml.xpath.ptests; package javax.xml.xpath.ptests;
import java.io.FilePermission;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import static javax.xml.xpath.XPathConstants.BOOLEAN; import static javax.xml.xpath.XPathConstants.BOOLEAN;
import static javax.xml.xpath.XPathConstants.NODE; import static javax.xml.xpath.XPathConstants.NODE;
import static javax.xml.xpath.XPathConstants.NODESET; import static javax.xml.xpath.XPathConstants.NODESET;
import static javax.xml.xpath.XPathConstants.NUMBER; import static javax.xml.xpath.XPathConstants.NUMBER;
import static javax.xml.xpath.XPathConstants.STRING; import static javax.xml.xpath.XPathConstants.STRING;
import static javax.xml.xpath.ptests.XPathTestConst.XML_DIR;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactory;
import static javax.xml.xpath.ptests.XPathTestConst.XML_DIR;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -52,7 +54,14 @@ import org.xml.sax.InputSource;
/** /**
* Class containing the test cases for XPathExpression API. * Class containing the test cases for XPathExpression API.
*/ */
public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.xpath.ptests.XPathExpressionTest
* @run testng/othervm javax.xml.xpath.ptests.XPathExpressionTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class XPathExpressionTest {
/** /**
* Document object for testing XML file. * Document object for testing XML file.
*/ */
@ -89,7 +98,6 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
*/ */
@BeforeTest @BeforeTest
public void setup() throws Exception { public void setup() throws Exception {
setPermissions(new FilePermission(XML_PATH.toFile().toString(), "read"));
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(XML_PATH.toFile()); document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(XML_PATH.toFile());
xpath = XPathFactory.newInstance().newXPath(); xpath = XPathFactory.newInstance().newXPath();
} }
@ -264,7 +272,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void testCheckXPathExpression15() throws Exception { public void testCheckXPathExpression15() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.compile(EXPRESSION_NAME_A). assertEquals(xpath.compile(EXPRESSION_NAME_A).
@ -287,7 +295,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void testCheckXPathExpression17() throws Exception { public void testCheckXPathExpression17() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.compile(null).evaluate(new InputSource(is)); xpath.compile(null).evaluate(new InputSource(is));
@ -300,7 +308,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class) @Test(expectedExceptions = XPathExpressionException.class)
public void testCheckXPathExpression18() throws Exception { public void testCheckXPathExpression18() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.compile("-*&").evaluate(new InputSource(is)); xpath.compile("-*&").evaluate(new InputSource(is));
@ -313,7 +321,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class) @Test(expectedExceptions = XPathExpressionException.class)
public void testCheckXPathExpression19() throws Exception { public void testCheckXPathExpression19() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.compile(" ").evaluate(new InputSource(is)); xpath.compile(" ").evaluate(new InputSource(is));
@ -326,7 +334,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPathExpression20() throws Exception { public void testCheckXPathExpression20() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.compile(EXPRESSION_NAME_A). assertEquals(xpath.compile(EXPRESSION_NAME_A).
@ -351,7 +359,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void testCheckXPathExpression22() throws Exception { public void testCheckXPathExpression22() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.compile(null).evaluate(new InputSource(is), STRING); xpath.compile(null).evaluate(new InputSource(is), STRING);
@ -364,7 +372,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void testCheckXPathExpression23() throws Exception { public void testCheckXPathExpression23() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.compile(EXPRESSION_NAME_A).evaluate(new InputSource(is), null); xpath.compile(EXPRESSION_NAME_A).evaluate(new InputSource(is), null);
@ -377,7 +385,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class) @Test(expectedExceptions = XPathExpressionException.class)
public void testCheckXPathExpression24() throws Exception { public void testCheckXPathExpression24() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.compile("-*&").evaluate(new InputSource(is), STRING); xpath.compile("-*&").evaluate(new InputSource(is), STRING);
@ -390,7 +398,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class) @Test(expectedExceptions = XPathExpressionException.class)
public void testCheckXPathExpression25() throws Exception { public void testCheckXPathExpression25() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.compile(" ").evaluate(new InputSource(is), STRING); xpath.compile(" ").evaluate(new InputSource(is), STRING);
@ -404,7 +412,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = IllegalArgumentException.class) @Test(expectedExceptions = IllegalArgumentException.class)
public void testCheckXPathExpression26() throws Exception { public void testCheckXPathExpression26() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.compile(EXPRESSION_NAME_A).evaluate(new InputSource(is), TEST_QNAME); xpath.compile(EXPRESSION_NAME_A).evaluate(new InputSource(is), TEST_QNAME);
@ -417,7 +425,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPathExpression27() throws Exception { public void testCheckXPathExpression27() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.compile(EXPRESSION_NAME_A). assertEquals(xpath.compile(EXPRESSION_NAME_A).
@ -431,7 +439,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPathExpression28() throws Exception { public void testCheckXPathExpression28() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.compile(EXPRESSION_NAME_B). assertEquals(xpath.compile(EXPRESSION_NAME_B).
@ -445,7 +453,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPathExpression29() throws Exception { public void testCheckXPathExpression29() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.compile(EXPRESSION_NAME_A). assertEquals(xpath.compile(EXPRESSION_NAME_A).
@ -459,7 +467,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPathExpression30() throws Exception { public void testCheckXPathExpression30() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
Attr attr = (Attr) xpath.compile(EXPRESSION_NAME_A). Attr attr = (Attr) xpath.compile(EXPRESSION_NAME_A).
@ -474,7 +482,7 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPathExpression31() throws Exception { public void testCheckXPathExpression31() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
NodeList nodeList = (NodeList) xpath.compile(EXPRESSION_NAME_A). NodeList nodeList = (NodeList) xpath.compile(EXPRESSION_NAME_A).
@ -483,3 +491,5 @@ public class XPathExpressionTest extends JAXPFileReadOnlyBaseTest {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,22 +24,29 @@
package javax.xml.xpath.ptests; package javax.xml.xpath.ptests;
import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL; import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL;
import static org.testng.Assert.assertNotNull;
import javax.xml.xpath.XPath; import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPathFactoryConfigurationException; import javax.xml.xpath.XPathFactoryConfigurationException;
import jaxp.library.JAXPDataProvider; import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertNotNull;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Class containing the test cases for XPathFactory API. * Class containing the test cases for XPathFactory API.
*/ */
public class XPathFactoryTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.xpath.ptests.XPathFactoryTest
* @run testng/othervm javax.xml.xpath.ptests.XPathFactoryTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class XPathFactoryTest {
/** /**
* Valid URL for creating a XPath factory. * Valid URL for creating a XPath factory.
*/ */
@ -211,3 +218,5 @@ public class XPathFactoryTest extends JAXPBaseTest {
assertNotNull(XPathFactory.newInstance(DOM_OBJECT_MODEL)); assertNotNull(XPathFactory.newInstance(DOM_OBJECT_MODEL));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,18 +23,27 @@
package javax.xml.xpath.ptests; package javax.xml.xpath.ptests;
import static org.testng.Assert.assertEquals;
import javax.xml.xpath.XPath; import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactory;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Class containing the test cases for XPathFunctionResolver. * Class containing the test cases for XPathFunctionResolver.
*/ */
public class XPathFunctionResolverTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.xpath.ptests.XPathFunctionResolverTest
* @run testng/othervm javax.xml.xpath.ptests.XPathFunctionResolverTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class XPathFunctionResolverTest {
/** /**
* A XPath for evaluation environment and expressions. * A XPath for evaluation environment and expressions.
*/ */
@ -73,3 +82,5 @@ public class XPathFunctionResolverTest extends JAXPBaseTest {
assertEquals(xpath.evaluate(null, "5"), "2"); assertEquals(xpath.evaluate(null, "5"), "2");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,30 +23,32 @@
package javax.xml.xpath.ptests; package javax.xml.xpath.ptests;
import java.io.FilePermission;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Iterator;
import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import static javax.xml.xpath.XPathConstants.BOOLEAN; import static javax.xml.xpath.XPathConstants.BOOLEAN;
import static javax.xml.xpath.XPathConstants.NODE; import static javax.xml.xpath.XPathConstants.NODE;
import static javax.xml.xpath.XPathConstants.NODESET; import static javax.xml.xpath.XPathConstants.NODESET;
import static javax.xml.xpath.XPathConstants.NUMBER; import static javax.xml.xpath.XPathConstants.NUMBER;
import static javax.xml.xpath.XPathConstants.STRING; import static javax.xml.xpath.XPathConstants.STRING;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import static javax.xml.xpath.ptests.XPathTestConst.XML_DIR; import static javax.xml.xpath.ptests.XPathTestConst.XML_DIR;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertNull;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Iterator;
import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -56,7 +58,14 @@ import org.xml.sax.InputSource;
/** /**
* Class containing the test cases for XPath API. * Class containing the test cases for XPath API.
*/ */
public class XPathTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true javax.xml.xpath.ptests.XPathTest
* @run testng/othervm javax.xml.xpath.ptests.XPathTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class XPathTest {
/** /**
* Document object for testing XML file. * Document object for testing XML file.
*/ */
@ -93,7 +102,6 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
*/ */
@BeforeTest @BeforeTest
public void setup() throws Exception { public void setup() throws Exception {
setPermissions(new FilePermission(XML_DIR + "-", "read"));
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(XML_PATH.toFile()); document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(XML_PATH.toFile());
xpath = XPathFactory.newInstance().newXPath(); xpath = XPathFactory.newInstance().newXPath();
} }
@ -347,7 +355,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test (groups = {"readLocalFiles"}) @Test
public void testCheckXPath22() throws Exception { public void testCheckXPath22() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is)), "6"); assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is)), "6");
@ -371,7 +379,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void testCheckXPath24() throws Exception { public void testCheckXPath24() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.evaluate(null, new InputSource(is)); xpath.evaluate(null, new InputSource(is));
@ -385,7 +393,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class) @Test(expectedExceptions = XPathExpressionException.class)
public void testCheckXPath25() throws Exception { public void testCheckXPath25() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.evaluate("-*&", new InputSource(is)); xpath.evaluate("-*&", new InputSource(is));
@ -398,7 +406,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class) @Test(expectedExceptions = XPathExpressionException.class)
public void testCheckXPath26() throws Exception { public void testCheckXPath26() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.evaluate(" ", new InputSource(is)); xpath.evaluate(" ", new InputSource(is));
@ -411,7 +419,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath27() throws Exception { public void testCheckXPath27() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), STRING), "6"); assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), STRING), "6");
@ -435,7 +443,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void testCheckXPath29() throws Exception { public void testCheckXPath29() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.evaluate(null, new InputSource(is), STRING); xpath.evaluate(null, new InputSource(is), STRING);
@ -448,7 +456,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void testCheckXPath30() throws Exception { public void testCheckXPath30() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), null); xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), null);
@ -461,7 +469,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class) @Test(expectedExceptions = XPathExpressionException.class)
public void testCheckXPath31() throws Exception { public void testCheckXPath31() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.evaluate("-*&", new InputSource(is), STRING); xpath.evaluate("-*&", new InputSource(is), STRING);
@ -474,7 +482,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class) @Test(expectedExceptions = XPathExpressionException.class)
public void testCheckXPath32() throws Exception { public void testCheckXPath32() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.evaluate(" ", new InputSource(is), STRING); xpath.evaluate(" ", new InputSource(is), STRING);
@ -488,7 +496,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = IllegalArgumentException.class) @Test(expectedExceptions = IllegalArgumentException.class)
public void testCheckXPath33() throws Exception { public void testCheckXPath33() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), TEST_QNAME); xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), TEST_QNAME);
@ -501,7 +509,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath34() throws Exception { public void testCheckXPath34() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is),
@ -515,7 +523,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath35() throws Exception { public void testCheckXPath35() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is), assertEquals(xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is),
@ -529,7 +537,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath36() throws Exception { public void testCheckXPath36() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is),
@ -543,7 +551,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath37() throws Exception { public void testCheckXPath37() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A, assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A,
@ -557,7 +565,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath38() throws Exception { public void testCheckXPath38() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A, NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A,
@ -573,7 +581,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath52() throws Exception { public void testCheckXPath52() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is), assertEquals(xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is),
@ -587,7 +595,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath53() throws Exception { public void testCheckXPath53() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is),
@ -601,7 +609,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath54() throws Exception { public void testCheckXPath54() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A, assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A,
@ -615,7 +623,7 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void testCheckXPath55() throws Exception { public void testCheckXPath55() throws Exception {
try (InputStream is = Files.newInputStream(XML_PATH)) { try (InputStream is = Files.newInputStream(XML_PATH)) {
NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A, NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A,
@ -749,3 +757,5 @@ public class XPathTest extends JAXPFileReadOnlyBaseTest {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,8 +31,6 @@ import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.CharacterData; import org.w3c.dom.CharacterData;
@ -42,7 +40,7 @@ import org.xml.sax.SAXException;
/* /*
* @summary common test for the CharacterData Interface * @summary common test for the CharacterData Interface
*/ */
public abstract class AbstractCharacterDataTest extends JAXPFileBaseTest { public abstract class AbstractCharacterDataTest {
@DataProvider(name = "data-for-length") @DataProvider(name = "data-for-length")
public Object[][] getDataForTestLength() { public Object[][] getDataForTestLength() {
return new Object[][] { return new Object[][] {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,8 +28,8 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.w3c.dom.ptests.DOMTestUtil.createDOM; import static org.w3c.dom.ptests.DOMTestUtil.createDOM;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -38,9 +38,14 @@ import org.w3c.dom.NamedNodeMap;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.AttrTest
* @run testng/othervm org.w3c.dom.ptests.AttrTest
* @summary Test for the Attr Interface * @summary Test for the Attr Interface
*/ */
public class AttrTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class AttrTest {
/* /*
* Verify getName method against both existing Attr and new Attr. * Verify getName method against both existing Attr and new Attr.
*/ */
@ -146,3 +151,4 @@ public class AttrTest extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,13 +28,19 @@ import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.testng.annotations.Listeners;
import org.w3c.dom.CharacterData; import org.w3c.dom.CharacterData;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/* /*
* @test
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/functional
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.CommentTest
* @run testng/othervm org.w3c.dom.ptests.CommentTest
* @summary Test for Comment implementation returned by Document.createComment(String) * @summary Test for Comment implementation returned by Document.createComment(String)
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class CommentTest extends AbstractCharacterDataTest { public class CommentTest extends AbstractCharacterDataTest {
@Override @Override
protected CharacterData createCharacterData(String text) throws IOException, SAXException, ParserConfigurationException { protected CharacterData createCharacterData(String text) throws IOException, SAXException, ParserConfigurationException {
@ -42,3 +48,4 @@ public class CommentTest extends AbstractCharacterDataTest {
return document.createComment(text); return document.createComment(text);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,9 +31,9 @@ import static org.w3c.dom.DOMException.NAMESPACE_ERR;
import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED; import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED;
import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS;
import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.DOMException; import org.w3c.dom.DOMException;
@ -42,9 +42,14 @@ import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.DocumentTest
* @run testng/othervm org.w3c.dom.ptests.DocumentTest
* @summary Test createAttributeNS, getElementsByTagNameNS and createElementNS method of Document * @summary Test createAttributeNS, getElementsByTagNameNS and createElementNS method of Document
*/ */
public class DocumentTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class DocumentTest {
@DataProvider(name = "invalid-nsuri") @DataProvider(name = "invalid-nsuri")
public Object[][] getInvalidNamespaceURI() { public Object[][] getInvalidNamespaceURI() {
@ -170,3 +175,4 @@ public class DocumentTest extends JAXPFileBaseTest {
doc.createElement("!nc$%^*(!"); doc.createElement("!nc$%^*(!");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,17 +25,22 @@ package org.w3c.dom.ptests;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.w3c.dom.ptests.DOMTestUtil.createDOM; import static org.w3c.dom.ptests.DOMTestUtil.createDOM;
import jaxp.library.JAXPFileBaseTest;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.DocumentType; import org.w3c.dom.DocumentType;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.DocumentTypeTest
* @run testng/othervm org.w3c.dom.ptests.DocumentTypeTest
* @summary Test DocumentType * @summary Test DocumentType
*/ */
public class DocumentTypeTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class DocumentTypeTest {
/* /*
* Test testGetEntities method, and verify the entity items. * Test testGetEntities method, and verify the entity items.
@ -87,3 +92,4 @@ public class DocumentTypeTest extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,18 +27,22 @@ import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import jaxp.library.JAXPBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.DOMImplementation; import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.DocumentType; import org.w3c.dom.DocumentType;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.DomImplementationTest
* @run testng/othervm org.w3c.dom.ptests.DomImplementationTest
* @summary Test DomImplementation API * @summary Test DomImplementation API
*/ */
public class DomImplementationTest extends JAXPBaseTest { @Listeners({jaxp.library.BasePolicy.class})
public class DomImplementationTest {
/* /*
* Test createDocument method with a namespace uri, qualified name and null * Test createDocument method with a namespace uri, qualified name and null
* for the doctype * for the doctype
@ -125,3 +129,4 @@ public class DomImplementationTest extends JAXPBaseTest {
assertEquals(documentType.getName(), name); assertEquals(documentType.getName(), name);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,9 +37,8 @@ import java.io.StringReader;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.DOMException; import org.w3c.dom.DOMException;
@ -50,9 +49,14 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.ElementTest
* @run testng/othervm org.w3c.dom.ptests.ElementTest
* @summary Test for the methods of Element Interface * @summary Test for the methods of Element Interface
*/ */
public class ElementTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class ElementTest {
@Test @Test
public void testGetAttributeNS() throws Exception { public void testGetAttributeNS() throws Exception {
Document document = createDOMWithNS("ElementSample01.xml"); Document document = createDOMWithNS("ElementSample01.xml");
@ -251,3 +255,4 @@ public class ElementTest extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,17 +30,21 @@ import java.io.File;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import jaxp.library.JAXPFileBaseTest; import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.EntityChildTest
* @run testng/othervm org.w3c.dom.ptests.EntityChildTest
* @summary Test DOM Parser: parsing an xml file that contains external entities. * @summary Test DOM Parser: parsing an xml file that contains external entities.
*/ */
public class EntityChildTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class EntityChildTest {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
@ -57,3 +61,4 @@ public class EntityChildTest extends JAXPFileBaseTest {
assertEquals(nl.getLength(), 3); assertEquals(nl.getLength(), 3);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,8 +25,8 @@ package org.w3c.dom.ptests;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -35,9 +35,14 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.NamedNodeMapTest
* @run testng/othervm org.w3c.dom.ptests.NamedNodeMapTest
* @summary Test for the methods of NamedNodeMap Interface * @summary Test for the methods of NamedNodeMap Interface
*/ */
public class NamedNodeMapTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class NamedNodeMapTest {
/* /*
* Test setNamedItemNS method with a node having the same namespaceURI and * Test setNamedItemNS method with a node having the same namespaceURI and
* qualified name as an existing one, and then test with a non-existing node. * qualified name as an existing one, and then test with a non-existing node.
@ -116,3 +121,4 @@ public class NamedNodeMapTest extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,20 +24,25 @@ package org.w3c.dom.ptests;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.w3c.dom.ptests.DOMTestUtil.createDOM; import static org.w3c.dom.ptests.DOMTestUtil.createDOM;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.NodeListTest
* @run testng/othervm org.w3c.dom.ptests.NodeListTest
* @summary Verifies a bug found in jaxp1.0.1 and 1.1FCS. After going out of * @summary Verifies a bug found in jaxp1.0.1 and 1.1FCS. After going out of
* bound, the last element of a NodeList returns null. The bug has been fixed * bound, the last element of a NodeList returns null. The bug has been fixed
* in jaxp 1.1.1 build. * in jaxp 1.1.1 build.
*/ */
public class NodeListTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class NodeListTest {
@DataProvider(name = "xml") @DataProvider(name = "xml")
public Object[][] getTestData() { public Object[][] getTestData() {
@ -59,3 +64,4 @@ public class NodeListTest extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,7 @@
package org.w3c.dom.ptests; package org.w3c.dom.ptests;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotEquals;
@ -33,6 +34,7 @@ import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS;
import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument; import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument;
import java.io.File; import java.io.File;
import java.util.PropertyPermission;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
@ -41,9 +43,8 @@ import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.DOMException; import org.w3c.dom.DOMException;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -53,9 +54,14 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.NodeTest
* @run testng/othervm org.w3c.dom.ptests.NodeTest
* @summary Test Node interface * @summary Test Node interface
*/ */
public class NodeTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class NodeTest {
@DataProvider(name = "feature-supported") @DataProvider(name = "feature-supported")
public Object[][] getFeatureSupportedList() throws Exception { public Object[][] getFeatureSupportedList() throws Exception {
Document document = createDOMWithNS("Node01.xml"); Document document = createDOMWithNS("Node01.xml");
@ -153,7 +159,7 @@ public class NodeTest extends JAXPFileBaseTest {
String outputfile = "InsertBefore.out"; String outputfile = "InsertBefore.out";
String goldfile = GOLDEN_DIR + "InsertBeforeGF.out"; String goldfile = GOLDEN_DIR + "InsertBeforeGF.out";
outputXml(document, outputfile); tryRunWithTmpPermission(() -> outputXml(document, outputfile), new PropertyPermission("user.dir", "read"));
assertTrue(compareWithGold(goldfile, outputfile)); assertTrue(compareWithGold(goldfile, outputfile));
} }
@ -171,7 +177,7 @@ public class NodeTest extends JAXPFileBaseTest {
String outputfile = "ReplaceChild3.out"; String outputfile = "ReplaceChild3.out";
String goldfile = GOLDEN_DIR + "ReplaceChild3GF.out"; String goldfile = GOLDEN_DIR + "ReplaceChild3GF.out";
outputXml(document, outputfile); tryRunWithTmpPermission(() -> outputXml(document, outputfile), new PropertyPermission("user.dir", "read"));
assertTrue(compareWithGold(goldfile, outputfile)); assertTrue(compareWithGold(goldfile, outputfile));
} }
@ -205,3 +211,4 @@ public class NodeTest extends JAXPFileBaseTest {
transformer.transform(domSource, streamResult); transformer.transform(domSource, streamResult);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,8 +29,7 @@ import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import jaxp.library.JAXPFileBaseTest; import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
@ -38,9 +37,14 @@ import org.w3c.dom.Notation;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.NotationTest
* @run testng/othervm org.w3c.dom.ptests.NotationTest
* @summary Test for Notation interface * @summary Test for Notation interface
*/ */
public class NotationTest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class NotationTest {
/* /*
* Test getSystemId method. * Test getSystemId method.
*/ */
@ -70,3 +74,4 @@ public class NotationTest extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,16 +24,21 @@ package org.w3c.dom.ptests;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS; import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS;
import jaxp.library.JAXPFileBaseTest;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.ProcessingInstruction;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.PITest
* @run testng/othervm org.w3c.dom.ptests.PITest
* @summary Test for the methods of Processing Instruction * @summary Test for the methods of Processing Instruction
*/ */
public class PITest extends JAXPFileBaseTest { @Listeners({jaxp.library.FilePolicy.class})
public class PITest {
/* /*
* Test getData, setData and getTarget methods * Test getData, setData and getTarget methods
*/ */
@ -49,3 +54,4 @@ public class PITest extends JAXPFileBaseTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,6 +30,7 @@ import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.CharacterData; import org.w3c.dom.CharacterData;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -39,8 +40,13 @@ import org.w3c.dom.Text;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/* /*
* @test
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/functional
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.TextTest
* @run testng/othervm org.w3c.dom.ptests.TextTest
* @summary Test for Text implementation returned by Document.createTextNode(String) * @summary Test for Text implementation returned by Document.createTextNode(String)
*/ */
@Listeners({jaxp.library.FilePolicy.class})
public class TextTest extends AbstractCharacterDataTest { public class TextTest extends AbstractCharacterDataTest {
/* /*
* Verify splitText method works as the spec. * Verify splitText method works as the spec.
@ -68,3 +74,4 @@ public class TextTest extends AbstractCharacterDataTest {
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,8 +30,7 @@ import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import jaxp.library.JAXPBaseTest; import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -39,9 +38,14 @@ import org.w3c.dom.TypeInfo;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
/* /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.w3c.dom.ptests.TypeInfoTest
* @run testng/othervm org.w3c.dom.ptests.TypeInfoTest
* @summary Test getTypeName and getTypeNamespace methods of TypeInfo interface * @summary Test getTypeName and getTypeNamespace methods of TypeInfo interface
*/ */
public class TypeInfoTest extends JAXPBaseTest { @Listeners({jaxp.library.BasePolicy.class})
public class TypeInfoTest {
/* /*
* Get the TypeInfo of the root element, and verify it. * Get the TypeInfo of the root element, and verify it.
*/ */
@ -136,3 +140,4 @@ public class TypeInfoTest extends JAXPBaseTest {
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,16 +22,24 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
/** /**
* Class containing the test cases for AttributesImpl API. * Class containing the test cases for AttributesImpl API.
*/ */
public class AttrImplTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.AttrImplTest
* @run testng/othervm org.xml.sax.ptests.AttrImplTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class AttrImplTest {
private static final String CAR_URI = "http://www.cars.com/xml"; private static final String CAR_URI = "http://www.cars.com/xml";
private static final String CAR_LOCALNAME = "part"; private static final String CAR_LOCALNAME = "part";
@ -194,3 +202,5 @@ public class AttrImplTest extends JAXPBaseTest {
attr.removeAttribute(1); attr.removeAttribute(1);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,17 +22,20 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.File;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR; import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.File;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/** /**
* This tests the Attributes interface. Here the startElement() callback of * This tests the Attributes interface. Here the startElement() callback of
* ContentHandler has Attributes as one of its arguments. Attributes * ContentHandler has Attributes as one of its arguments. Attributes
@ -40,7 +43,14 @@ import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
* of Attributes interfaces are tested. This program uses Namespace processing * of Attributes interfaces are tested. This program uses Namespace processing
* with namespaces in XML file. This program does not use Validation * with namespaces in XML file. This program does not use Validation
*/ */
public class AttributesNSTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.AttributesNSTest
* @run testng/othervm org.xml.sax.ptests.AttributesNSTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class AttributesNSTest {
/** /**
* Test for Attribute Interface's setter/getter. * Test for Attribute Interface's setter/getter.
* *
@ -64,3 +74,5 @@ public class AttributesNSTest extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,17 +22,20 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.File;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR; import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.File;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/** /**
* This tests the Attributes interface. Here the startElement() callback of * This tests the Attributes interface. Here the startElement() callback of
* ContentHandler has Attributes as one of its arguments. Attributes * ContentHandler has Attributes as one of its arguments. Attributes
@ -41,7 +44,14 @@ import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
* This program uses Namespace processing without any namepsaces in xml file. * This program uses Namespace processing without any namepsaces in xml file.
* This program uses Validation * This program uses Validation
*/ */
public class AttributesTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.AttributesTest
* @run testng/othervm org.xml.sax.ptests.AttributesTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class AttributesTest {
/** /**
* Unit test for Attributes interface. Prints all attributes into output * Unit test for Attributes interface. Prints all attributes into output
* file. Check it with golden file. * file. Check it with golden file.
@ -66,3 +76,5 @@ public class AttributesTest extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,15 +22,20 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import org.testng.annotations.Listeners;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -38,15 +43,20 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLFilterImpl; import org.xml.sax.helpers.XMLFilterImpl;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* Class registers a content event handler to XMLReader. Content event handler * Class registers a content event handler to XMLReader. Content event handler
* transverses XML and print all visited node when XMLreader parses XML. Test * transverses XML and print all visited node when XMLreader parses XML. Test
* verifies output is same as the golden file. * verifies output is same as the golden file.
*/ */
public class ContentHandlerTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.ContentHandlerTest
* @run testng/othervm org.xml.sax.ptests.ContentHandlerTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class ContentHandlerTest {
/** /**
* Content event handler visit all nodes to print to output file. * Content event handler visit all nodes to print to output file.
* *
@ -254,3 +264,5 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable {
bWriter.close(); bWriter.close();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,30 +22,40 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import org.testng.annotations.Listeners;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.Locator; import org.xml.sax.Locator;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* XMLReader parse XML with default handler that transverses XML and * XMLReader parse XML with default handler that transverses XML and
* print all visited node. Test verifies output is same as the golden file. * print all visited node. Test verifies output is same as the golden file.
*/ */
public class DefaultHandlerTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.DefaultHandlerTest
* @run testng/othervm org.xml.sax.ptests.DefaultHandlerTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class DefaultHandlerTest {
/** /**
* Test default handler that transverses XML and print all visited node. * Test default handler that transverses XML and print all visited node.
* *
@ -262,3 +272,5 @@ class MyDefaultHandler extends DefaultHandler {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,31 +22,41 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLFilterImpl; import org.xml.sax.helpers.XMLFilterImpl;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* ErrorHandler unit test. Set a ErrorHandle to XMLReader. Capture fatal error * ErrorHandler unit test. Set a ErrorHandle to XMLReader. Capture fatal error
* events in ErrorHandler. * events in ErrorHandler.
*/ */
public class EHFatalTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.EHFatalTest
* @run testng/othervm org.xml.sax.ptests.EHFatalTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class EHFatalTest {
/** /**
* Error Handler to capture all error events to output file. Verifies the * Error Handler to capture all error events to output file. Verifies the
* output file is same as golden file. * output file is same as golden file.
@ -125,3 +135,5 @@ class MyErrorHandler extends XMLFilterImpl implements AutoCloseable {
bWriter.close(); bWriter.close();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,17 +22,26 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.util.Enumeration;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import java.util.Enumeration;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.helpers.NamespaceSupport; import org.xml.sax.helpers.NamespaceSupport;
/** /**
* Unit test cases for NamespaceSupport API * Unit test cases for NamespaceSupport API
*/ */
public class NSSupportTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.NSSupportTest
* @run testng/othervm org.xml.sax.ptests.NSSupportTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class NSSupportTest {
/** /**
* Empty prefix name. * Empty prefix name.
*/ */
@ -122,3 +131,5 @@ public class NSSupportTest extends JAXPBaseTest {
assertNull(support.getURI(DC_PREFIX)); assertNull(support.getURI(DC_PREFIX));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,11 +22,13 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
@ -34,7 +36,14 @@ import org.xml.sax.XMLReader;
* Class containing the test cases for Namespace Table defined at * Class containing the test cases for Namespace Table defined at
* http://www.megginson.com/SAX/Java/namespaces.html * http://www.megginson.com/SAX/Java/namespaces.html
*/ */
public class NSTableTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.NSTableTest
* @run testng/othervm org.xml.sax.ptests.NSTableTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class NSTableTest {
private static final String NAMESPACES = private static final String NAMESPACES =
"http://xml.org/sax/features/namespaces"; "http://xml.org/sax/features/namespaces";
private static final String NAMESPACE_PREFIXES = private static final String NAMESPACE_PREFIXES =
@ -159,3 +168,5 @@ public class NSTableTest extends JAXPBaseTest {
assertFalse(spf.getFeature(NAMESPACE_PREFIXES)); assertFalse(spf.getFeature(NAMESPACE_PREFIXES));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,12 +22,16 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.ContentHandler; import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -37,14 +41,20 @@ import org.xml.sax.XMLReader;
import org.xml.sax.helpers.ParserAdapter; import org.xml.sax.helpers.ParserAdapter;
import org.xml.sax.helpers.XMLFilterImpl; import org.xml.sax.helpers.XMLFilterImpl;
import org.xml.sax.helpers.XMLReaderAdapter; import org.xml.sax.helpers.XMLReaderAdapter;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* Unit test cases for ParserAdapter API. By default the only features recognized * Unit test cases for ParserAdapter API. By default the only features recognized
* are namespaces and namespace-prefixes. * are namespaces and namespace-prefixes.
*/ */
public class ParserAdapterTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.ParserAdapterTest
* @run testng/othervm org.xml.sax.ptests.ParserAdapterTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class ParserAdapterTest {
/** /**
* namespaces feature name. * namespaces feature name.
*/ */
@ -234,7 +244,7 @@ public class ParserAdapterTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class) @Test(expectedExceptions = SAXException.class)
public void parse02() throws Exception { public void parse02() throws Exception {
try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) { try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) {
InputSource is = new InputSource(fis); InputSource is = new InputSource(fis);
@ -247,7 +257,7 @@ public class ParserAdapterTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void parse03() throws Exception { public void parse03() throws Exception {
try(FileInputStream fis = new FileInputStream(XML_DIR + "correct.xml")) { try(FileInputStream fis = new FileInputStream(XML_DIR + "correct.xml")) {
InputSource is = new InputSource(fis); InputSource is = new InputSource(fis);
@ -255,3 +265,5 @@ public class ParserAdapterTest extends JAXPFileReadOnlyBaseTest {
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,28 +22,45 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import org.testng.annotations.Listeners;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLFilterImpl; import org.xml.sax.helpers.XMLFilterImpl;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* Entity resolver should be invoked in XML parse. This test verifies parsing * Entity resolver should be invoked in XML parse. This test verifies parsing
* process by checking the output with golden file. * process by checking the output with golden file.
*/ */
public class ResolverTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.ResolverTest
* @run testng/othervm org.xml.sax.ptests.ResolverTest
*/
@Test
@Listeners({jaxp.library.FilePolicy.class})
public class ResolverTest {
/** /**
* Unit test for entityResolver setter. * Unit test for entityResolver setter.
* *
@ -54,6 +71,11 @@ public class ResolverTest extends JAXPFileBaseTest {
String goldFile = GOLDEN_DIR + "EntityResolverGF.out"; String goldFile = GOLDEN_DIR + "EntityResolverGF.out";
String xmlFile = XML_DIR + "publish.xml"; String xmlFile = XML_DIR + "publish.xml";
Files.copy(Paths.get(XML_DIR + "publishers.dtd"),
Paths.get(USER_DIR + "publishers.dtd"), REPLACE_EXISTING);
Files.copy(Paths.get(XML_DIR + "familytree.dtd"),
Paths.get(USER_DIR + "familytree.dtd"), REPLACE_EXISTING);
try(FileInputStream instream = new FileInputStream(xmlFile); try(FileInputStream instream = new FileInputStream(xmlFile);
MyEntityResolver eResolver = new MyEntityResolver(outputFile)) { MyEntityResolver eResolver = new MyEntityResolver(outputFile)) {
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
@ -97,7 +119,7 @@ class MyEntityResolver extends XMLFilterImpl implements AutoCloseable {
@Override @Override
public InputSource resolveEntity(String publicid, String systemid) public InputSource resolveEntity(String publicid, String systemid)
throws SAXException, IOException { throws SAXException, IOException {
String str = "In resolveEntity.." + " " + publicid + " " + systemid; String str = "In resolveEntity.." + " " + publicid + " " + getFileName(systemid);
bWriter.write( str, 0,str.length()); bWriter.write( str, 0,str.length());
bWriter.newLine(); bWriter.newLine();
return super.resolveEntity(publicid, systemid); return super.resolveEntity(publicid, systemid);
@ -112,4 +134,14 @@ class MyEntityResolver extends XMLFilterImpl implements AutoCloseable {
bWriter.flush(); bWriter.flush();
bWriter.close(); bWriter.close();
} }
private String getFileName(String systemid) {
try {
return Paths.get(new URI(systemid)).getFileName().toString();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,21 +22,31 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.File;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR; import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.File;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/** /**
* This class contains the testcases to test SAXParser with regard to * This class contains the testcases to test SAXParser with regard to
* Namespace Table defined at http://www.megginson.com/SAX/Java/namespaces.html * Namespace Table defined at http://www.megginson.com/SAX/Java/namespaces.html
*/ */
public class SAXParserNSTableTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.SAXParserNSTableTest
* @run testng/othervm org.xml.sax.ptests.SAXParserNSTableTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class SAXParserNSTableTest {
/** /**
* namespace processing is enabled. namespace-prefix is also is enabled. * namespace processing is enabled. namespace-prefix is also is enabled.
* So it is a True-True combination. * So it is a True-True combination.
@ -97,3 +107,5 @@ public class SAXParserNSTableTest extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,15 +22,21 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import org.testng.annotations.Listeners;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.Locator; import org.xml.sax.Locator;
@ -38,14 +44,20 @@ import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLFilterImpl; import org.xml.sax.helpers.XMLFilterImpl;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* Set parent of XMLFilter to XMLReader. Parsing on XML file will invoke XMLFilter * Set parent of XMLFilter to XMLReader. Parsing on XML file will invoke XMLFilter
* to write to output file. Test verifies output is same as the golden file. * to write to output file. Test verifies output is same as the golden file.
*/ */
public class XMLFilterCBTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.XMLFilterCBTest
* @run testng/othervm org.xml.sax.ptests.XMLFilterCBTest
*/
@Test
@Listeners({jaxp.library.FilePolicy.class})
public class XMLFilterCBTest {
/** /**
* Test XMLFilter working with XML reader. * Test XMLFilter working with XML reader.
* *
@ -273,3 +285,5 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable {
bWriter.close(); bWriter.close();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,23 +22,33 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLFilterImpl; import org.xml.sax.helpers.XMLFilterImpl;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* Unit test for XMLFilter. * Unit test for XMLFilter.
*/ */
public class XMLFilterTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.XMLFilterTest
* @run testng/othervm org.xml.sax.ptests.XMLFilterTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class XMLFilterTest {
/** /**
* name spaces constant. * name spaces constant.
*/ */
@ -217,7 +227,7 @@ public class XMLFilterTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void parse02() throws Exception { public void parse02() throws Exception {
try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) { try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) {
new XMLFilterImpl().parse(new InputSource(fis)); new XMLFilterImpl().parse(new InputSource(fis));
@ -229,10 +239,12 @@ public class XMLFilterTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void parse03() throws Exception { public void parse03() throws Exception {
try(FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) { try(FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) {
new XMLFilterImpl().parse(new InputSource(fis)); new XMLFilterImpl().parse(new InputSource(fis));
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,24 +22,33 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.FileInputStream;
import java.io.FilePermission;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPBaseTest;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.HandlerBase; import org.xml.sax.HandlerBase;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderAdapter; import org.xml.sax.helpers.XMLReaderAdapter;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* Class containing the test cases for XMLReaderAdapter API * Class containing the test cases for XMLReaderAdapter API
*/ */
public class XMLReaderAdapterTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.XMLReaderAdapterTest
* @run testng/othervm org.xml.sax.ptests.XMLReaderAdapterTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class XMLReaderAdapterTest {
/** /**
* http://xml.org/sax/features/namespace-prefixes property name. * http://xml.org/sax/features/namespace-prefixes property name.
*/ */
@ -92,7 +101,6 @@ public class XMLReaderAdapterTest extends JAXPBaseTest {
*/ */
@Test @Test
public void parse01() throws Exception { public void parse01() throws Exception {
setPermissions(new FilePermission(XML_DIR + "/-", "read"));
try (FileInputStream fis = new FileInputStream(XML_DIR + "namespace1.xml")) { try (FileInputStream fis = new FileInputStream(XML_DIR + "namespace1.xml")) {
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
if (!xmlReader.getFeature(NM_PREFIXES_PROPERTY)) { if (!xmlReader.getFeature(NM_PREFIXES_PROPERTY)) {
@ -102,6 +110,7 @@ public class XMLReaderAdapterTest extends JAXPBaseTest {
xmlRA.setDocumentHandler(new HandlerBase()); xmlRA.setDocumentHandler(new HandlerBase());
xmlRA.parse(new InputSource(fis)); xmlRA.parse(new InputSource(fis));
} }
setPermissions();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,8 +22,11 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import jaxp.library.JAXPBaseTest; import static jaxp.library.JAXPTestUtilities.setSystemProperty;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.XMLReaderFactory; import org.xml.sax.helpers.XMLReaderFactory;
@ -31,7 +34,14 @@ import org.xml.sax.helpers.XMLReaderFactory;
/** /**
* Unit test for XMLReaderFactory.createXMLReader API. * Unit test for XMLReaderFactory.createXMLReader API.
*/ */
public class XMLReaderFactoryTest extends JAXPBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.XMLReaderFactoryTest
* @run testng/othervm org.xml.sax.ptests.XMLReaderFactoryTest
*/
@Listeners({jaxp.library.BasePolicy.class})
public class XMLReaderFactoryTest {
/** /**
* No exception expected when create XMLReader by default. * No exception expected when create XMLReader by default.
* @throws org.xml.sax.SAXException when xml reader creation failed. * @throws org.xml.sax.SAXException when xml reader creation failed.
@ -66,3 +76,5 @@ public class XMLReaderFactoryTest extends JAXPBaseTest {
XMLReaderFactory.createXMLReader("org.apache.crimson.parser.ABCD"); XMLReaderFactory.createXMLReader("org.apache.crimson.parser.ABCD");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,23 +22,35 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileBaseTest;
import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.USER_DIR;
import static jaxp.library.JAXPTestUtilities.compareWithGold; import static jaxp.library.JAXPTestUtilities.compareWithGold;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR; import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR; import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
/** This class contains the testcases to test XMLReader with regard to /** This class contains the testcases to test XMLReader with regard to
* Namespace Table defined at * Namespace Table defined at
* http://www.megginson.com/SAX/Java/namespaces.html * http://www.megginson.com/SAX/Java/namespaces.html
*/ */
public class XMLReaderNSTableTest extends JAXPFileBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.XMLReaderNSTableTest
* @run testng/othervm org.xml.sax.ptests.XMLReaderNSTableTest
*/
@Test
@Listeners({jaxp.library.FilePolicy.class})
public class XMLReaderNSTableTest {
/** /**
* XML file that used to be parsed. * XML file that used to be parsed.
*/ */
@ -109,7 +121,7 @@ public class XMLReaderNSTableTest extends JAXPFileBaseTest {
String goldFile = GOLDEN_DIR + "NSTableFTGF.out"; String goldFile = GOLDEN_DIR + "NSTableFTGF.out";
SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true); //NamespaceAware is false by default, so don't need to set here
XMLReader xmlReader = spf.newSAXParser().getXMLReader(); XMLReader xmlReader = spf.newSAXParser().getXMLReader();
try (FileInputStream fis = new FileInputStream(xmlFile); try (FileInputStream fis = new FileInputStream(xmlFile);
MyNSContentHandler handler = new MyNSContentHandler(outputFile)) { MyNSContentHandler handler = new MyNSContentHandler(outputFile)) {
@ -119,3 +131,5 @@ public class XMLReaderNSTableTest extends JAXPFileBaseTest {
assertTrue(compareWithGold(goldFile, outputFile)); assertTrue(compareWithGold(goldFile, outputFile));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,14 +22,18 @@
*/ */
package org.xml.sax.ptests; package org.xml.sax.ptests;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParserFactory;
import jaxp.library.JAXPFileReadOnlyBaseTest;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
import java.io.FileInputStream;
import javax.xml.parsers.SAXParserFactory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -39,12 +43,18 @@ import org.xml.sax.XMLReader;
import org.xml.sax.ext.DeclHandler; import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler; import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.XMLFilterImpl; import org.xml.sax.helpers.XMLFilterImpl;
import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
/** /**
* Class containing the test cases for SAXParser API * Class containing the test cases for SAXParser API
*/ */
public class XMLReaderTest extends JAXPFileReadOnlyBaseTest { /*
* @test
* @library /javax/xml/jaxp/libs
* @run testng/othervm -DrunSecMngr=true org.xml.sax.ptests.XMLReaderTest
* @run testng/othervm org.xml.sax.ptests.XMLReaderTest
*/
@Listeners({jaxp.library.FilePolicy.class})
public class XMLReaderTest {
/** /**
* XML namespaces. * XML namespaces.
@ -434,7 +444,7 @@ public class XMLReaderTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class) @Test(expectedExceptions = SAXException.class)
public void parse02() throws Exception { public void parse02() throws Exception {
try (FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) { try (FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) {
SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParserFactory spf = SAXParserFactory.newInstance();
@ -448,7 +458,7 @@ public class XMLReaderTest extends JAXPFileReadOnlyBaseTest {
* *
* @throws Exception If any errors occur. * @throws Exception If any errors occur.
*/ */
@Test(groups = {"readLocalFiles"}) @Test
public void parse03() throws Exception { public void parse03() throws Exception {
try (FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) { try (FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) {
SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParserFactory spf = SAXParserFactory.newInstance();
@ -661,3 +671,5 @@ class MyDeclHandler implements DeclHandler {
public void internalEntityDecl(String name, String value) { public void internalEntityDecl(String name, String value) {
} }
} }

View File

@ -0,0 +1 @@
<familytree>purplelustrous</familytree>

View File

@ -1,2 +1,2 @@
In resolveEntity.. -//mkrishna mohan//DTD//music pub//EN/ http://sc11152338.us.oracle.com:8080/xmlsqe/jaxp/web/testfiles/JAXPREP/publishers.dtd In resolveEntity.. -//mkrishna mohan//DTD//music pub//EN/ publishers.dtd
In resolveEntity.. null http://sc11152338.us.oracle.com:8080/xmlsqe/jaxp/web/testfiles/JAXPREP/familytree.dtd In resolveEntity.. null familytree.dtd

Some files were not shown because too many files have changed in this diff Show More