8067170: Enable security manager on JAXP unit tests and make some improvement
authorfyuan
Mon, 08 Aug 2016 12:50:00 +0800
changeset 40223 64662417aa2d
parent 40222 ec0a4bdb7a07
child 40224 7e5f4746e87c
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 Contributed-by: Frank Yuan <frank.yuan@oracle.com>
jaxp/test/ProblemList.txt
jaxp/test/TEST.ROOT
jaxp/test/javax/xml/jaxp/functional/TEST.properties
jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java
jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java
jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AbstractCharacterDataTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java
jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/SAXParserNSTableTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/familytree.dtd
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/out/EntityResolverGF.out
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/out/NSTableFTGF.out
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/publish.xml
jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/publishers.dtd
jaxp/test/javax/xml/jaxp/functional/test/astro/AstroTest.java
jaxp/test/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java
jaxp/test/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java
jaxp/test/javax/xml/jaxp/functional/test/astro/SAX201Test.java
jaxp/test/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java
jaxp/test/javax/xml/jaxp/functional/test/astro/XPathAPITest.java
jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java
jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java
jaxp/test/javax/xml/jaxp/functional/test/auctionportal/UserController.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java
jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java
jaxp/test/javax/xml/jaxp/internaltest/TEST.properties
jaxp/test/javax/xml/jaxp/internaltest/javax/xml/parsers/bug8003147/Bug8003147Test.java
jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/bug6551616/Bug6551616.java
jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/cli/CLITest.java
jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/cli/ProcessXSLT.java
jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/cli/tigertest-in.xml
jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/cli/tigertest.xsl
jaxp/test/javax/xml/jaxp/isolatedjdk/TEST.properties
jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/BasePolicy.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/FilePolicy.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/InternalAPIPolicy.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPBaseTest.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPFileBaseTest.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPFileReadOnlyBaseTest.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPPolicyManager.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/NetAccessPolicy.java
jaxp/test/javax/xml/jaxp/libs/jaxp/library/TestPolicy.java
jaxp/test/javax/xml/jaxp/libs/test/astro/DOML3InputSourceFactoryImpl.java
jaxp/test/javax/xml/jaxp/module/TEST.properties
jaxp/test/javax/xml/jaxp/unittest/TEST.properties
jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java
jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java
jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java
jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java
jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java
jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java
jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java
jaxp/test/javax/xml/jaxp/unittest/common/Bug6350682.java
jaxp/test/javax/xml/jaxp/unittest/common/Bug6723276Test.java
jaxp/test/javax/xml/jaxp/unittest/common/Bug6941169Test.java
jaxp/test/javax/xml/jaxp/unittest/common/Bug7143711Test.java
jaxp/test/javax/xml/jaxp/unittest/common/Sources.java
jaxp/test/javax/xml/jaxp/unittest/common/TestSAXDriver.java
jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java
jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java
jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6320118.java
jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937951Test.java
jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937964Test.java
jaxp/test/javax/xml/jaxp/unittest/datatype/Bug7042647Test.java
jaxp/test/javax/xml/jaxp/unittest/datatype/DatatypeFactoryTest.java
jaxp/test/javax/xml/jaxp/unittest/datatype/DurationTest.java
jaxp/test/javax/xml/jaxp/unittest/datatype/FactoryFindTest.java
jaxp/test/javax/xml/jaxp/unittest/datatype/JDK8068839Test.java
jaxp/test/javax/xml/jaxp/unittest/datatype/XMLGregorianCalendarTest.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915524.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915748.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966082.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966138.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966142.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966143.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug6339023.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug6355326.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug6367542.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug6520131.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug6521260.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug6582545Test.java
jaxp/test/javax/xml/jaxp/unittest/dom/Bug6879614Test.java
jaxp/test/javax/xml/jaxp/unittest/dom/CR6333993Test.java
jaxp/test/javax/xml/jaxp/unittest/dom/CR6517707Test.java
jaxp/test/javax/xml/jaxp/unittest/dom/CR6517717Test.java
jaxp/test/javax/xml/jaxp/unittest/dom/CR6909336Test.java
jaxp/test/javax/xml/jaxp/unittest/dom/DOMConfigurationTest.java
jaxp/test/javax/xml/jaxp/unittest/dom/DOMXPathTest.java
jaxp/test/javax/xml/jaxp/unittest/dom/ElementTraversal.java
jaxp/test/javax/xml/jaxp/unittest/dom/JdkXmlDomTest.java
jaxp/test/javax/xml/jaxp/unittest/dom/TCKEncodingTest.java
jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug4973153.java
jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6290947.java
jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6354955.java
jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6376823.java
jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6710741Test.java
jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTCKTest.java
jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTest.java
jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSSerializerTest.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4674384_MAX_OCCURS_Test.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4934208.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4967002.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4985486.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991020.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991946.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5010072.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5025825.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6309988.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6361283.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6506304Test.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6518733.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6564400.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786ErrorHandler.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6594813.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6608841.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6690015.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6760982.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6849942Test.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7157608Test.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7166896Test.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147Test.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147TestClass.java
jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8073385.java
jaxp/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java
jaxp/test/javax/xml/jaxp/unittest/parsers/MyDefaultHandler.java
jaxp/test/javax/xml/jaxp/unittest/parsers/MyErrorHandler.java
jaxp/test/javax/xml/jaxp/unittest/parsers/ParseEmptyStream.java
jaxp/test/javax/xml/jaxp/unittest/parsers/SupplementaryChars.java
jaxp/test/javax/xml/jaxp/unittest/parsers/xinclude/Bug6794483Test.java
jaxp/test/javax/xml/jaxp/unittest/policy/PolicyUtil.java
jaxp/test/javax/xml/jaxp/unittest/policy/common.policy
jaxp/test/javax/xml/jaxp/unittest/sax/Attributes2ImplTest.java
jaxp/test/javax/xml/jaxp/unittest/sax/Bug6889654Test.java
jaxp/test/javax/xml/jaxp/unittest/sax/Bug6925410Test.java
jaxp/test/javax/xml/jaxp/unittest/sax/Bug6949607Test.java
jaxp/test/javax/xml/jaxp/unittest/sax/Bug6992561Test.java
jaxp/test/javax/xml/jaxp/unittest/sax/Bug7057778Test.java
jaxp/test/javax/xml/jaxp/unittest/sax/DefaultHandler2Test.java
jaxp/test/javax/xml/jaxp/unittest/sax/IssueTracker56Test.java
jaxp/test/javax/xml/jaxp/unittest/sax/MyDefaultHandler2.java
jaxp/test/javax/xml/jaxp/unittest/sax/NSSupportTest.java
jaxp/test/javax/xml/jaxp/unittest/sax/SAXExceptionExt.java
jaxp/test/javax/xml/jaxp/unittest/sax/XMLReaderTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/AttributeLocalNameTest/AttributeLocalNameTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/Bug6370703.java
jaxp/test/javax/xml/jaxp/unittest/stream/Bug6378422.java
jaxp/test/javax/xml/jaxp/unittest/stream/Bug6380870.java
jaxp/test/javax/xml/jaxp/unittest/stream/Bug6489502.java
jaxp/test/javax/xml/jaxp/unittest/stream/Bug6509774.java
jaxp/test/javax/xml/jaxp/unittest/stream/Bug6688002Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/Bug6976938Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/CoalesceTest/CoalesceTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/EntitiesTest/EntityTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/EventReaderDelegateTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue41Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue48Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue53Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue58Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/FactoryFindTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/IgnoreExternalDTDTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/ProcessingInstructionTest/ProcessingInstructionTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/StreamReaderDelegateTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventLocationTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6489890.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6555001.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6586466Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6613059Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6668115Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6846133Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug8153781.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Issue40Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/ReaderToWriterTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/XMLEventWriterTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6756677Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6909759Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/IssueTracker38.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/MyInputFactory.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/Bug6846132Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/DuplicateNSDeclarationTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/StreamResultTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLResolverTest/XMLResolverTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481615.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481678.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTypeFilter.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BOMTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6388460.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6472982Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6767322Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6847819Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DefaultAttributeTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DoubleXmlnsTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IsValidatingTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue44Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue47Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker24.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker35.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker70.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req5Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req8Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/NamespaceTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/StreamReaderTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/SupportDTDTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/VoiceXMLDTDTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/XML11Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/AttributeEscapeTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6452107.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6600882Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6675332Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug7037352Test.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DOMUtil.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DomUtilTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EmptyElementTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EncodingTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NamespaceTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NullUriDetectionTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SqeLinuxTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SurrogatesTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/UnprefixedNameTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/WriterTest.java
jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug4693341Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug4892774.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug5073477.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6175602.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6206491.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6216226Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6311448.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6384805.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6465722.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6467808.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490380.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490921.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6513892.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6537167.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6540545.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6551616.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6559595.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6565260.java
jaxp/test/javax/xml/jaxp/unittest/transform/Bug6940416.java
jaxp/test/javax/xml/jaxp/unittest/transform/BugDB12665704Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CLITest.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6401137Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600.policy
jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6577667Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6652519Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6689809Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6905829Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6935697Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6941869Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR6957215Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/CR7098746Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/DOMResultTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/DocumentExtFunc.java
jaxp/test/javax/xml/jaxp/unittest/transform/FactoryFindTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/Issue2204Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/Issue2290Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/OpenJDK100017Test.java
jaxp/test/javax/xml/jaxp/unittest/transform/ProcessXSLT.java
jaxp/test/javax/xml/jaxp/unittest/transform/SAX2DOMTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/SourceTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/TemplatesTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/TransformerFactoryTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/TransformerUtilFactory.java
jaxp/test/javax/xml/jaxp/unittest/transform/VersionDefaultHandler.java
jaxp/test/javax/xml/jaxp/unittest/transform/VersionEventWriter.java
jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java
jaxp/test/javax/xml/jaxp/unittest/transform/sax/Bug6451633.java
jaxp/test/javax/xml/jaxp/unittest/transform/util/DOMUtil.java
jaxp/test/javax/xml/jaxp/unittest/transform/util/SAXUtil.java
jaxp/test/javax/xml/jaxp/unittest/transform/util/StAXUtil.java
jaxp/test/javax/xml/jaxp/unittest/transform/util/StreamUtil.java
jaxp/test/javax/xml/jaxp/unittest/util/BOMInputStream.java
jaxp/test/javax/xml/jaxp/unittest/util/BaseStAXUT.java
jaxp/test/javax/xml/jaxp/unittest/validation/6773084.policy
jaxp/test/javax/xml/jaxp/unittest/validation/AnyElementTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966232.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966254.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969042.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969089.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969110.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969689.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969692.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969693.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969695.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969732.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970380.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970383.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970400.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970402.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970951.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971605.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971607.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4972882.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4986844.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4987574.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988267.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988268.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988387.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4996446.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug4997818.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug5011500.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug5072946.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6378043.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6449797.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6467424Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6483188.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6493687.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6509668.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6526547.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6531160.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6695843Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6859210.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6925531Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6946312Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/Bug6954738_Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/CR6708840Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/CR6740048.java
jaxp/test/javax/xml/jaxp/unittest/validation/ErrorHandlerImpl.java
jaxp/test/javax/xml/jaxp/unittest/validation/Issue682Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/IssueTracker30.java
jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue43Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue49.java
jaxp/test/javax/xml/jaxp/unittest/validation/LargeMaxOccursTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursUnboundedTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/OccursTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/OccursUnboundedTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardUnbounded.java
jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesId005Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesIg004Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesQ013Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/SchemaTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/TCKGroupA008Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/ValidatorTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/XMLDocBuilder.java
jaxp/test/javax/xml/jaxp/unittest/validation/XMLSchemaValidator.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6943252Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963124Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963468Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6964720Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6967214Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6970890Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6971190Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6974551Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6975265Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6977201Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6989956Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug7014246Test.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/ParticleTest.java
jaxp/test/javax/xml/jaxp/unittest/validation/tck/RegexWord.java
jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991857.java
jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991939.java
jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992788.java
jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992793.java
jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992805.java
jaxp/test/javax/xml/jaxp/unittest/xpath/ClassLoaderTest.java
jaxp/test/javax/xml/jaxp/unittest/xpath/MyClassLoader.java
jaxp/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java
jaxp/test/javax/xml/jaxp/unittest/xpath/XPathAnyTypeTest.java
jaxp/test/javax/xml/jaxp/unittest/xpath/XPathExpAnyTypeTest.java
jaxp/test/javax/xml/jaxp/unittest/xpath/XPathTest.java
jaxp/test/javax/xml/jaxp/unittest/xpath/XPathTestBase.java
--- a/jaxp/test/ProblemList.txt	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/ProblemList.txt	Mon Aug 08 12:50:00 2016 +0800
@@ -27,4 +27,4 @@
 
 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
--- a/jaxp/test/TEST.ROOT	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/TEST.ROOT	Mon Aug 08 12:50:00 2016 +0800
@@ -14,6 +14,11 @@
 # Tests that must run in othervm mode
 othervm.dirs=javax/xml/jaxp
 
+lib.dirs = /javax/xml/jaxp/libs
+
+# Declare module dependency
+modules=java.xml
+
 # Group definitions
 groups=TEST.groups
 
--- a/jaxp/test/javax/xml/jaxp/functional/TEST.properties	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
-
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,17 +28,21 @@
 import javax.xml.catalog.CatalogException;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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
  *          a (partial) closed circuit. For instance, a catalog may use itself
  *          as an additional catalog specified in its own nextCatalog entry.
  *          This case tests if the implementation handles this issue.
- * @compile ../../libs/catalog/CatalogTestUtils.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CatalogReferCircularityTest {
 
     @Test(dataProvider = "catalogName",
@@ -49,7 +53,7 @@
     }
 
     @DataProvider(name = "catalogName")
-    private Object[][] catalogName() {
+    public Object[][] catalogName() {
         return new Object[][] {
                 // This catalog defines itself as next catalog.
                 { "catalogReferCircle-itself.xml" },
@@ -60,3 +64,4 @@
                 { "catalogReferCircle-left.xml" } };
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,13 +29,18 @@
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DefaultFeaturesTest {
 
     private CatalogFeatures defaultFeature;
@@ -56,7 +61,7 @@
     }
 
     @DataProvider(name = "feature-value")
-    private Object[][] data() {
+    public Object[][] data() {
         return new Object[][] {
                 { Feature.FILES, null },
                 { Feature.PREFER, CatalogTestUtils.PREFER_PUBLIC },
@@ -64,3 +69,4 @@
                 { Feature.RESOLVE, CatalogTestUtils.RESOLVE_STRICT } };
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
 import static catalog.CatalogTestUtils.getCatalogPath;
 import static javax.xml.catalog.CatalogFeatures.Feature.DEFER;
 import static javax.xml.catalog.CatalogManager.catalog;
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+import static jaxp.library.JAXPTestUtilities.tryRunWithAllPerm;
 
 import java.lang.reflect.Method;
 
@@ -36,16 +38,20 @@
 
 import org.testng.Assert;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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,
  *          delegatePublic, delegateURI and nextCatalog entries are used lazily
  *          in resolution via defer feature.
- * @compile ../../libs/catalog/CatalogTestUtils.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DeferFeatureTest {
 
     @Test(dataProvider = "catalog-countOfLoadedCatalogFile")
@@ -55,7 +61,7 @@
     }
 
     @DataProvider(name = "catalog-countOfLoadedCatalogFile")
-    private Object[][] data() {
+    public Object[][] data() {
         return new Object[][]{
             // By default, alternative catalogs are not loaded.
             {createCatalog(CatalogFeatures.defaults()), 0},
@@ -75,9 +81,9 @@
     }
 
     private int loadedCatalogCount(Catalog catalog) throws Exception {
-        Method method = catalog.getClass().getDeclaredMethod(
-                "loadedCatalogCount");
-        method.setAccessible(true);
+        Method method = tryRunWithAllPerm(() -> catalog.getClass().getDeclaredMethod("loadedCatalogCount"));
+        runWithAllPerm(() -> method.setAccessible(true));
         return (int) method.invoke(catalog);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,18 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DelegatePublicTest {
 
     @Test(dataProvider = "publicId-matchedUri")
@@ -48,7 +51,7 @@
     }
 
     @DataProvider(name = "publicId-matchedUri")
-    private Object[][] dataOnMatch() {
+    public Object[][] dataOnMatch() {
         return new Object[][] {
                 // The matched URI of the specified public id is defined in
                 // a delegate catalog file of the current catalog file.
@@ -79,7 +82,7 @@
     }
 
     @DataProvider(name = "publicId-expectedExceptionClass")
-    private Object[][] dataOnException() {
+    public Object[][] dataOnException() {
         return new Object[][] {
                 // The matched delegatePublic entry of the specified public id
                 // defines a non-existing delegate catalog file. That should
@@ -97,3 +100,4 @@
         return catalogResolver("delegatePublic.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,18 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DelegateSystemTest {
 
     @Test(dataProvider = "systemId-matchedUri")
@@ -48,7 +51,7 @@
     }
 
     @DataProvider(name = "systemId-matchedUri")
-    private Object[][] dataOnMatch() {
+    public Object[][] dataOnMatch() {
         return new Object[][] {
                 // The matched URI of the specified system id is defined in
                 // a delegate catalog file of the current catalog file.
@@ -79,7 +82,7 @@
     }
 
     @DataProvider(name = "systemId-expectedExceptionClass")
-    private Object[][] dataOnException() {
+    public Object[][] dataOnException() {
         return new Object[][] {
                 // The matched delegateSystem entry of the specified system id
                 // defines a non-existing delegate catalog file. That should
@@ -97,3 +100,4 @@
         return catalogResolver("delegateSystem.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,18 @@
 import javax.xml.catalog.CatalogUriResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DelegateUriTest {
 
     @Test(dataProvider = "uri-matchedUri")
@@ -48,7 +51,7 @@
     }
 
     @DataProvider(name = "uri-matchedUri")
-    private Object[][] data() {
+    public Object[][] data() {
         return new Object[][] {
                 // The matched URI of the specified URI reference is defined in
                 // a delegate catalog file of the current catalog file.
@@ -78,7 +81,7 @@
     }
 
     @DataProvider(name = "uri-expectedExceptionClass")
-    private Object[][] dataOnException() {
+    public Object[][] dataOnException() {
         return new Object[][] {
                 // The matched delegateURI entry of the specified URI reference
                 // defines a non-existing delegate catalog file. That should
@@ -96,3 +99,4 @@
         return catalogUriResolver("delegateUri.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,16 +32,19 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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,
  *          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 {
 
     private static final String CATALOG_GROUP = "group.xml";
@@ -52,7 +55,7 @@
     }
 
     @DataProvider(name = "systemId-matchedUri")
-    private Object[][] dataOnSysId() {
+    public Object[][] dataOnSysId() {
         return new Object[][] {
                 // The matched URI of the specified system id is enclosed by a
                 // group entry.
@@ -78,7 +81,7 @@
     }
 
     @DataProvider(name = "publicId-matchedUri")
-    private Object[][] dataOnPubId() {
+    public Object[][] dataOnPubId() {
         return new Object[][] {
                 // The matched URI of the specified public id is enclosed by a
                 // group entry.
@@ -104,7 +107,7 @@
     }
 
     @DataProvider(name = "uri-matchedUri")
-    private Object[][] dataOnUri() {
+    public Object[][] dataOnUri() {
         return new Object[][] {
                 // The matched URI of the specified URI reference is enclosed by
                 // a group entry.
@@ -128,3 +131,4 @@
         return catalogResolver(CATALOG_GROUP);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,17 +36,20 @@
 import javax.xml.catalog.CatalogUriResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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
  *          and the catalog files specified by the nextCatalog entries may not
  *          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 {
 
     private static final String CATALOG_LOADCATALOGFILES = "loadCatalogFiles.xml";
@@ -62,7 +65,7 @@
     }
 
     @DataProvider(name = "entityResolver")
-    private Object[][] entityResolver() {
+    public Object[][] entityResolver() {
         return new Object[][] {
                 // This EntityResolver loads multiple catalog files one by one.
                 // All of the files are available.
@@ -82,7 +85,7 @@
     }
 
     @DataProvider(name = "uriResolver")
-    private Object[][] uriResolver() {
+    public Object[][] uriResolver() {
         return new Object[][] {
                 // This URIResolver loads multiple catalog files one by one.
                 // All of the files are available.
@@ -108,7 +111,7 @@
     }
 
     @DataProvider(name = "catalogName")
-    private Object[][] catalogName() {
+    public Object[][] catalogName() {
         return new Object[][] {
                 // This catalog file set includes null catalog files.
                 { (String[]) null },
@@ -118,3 +121,4 @@
                 { new String[] { CATALOG_LOADCATALOGFILES } } };
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,16 +33,19 @@
 import javax.xml.catalog.CatalogUriResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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,
  *          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 {
 
     private static final String CATALOG_NEXTCATALOGLEFT
@@ -56,7 +59,7 @@
     }
 
     @DataProvider(name = "systemId-matchedUri")
-    private Object[][] dataOnSysId() {
+    public Object[][] dataOnSysId() {
         return new Object[][] {
                 // This matched URI of the specified system id is defined in a
                 // next catalog file.
@@ -88,7 +91,7 @@
     }
 
     @DataProvider(name = "publicId-matchedUri")
-    private Object[][] dataOnPubId() {
+    public Object[][] dataOnPubId() {
         return new Object[][] {
                 // This matched URI of the specified public id is defined in a
                 // next catalog file.
@@ -120,7 +123,7 @@
     }
 
     @DataProvider(name = "uri-matchedUri")
-    private Object[][] dataOnUri() {
+    public Object[][] dataOnUri() {
         return new Object[][] {
                 // This matched URI of the specified URI reference is defined in
                 // a next catalog file.
@@ -156,3 +159,4 @@
                 CATALOG_NEXTCATALOGRIGHT);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,18 +33,21 @@
 import javax.xml.catalog.CatalogUriResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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
  *          the passed identifiers and URI references. And then the catalog
  *          resolver uses the normalized stuff to search the counterparts in
  *          catalog files.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class NormalizationTest {
 
     private static final String CATALOG_NORMALIZATION = "normalization.xml";
@@ -65,7 +68,7 @@
     }
 
     @DataProvider(name = "systemId_uri-matchedUri")
-    private Object[][] dataOnSysIdAndUri() {
+    public Object[][] dataOnSysIdAndUri() {
         return new Object[][] {
                 // The specified system id/URI reference contains spaces. And
                 // the counterparts in system/uri entries also contain spaces.
@@ -87,7 +90,7 @@
     }
 
     @DataProvider(name = "publicId-matchedUri")
-    private Object[][] dataOnPubId() {
+    public Object[][] dataOnPubId() {
         return new Object[][] {
                 // The specified public id contains spaces. And the counterparts
                 // in public entry also contains spaces.
@@ -112,3 +115,4 @@
         return catalogUriResolver(CATALOG_NORMALIZATION);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,16 +33,20 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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,
  *          and tests the priority between this feature and attribute prefer
  *          in catalog file.
- * @compile ../../libs/catalog/CatalogTestUtils.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class PreferFeatureTest {
 
     @Test(dataProvider = "prefer-publicId-systemId",
@@ -53,7 +57,7 @@
     }
 
     @DataProvider(name = "prefer-publicId-systemId")
-    private Object[][] data() {
+    public Object[][] data() {
         return new Object[][] {
                 // The feature prefer is system. There's a match for the
                 // specified public id, and no match for the specified system id.
@@ -77,3 +81,4 @@
                 "preferFeature.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,18 +29,21 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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
  *          specify the prefer attribute. It tests how does the prefer attribute
  *          affect the resolution procedure. The test rule is based on OASIS
  *          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 {
 
     @Test(dataProvider = "publicId-systemId-matchedUri")
@@ -50,7 +53,7 @@
     }
 
     @DataProvider(name = "publicId-systemId-matchedUri")
-    private Object[][] data() {
+    public Object[][] data() {
         return new Object[][] {
                 // The prefer attribute is public. Both of the specified public
                 // id and system id have matches in the catalog file. But
@@ -89,3 +92,4 @@
         return catalogResolver("prefer.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,18 +30,21 @@
 import javax.xml.catalog.CatalogException;
 import javax.xml.catalog.CatalogResolver;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
  *          It tests the resolution priorities among the public family entries.
  *          The test rule is based on OASIS 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 PublicFamilyTest {
 
     /*
@@ -67,3 +70,4 @@
         return catalogResolver("publicFamily.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,15 +32,18 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class PublicTest {
 
     @Test(dataProvider = "publicId-matchedUri")
@@ -89,3 +92,4 @@
         return catalogResolver(CATALOG_PUBLIC);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,16 +40,19 @@
 import javax.xml.catalog.CatalogResolver;
 import javax.xml.catalog.CatalogUriResolver;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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
  *          resolution.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class ResolveFeatureTest {
 
     /*
@@ -128,3 +131,4 @@
         return builder().with(Feature.RESOLVE, resolve).build();
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,18 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class RewriteSystemTest {
 
     @Test(dataProvider = "systemId-matchedUri")
@@ -92,3 +95,4 @@
         return catalogResolver("rewriteSystem.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,18 @@
 import javax.xml.catalog.CatalogUriResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class RewriteUriTest {
 
     @Test(dataProvider = "uri-matchedUri")
@@ -92,3 +95,4 @@
         return catalogUriResolver("rewriteUri.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 
 package catalog;
 
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import static catalog.CatalogTestUtils.FEATURE_FILES;
 import static catalog.CatalogTestUtils.catalogResolver;
 import static catalog.CatalogTestUtils.catalogUriResolver;
@@ -36,15 +38,18 @@
 import javax.xml.catalog.CatalogResolver;
 import javax.xml.catalog.CatalogUriResolver;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class SpecifyCatalogTest {
 
     private static final String ID_URI = "http://remote/dtd/uri/doc.dtd";
@@ -76,7 +81,7 @@
      */
     @Test
     public void specifyCatalogViaSysProps() {
-        System.setProperty(FEATURE_FILES,
+        setSystemProperty(FEATURE_FILES,
                 getCatalogPath("specifyCatalog-sysProps.xml"));
 
         checkResolutionOnEntityResolver(catalogResolver((String[]) null),
@@ -106,3 +111,4 @@
         return builder().with(FILES, getCatalogPath(catalogName)).build();
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,18 +31,21 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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
  *          delegateSystem entries. It tests the resolution priorities among
  *          the system family entries. The test rule is based on OASIS
  *          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 {
 
     @Test(dataProvider = "systemId-matchedUri")
@@ -81,3 +84,4 @@
         return catalogResolver("systemFamily.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,18 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class SystemSuffixTest {
 
     @Test(dataProvider = "systemId-matchedUri")
@@ -92,3 +95,4 @@
         return catalogResolver("systemSuffix.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,15 +32,18 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class SystemTest {
 
     @Test(dataProvider = "systemId-matchedUri")
@@ -89,3 +92,4 @@
         return catalogResolver(CATALOG_SYSTEM);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,18 +31,21 @@
 import javax.xml.catalog.CatalogUriResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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
  *          entries. It tests the resolution priorities among the uri family
  *          entries. The test rule is based on OASIS Standard V1.1 section
  *          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 {
 
     @Test(dataProvider = "uri-matchedUri")
@@ -81,3 +84,4 @@
         return catalogUriResolver("uriFamily.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,18 @@
 import javax.xml.catalog.CatalogUriResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class UriSuffixTest {
 
     @Test(dataProvider = "uri-matchedUri")
@@ -92,3 +95,4 @@
         return catalogUriResolver("uriSuffix.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,15 +34,18 @@
 import javax.xml.catalog.CatalogUriResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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.
- * @compile ../../libs/catalog/CatalogTestUtils.java
- * @compile ../../libs/catalog/ResolutionChecker.java
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class UriTest {
 
     @Test(dataProvider = "uri-matchedUri")
@@ -101,3 +104,4 @@
         return catalogUriResolver(CATALOG_URI);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,17 +29,20 @@
 import javax.xml.catalog.CatalogResolver;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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:",
  *          it has to be regarded as URN and normalized. And then the catalog
  *          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 {
 
     @Test(dataProvider = "urn-matchedUri")
@@ -48,7 +51,7 @@
     }
 
     @DataProvider(name = "urn-matchedUri")
-    private Object[][] data() {
+    public Object[][] data() {
         return new Object[][] {
                 // The specified public id is URN format.
                 { "urn:publicid:-:REMOTE:DTD+ALICE+DOCALICE+XML:EN",
@@ -64,3 +67,4 @@
         return catalogResolver("urnUnwrapping.xml");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,17 +32,20 @@
 
 import javax.xml.catalog.CatalogException;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
  * @test
  * @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
  *          must be catalog, and the naming space of the root element must be
  *          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 {
 
     private static final String CATALOG_WRONGROOT = "validateCatalog-wrongRoot.xml";
@@ -99,3 +102,4 @@
                 "http://local/dtd/docAliceURI.dtd");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,17 +44,21 @@
 import javax.xml.datatype.Duration;
 import javax.xml.namespace.QName;
 
-import jaxp.library.JAXPBaseTest;
-
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 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.
  */
-public class DurationTest extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class DurationTest {
 
     private DatatypeFactory datatypeFactory;
 
@@ -583,3 +587,4 @@
     private final BigInteger one = BigInteger.ONE;
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,15 +30,20 @@
 import javax.xml.datatype.Duration;
 
 import jaxp.library.JAXPDataProvider;
-import jaxp.library.JAXPBaseTest;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 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)
  */
-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";
 
@@ -72,3 +77,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,18 +39,22 @@
 import javax.xml.datatype.Duration;
 import javax.xml.datatype.XMLGregorianCalendar;
 
-import jaxp.library.JAXPBaseTest;
-
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @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
  */
-public class XMLGregorianCalendarTest extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class XMLGregorianCalendarTest {
 
     private DatatypeFactory datatypeFactory;
 
@@ -354,3 +358,4 @@
     private final int undef = DatatypeConstants.FIELD_UNDEFINED;
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,18 +23,21 @@
 
 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.compareWithGold;
 import static org.testng.Assert.assertTrue;
+
 import java.io.File;
+
 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.dom.DOMSource;
 import javax.xml.transform.sax.SAXResult;
-import jaxp.library.JAXPFileBaseTest;
+
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
@@ -42,7 +45,14 @@
  * This tests DocumentBuilderFactory for namespace processing and no-namespace
  * 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.
@@ -95,3 +105,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,6 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.io.FilePermission;
 import java.io.FileReader;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -55,9 +54,9 @@
 import javax.xml.transform.sax.SAXResult;
 
 import jaxp.library.JAXPDataProvider;
-import jaxp.library.JAXPFileBaseTest;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -70,7 +69,14 @@
  * @bug 8080907
  * 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.
      */
@@ -419,8 +425,6 @@
     @Test
     public void testCheckDocumentBuilderFactory13() throws Exception {
         // Accesing default working directory.
-        String workingDir = getSystemProperty("user.dir");
-        setPermissions(new FilePermission(workingDir + "/*", "read"));
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         DocumentBuilder docBuilder = dbf.newDocumentBuilder();
         Document doc = docBuilder.parse(new File(XML_DIR + "dbf10import.xsl")
@@ -436,8 +440,6 @@
     @Test(expectedExceptions = SAXException.class)
     public void testCheckDocumentBuilderFactory14() throws Exception {
         // Accesing default working directory.
-        String workingDir = getSystemProperty("user.dir");
-        setPermissions(new FilePermission(workingDir, "read"));
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         DocumentBuilder docBuilder = dbf.newDocumentBuilder();
         docBuilder.parse("");
@@ -529,3 +531,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,18 +23,21 @@
 
 package javax.xml.parsers.ptests;
 
+import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
 import static jaxp.library.JAXPTestUtilities.FILE_SEP;
 import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FilePermission;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 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.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
@@ -42,8 +45,14 @@
 /**
  * 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.
      *
@@ -82,7 +91,7 @@
      * @param docBuilder document builder instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "builder-provider")
+    @Test(dataProvider = "builder-provider")
     public void testCheckDocumentBuilderImpl04(DocumentBuilder docBuilder)
             throws Exception {
         try (FileInputStream fis = new FileInputStream(new File(XML_DIR,
@@ -97,7 +106,7 @@
      * @param docBuilder document builder instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "builder-provider")
+    @Test(dataProvider = "builder-provider")
     public void testCheckDocumentBuilderImpl05(DocumentBuilder docBuilder)
             throws Exception {
         assertNotNull(docBuilder.parse(new File(XML_DIR,
@@ -109,11 +118,9 @@
      * @param docBuilder document builder instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "builder-provider")
+    @Test(dataProvider = "builder-provider")
     public void testCheckDocumentBuilderImpl06(DocumentBuilder docBuilder)
             throws Exception {
-        setPermissions(new FilePermission(XML_DIR + "../-",
-                "read"));
         try (FileInputStream fis = new FileInputStream(new File(XML_DIR,
                 "DocumentBuilderImpl02.xml"))) {
             assertNotNull(docBuilder.parse(fis, new File(XML_DIR).toURI()
@@ -150,3 +157,5 @@
             return null;
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,20 +23,30 @@
 
 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.FactoryConfigurationError;
 import javax.xml.parsers.SAXParserFactory;
-import jaxp.library.JAXPBaseTest;
 
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /**
  * Class containing the test cases for SAXParserFactory/DocumentBuilderFactory
  * 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
@@ -54,8 +64,8 @@
      */
     @AfterTest
     public void cleanup() {
-        setSystemProperty("javax.xml.parsers.DocumentBuilderFactory", null);
-        setSystemProperty("javax.xml.parsers.SAXParserFactory", null);
+        clearSystemProperty("javax.xml.parsers.DocumentBuilderFactory");
+        clearSystemProperty("javax.xml.parsers.SAXParserFactory");
     }
 
     /**
@@ -76,3 +86,5 @@
         DocumentBuilderFactory.newInstance();
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,16 +31,21 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import jaxp.library.JAXPDataProvider;
-import jaxp.library.JAXPBaseTest;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 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)
  */
-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";
 
@@ -73,3 +78,5 @@
     }
 
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,23 @@
 package javax.xml.parsers.ptests;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
+
 import javax.xml.parsers.SAXParserFactory;
-import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /**
  * 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 NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes";
@@ -220,3 +229,5 @@
         assertFalse(spf.getFeature(EXTERNAL_P_ENTITIES));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,15 +23,23 @@
 
 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.FileInputStream;
 import java.io.FilePermission;
 import java.io.IOException;
+import java.util.PropertyPermission;
+
 import javax.xml.parsers.SAXParser;
 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.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.HandlerBase;
 import org.xml.sax.InputSource;
@@ -41,7 +49,14 @@
 /**
  * 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.
      *
@@ -92,13 +107,7 @@
     @Test(expectedExceptions = { SAXException.class },
             dataProvider = "parser-provider")
     public void testParse03(SAXParser saxparser) throws Exception {
-        String workingDir = getSystemProperty("user.dir");
-        setPermissions(new FilePermission(workingDir, "read"));
-        try {
-            saxparser.parse("", new HandlerBase());
-        } finally {
-            setPermissions();
-        }
+        saxparser.parse("", new HandlerBase());
     }
 
     /**
@@ -124,13 +133,7 @@
      */
     @Test(expectedExceptions = SAXException.class, dataProvider = "parser-provider")
     public void testParse05(SAXParser saxparser) throws Exception {
-        String workingDir = getSystemProperty("user.dir");
-        setPermissions(new FilePermission(workingDir, "read"));
-        try {
-            saxparser.parse(new File(""), new HandlerBase());
-        } finally {
-            setPermissions();
-        }
+        tryRunWithTmpPermission(() -> saxparser.parse(new File(""), new HandlerBase()), new PropertyPermission("user.dir", "read"));
     }
 
     /**
@@ -176,23 +179,18 @@
     }
 
     /**
-     * Test with non-existence URI, parsing should fail and throw
-     * SAXException or IOException.
+     * Test with non-existence URI, parsing should fail and throw SAXException
+     * or IOException.
      *
-     * @param saxparser a SAXParser instance.
-     * @throws Exception If any errors occur.
+     * @param saxparser
+     *            a SAXParser instance.
+     * @throws Exception
+     *             If any errors occur.
      */
-    @Test(expectedExceptions = { SAXException.class, IOException.class },
-            dataProvider = "parser-provider")
+    @Test(expectedExceptions = { SAXException.class, IOException.class }, dataProvider = "parser-provider")
     public void testParse09(SAXParser saxparser) throws Exception {
-        String workingDir = getSystemProperty("user.dir");
-        setPermissions(new FilePermission(workingDir + "/../-", "read"));
-        String uri = " ";
-        try {
-            saxparser.parse(uri, new DefaultHandler());
-        } finally {
-            setPermissions();
-        }
+        JAXPTestUtilities.tryRunWithTmpPermission(() -> saxparser.parse(" ", new DefaultHandler()),
+                new FilePermission(USER_DIR + " ", "read"));
     }
 
     /**
@@ -204,14 +202,8 @@
      */
     @Test(expectedExceptions = SAXException.class, dataProvider = "parser-provider")
     public void testParse10(SAXParser saxparser) throws Exception {
-        String workingDir = getSystemProperty("user.dir");
-        setPermissions(new FilePermission(workingDir, "read"));
         File file = new File("");
-        try {
-            saxparser.parse(file, new DefaultHandler());
-        } finally {
-            setPermissions();
-        }
+        tryRunWithTmpPermission(() -> saxparser.parse(file, new DefaultHandler()), new PropertyPermission("user.dir", "read"));
     }
 
     /**
@@ -248,7 +240,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class,
+    @Test(expectedExceptions = SAXException.class,
             dataProvider = "parser-provider")
     public void testParse13(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(new File(
@@ -263,7 +255,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse14(SAXParser saxparser) throws Exception {
         saxparser.parse(new File(XML_DIR, "parsertest.xml"),
                 new HandlerBase());
@@ -276,7 +268,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse15(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(new File(XML_DIR,
                 "correct.xml"))) {
@@ -291,7 +283,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse16(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(
                 new File(XML_DIR, "parsertest.xml"))) {
@@ -306,7 +298,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse17(SAXParser saxparser) throws Exception {
         File file = new File(XML_DIR, "correct.xml");
         saxparser.parse(file.toURI().toASCIIString(), new HandlerBase());
@@ -319,7 +311,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class,
+    @Test(expectedExceptions = SAXException.class,
             dataProvider = "parser-provider")
     public void testParse18(SAXParser saxparser) throws Exception {
         saxparser.parse(new File(XML_DIR, "valid.xml"), new HandlerBase());
@@ -332,7 +324,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse19(SAXParser saxparser) throws Exception {
         saxparser.parse(new File(XML_DIR, "correct.xml"), new HandlerBase());
     }
@@ -344,7 +336,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class,
+    @Test(expectedExceptions = SAXException.class,
             dataProvider = "parser-provider")
     public void testParse20(SAXParser saxparser) throws Exception {
         try(FileInputStream instream = new FileInputStream(new File(XML_DIR,
@@ -360,7 +352,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse21(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(new File(XML_DIR,
                 "correct.xml"))) {
@@ -375,7 +367,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class,
+    @Test(expectedExceptions = SAXException.class,
             dataProvider = "parser-provider")
     public void testParse22(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(
@@ -391,7 +383,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse23(SAXParser saxparser) throws Exception {
         DefaultHandler handler = new DefaultHandler();
         saxparser.parse(new File(XML_DIR, "parsertest.xml"), handler);
@@ -404,7 +396,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse24(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(new File(XML_DIR,
                 "correct.xml"))) {
@@ -420,7 +412,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse25(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(
                 new File(XML_DIR, "parsertest.xml"))) {
@@ -435,7 +427,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse26(SAXParser saxparser) throws Exception {
         File file = new File(XML_DIR, "correct.xml");
         saxparser.parse(file.toURI().toASCIIString(), new DefaultHandler());
@@ -448,7 +440,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class,
+    @Test(expectedExceptions = SAXException.class,
             dataProvider = "parser-provider")
     public void testParse27(SAXParser saxparser) throws Exception {
         saxparser.parse(new File(XML_DIR, "valid.xml"), new DefaultHandler());
@@ -461,7 +453,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse28(SAXParser saxparser) throws Exception {
         saxparser.parse(new File(XML_DIR, "correct.xml"), new DefaultHandler());
     }
@@ -472,7 +464,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class,
+    @Test(expectedExceptions = SAXException.class,
             dataProvider = "parser-provider")
     public void testParse29(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(
@@ -487,7 +479,7 @@
      * @param saxparser a SAXParser instance.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "parser-provider")
+    @Test(dataProvider = "parser-provider")
     public void testParse30(SAXParser saxparser) throws Exception {
         try (FileInputStream instream = new FileInputStream(
                 new File(XML_DIR, "correct.xml"))) {
@@ -500,7 +492,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testParse31() throws Exception {
         try (FileInputStream instream = new FileInputStream(
                 new File(XML_DIR, "ns4.xml"))) {
@@ -510,3 +502,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,15 @@
 package javax.xml.parsers.ptests;
 
 import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
+
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
-import jaxp.library.JAXPBaseTest;
-import static org.testng.Assert.assertNotNull;
+
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotSupportedException;
@@ -40,7 +42,14 @@
 /**
  * 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 XML_STRING = "http://xml.org/sax/properties/xml-string";
     private static final String DECL_HANDLER = "http://xml.org/sax/properties/declaration-handler";
@@ -260,3 +269,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,25 +23,32 @@
 
 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.assertTrue;
+import static org.testng.Assert.fail;
+
 import java.io.File;
-import java.io.FilePermission;
+
 import javax.xml.parsers.SAXParser;
 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.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /**
  * 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.
@@ -63,7 +70,7 @@
      * @param handler an error handler for capturing events.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "input-provider")
+    @Test(dataProvider = "input-provider")
     public void testParseValidate01(SAXParserFactory spf, MyErrorHandler handler)
             throws Exception {
             spf.newSAXParser().parse(new File(XML_DIR, "parsertest.xml"), handler);
@@ -78,7 +85,7 @@
      * @param handler an error handler for capturing events.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "input-provider")
+    @Test(dataProvider = "input-provider")
     public void testParseValidate02(SAXParserFactory spf, MyErrorHandler handler)
             throws Exception {
             spf.setNamespaceAware(true);
@@ -95,7 +102,7 @@
      * @param handler an error handler for capturing events.
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, dataProvider = "input-provider")
+    @Test(dataProvider = "input-provider")
     public void testParseValidate03(SAXParserFactory spf, MyErrorHandler handler)
             throws Exception {
         try {
@@ -109,3 +116,5 @@
     }
 
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,20 +23,28 @@
 
 package javax.xml.stream.ptests;
 
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+
 import static org.testng.Assert.assertNotNull;
 
 import javax.xml.stream.XMLEventFactory;
 
 import jaxp.library.JAXPDataProvider;
-import jaxp.library.JAXPBaseTest;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 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)
  */
-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_FACRORY_ID = "javax.xml.stream.XMLEventFactory";
@@ -59,7 +67,7 @@
             XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader);
             assertNotNull(xef);
         } finally {
-            setSystemProperty(XMLEVENT_FACRORY_ID, null);
+            clearSystemProperty(XMLEVENT_FACRORY_ID);
         }
     }
 
@@ -74,3 +82,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,20 +23,28 @@
 
 package javax.xml.stream.ptests;
 
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+
 import static org.testng.Assert.assertNotNull;
 
 import javax.xml.stream.XMLInputFactory;
 
 import jaxp.library.JAXPDataProvider;
-import jaxp.library.JAXPBaseTest;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 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)
  */
-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_FACRORY_ID = "javax.xml.stream.XMLInputFactory";
@@ -59,7 +67,7 @@
             XMLInputFactory xif = XMLInputFactory.newFactory(factoryId, classLoader);
             assertNotNull(xif);
         } finally {
-            setSystemProperty(XMLINPUT_FACRORY_ID, null);
+            clearSystemProperty(XMLINPUT_FACRORY_ID);
         }
     }
 
@@ -74,3 +82,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 
 package javax.xml.transform.ptests;
 
+import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 
@@ -34,17 +36,20 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
-import jaxp.library.JAXPFileBaseTest;
-import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
 /*
+ * @test
  * @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
  */
-public class Bug6384418Test extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class Bug6384418Test {
 
     @Test
     public void test() throws Exception {
@@ -62,3 +67,5 @@
     }
 
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,20 +23,23 @@
 
 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.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.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.compareWithGold;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.NamedNodeMap;
@@ -50,7 +53,14 @@
  * DOM parse on test file to be compared with golden output file. No Exception
  * 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.
      * @throws Exception If any errors occur.
@@ -108,3 +118,5 @@
                 writeNodes(kids.item(i), bWriter);
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,23 +23,32 @@
 
 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.FilePermission;
+
 import javax.xml.transform.ErrorListener;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
-import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
 import javax.xml.transform.stream.StreamSource;
-import jaxp.library.JAXPBaseTest;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /**
  * 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.
      */
@@ -60,7 +69,6 @@
         try {
             TransformerFactory tfactory = TransformerFactory.newInstance();
             tfactory.setErrorListener (listener);
-            setPermissions(new FilePermission(XML_DIR + "invalid.xsl", "read"));
             tfactory.newTransformer(new StreamSource(
                                         new File(XML_DIR + "invalid.xsl")));
             fail("Expect TransformerConfigurationException here");
@@ -96,3 +104,5 @@
         this.status = ListenerStatus.FATAL;
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,18 +23,21 @@
 
 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.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 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.assertNotNull;
-import static org.testng.Assert.assertNull;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 
@@ -42,7 +45,14 @@
 /**
  * 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
      */
@@ -53,7 +63,7 @@
      *
      * @throws IOException reading file error.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void source2inputsource01() throws IOException {
         try (FileInputStream fis = new FileInputStream(TEST_FILE)) {
             StreamSource streamSource = new StreamSource(fis);
@@ -68,7 +78,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void source2inputsource02() throws Exception {
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
@@ -83,7 +93,7 @@
      *
      * @throws IOException reading file error.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void source2inputsource03() throws IOException {
         String SYSTEM_ID = "file:///" + XML_DIR;
         try (FileInputStream fis = new FileInputStream(TEST_FILE)) {
@@ -95,3 +105,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,27 +23,30 @@
 
 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.FileInputStream;
 import java.io.FileOutputStream;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.Result;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerFactory;
 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.SAXTransformerFactory;
 import javax.xml.transform.sax.TemplatesHandler;
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -56,7 +59,14 @@
  * Test newTransformerhandler() method which takes StreamSource as argument can
  * 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.
      */
@@ -421,3 +431,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,11 +22,16 @@
  */
 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.FileInputStream;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Properties;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -34,12 +39,10 @@
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 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.StreamSource;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.failUnexpected;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
@@ -48,7 +51,14 @@
  * Test a StreamResult using a file name that contains URL characters that need
  * 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.
      */
@@ -96,3 +106,5 @@
         });
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,20 +22,23 @@
  */
 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.FileInputStream;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerFactory;
 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.stream.StreamSource;
-import jaxp.library.JAXPFileReadOnlyBaseTest;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -44,7 +47,14 @@
 /**
  * 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.
      */
@@ -128,7 +138,7 @@
      * @throws TransformerConfigurationException If for some reason the
      *         TransformerHandler can not be created.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void clear05() throws TransformerConfigurationException {
         Transformer transformer = TransformerFactory.newInstance().
                 newTransformer(new StreamSource(new File(XSL_FILE)));
@@ -143,7 +153,7 @@
      * @throws TransformerConfigurationException If for some reason the
      *         TransformerHandler can not be created.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void clear06() throws TransformerConfigurationException {
         Transformer transformer = TransformerFactory.newInstance().
                 newTransformer(new StreamSource(new File(XSL_FILE)));
@@ -157,7 +167,7 @@
      * the a name that set before. Value should be same as set one.
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void clear07() throws Exception {
         try (FileInputStream fis = new FileInputStream(XSL_FILE)) {
             SAXSource saxSource = new SAXSource();
@@ -174,7 +184,7 @@
      * the a name that wasn't set before. Null is expected.
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void clear08() throws Exception {
         try (FileInputStream fis = new FileInputStream(XSL_FILE)) {
             SAXSource saxSource = new SAXSource();
@@ -192,7 +202,7 @@
      * the a name that set before. Value should be same as set one.
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void clear09() throws Exception {
         TransformerFactory tfactory = TransformerFactory.newInstance();
 
@@ -213,7 +223,7 @@
      * the a name that wasn't set before. Null is expected.
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void clear10() throws Exception {
         TransformerFactory tfactory = TransformerFactory.newInstance();
 
@@ -229,3 +239,5 @@
         assertNull(transformer.getParameter(LONG_PARAM_NAME));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,6 @@
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLEventWriter;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
@@ -58,10 +57,9 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
-import jaxp.library.JAXPFileBaseTest;
-
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.Attributes;
@@ -71,10 +69,15 @@
 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)
  */
 @Test(singleThreaded = true)
-public class TransformTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class TransformTest {
 
     /*
      * Initialize the share objects.
@@ -381,3 +384,5 @@
     private Document xmlDoc;
 
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,32 +22,40 @@
  */
 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 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.assertNotNull;
 import static org.testng.Assert.assertNull;
 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;
 
 /**
  *  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.
      */
     @Test
     public void tfexception() {
         try {
-            setPermissions(new FilePermission(XML_DIR  + "-", "read"));
             // invalid.xsl has well-formedness error. Therefore transform throws
             // TransformerException
             StreamSource streamSource
@@ -63,8 +71,6 @@
             assertNotNull(e.getException());
             assertNull(e.getLocationAsString());
             assertEquals(e.getMessageAndLocation(),e.getMessage());
-        } finally {
-            setPermissions();
         }
     }
 
@@ -99,3 +105,5 @@
         assertNotNull(te.initCause(null));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,33 +22,45 @@
  */
 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.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.compareWithGold;
 import static org.testng.Assert.assertNotNull;
 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.Listeners;
 import org.testng.annotations.Test;
-import org.w3c.dom.*;
+import org.w3c.dom.Document;
 
 /**
  * Class containing the test cases for TransformerFactory API's
  * 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.
      */
@@ -129,3 +141,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,9 +22,15 @@
  */
 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.FileInputStream;
 import java.util.Properties;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.ErrorListener;
@@ -33,13 +39,10 @@
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 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.stream.StreamSource;
-import jaxp.library.JAXPFileReadOnlyBaseTest;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -47,7 +50,14 @@
 /**
  * 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.
      */
@@ -58,7 +68,7 @@
      * @throws TransformerConfigurationException If for some reason the
      *         TransformerHandler can not be created.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void transformer01() throws TransformerConfigurationException {
         TransformerFactory tfactory = TransformerFactory.newInstance();
         StreamSource streamSource = new StreamSource(
@@ -71,7 +81,7 @@
      * This tests if newTransformer(SAXSource) method returns Transformer.
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void transformer02() throws Exception {
         try (FileInputStream fis = new FileInputStream(TEST_XSL)) {
             TransformerFactory tfactory = TransformerFactory.newInstance();
@@ -86,7 +96,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void transformer03() throws Exception {
         TransformerFactory tfactory = TransformerFactory.newInstance();
 
@@ -105,7 +115,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void transformer04() throws Exception {
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
@@ -125,7 +135,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void transformer05() throws Exception {
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
@@ -150,7 +160,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void transformer06() throws Exception {
         TransformerFactory tfactory = TransformerFactory.newInstance();
 
@@ -197,3 +207,5 @@
         System.out.println(" In fatal");
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,21 +22,24 @@
  */
 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.FileInputStream;
 import java.io.FileOutputStream;
+
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 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.StreamSource;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 
@@ -44,7 +47,14 @@
  * Here a transformer is created using DOMSource. Some specific output property
  * 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).
      *
@@ -75,3 +85,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,22 +22,25 @@
  */
 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.FileInputStream;
 import java.io.FileOutputStream;
 import java.util.Properties;
+
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 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.StreamSource;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /**
@@ -46,7 +49,14 @@
  * for transformer. Then transform(StreamSource, StreamResult) is used for
  * 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.
      *
@@ -84,3 +94,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,13 @@
  */
 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.FileInputStream;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.Source;
@@ -31,13 +36,11 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.URIResolver;
 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.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
-import jaxp.library.JAXPFileBaseTest;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -45,7 +48,14 @@
 /**
  * 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.
      */
@@ -115,7 +125,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public static void resolver01() throws Exception {
         try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)) {
             TransformerFactory tfactory = TransformerFactory.newInstance();
@@ -134,7 +144,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public static void resolver02() throws Exception {
         TransformerFactory tfactory = TransformerFactory.newInstance();
         URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
@@ -155,7 +165,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public static void resolver03() throws Exception {
         try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)){
             URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
@@ -174,7 +184,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public static void resolver04() throws Exception {
         try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)) {
             URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
@@ -192,7 +202,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public static void resolver05() throws Exception {
         URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
         TransformerFactory tfactory = TransformerFactory.newInstance();
@@ -211,7 +221,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public static void resolver06() throws Exception {
         try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)){
             URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
@@ -230,7 +240,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public static void docResolver01() throws Exception {
         try (FileInputStream fis = new FileInputStream(XML_DIR + "doctest.xsl")) {
             URIResolverTest resolver = new URIResolverTest("temp/colors.xml", SYSTEM_ID);
@@ -252,3 +262,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,15 +22,27 @@
  */
 package javax.xml.transform.ptests.othervm;
 
-import javax.xml.transform.*;
-import jaxp.library.JAXPBaseTest;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 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;
 
 /**
  * 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)
     public void tfce01() throws Exception {
         try{
@@ -42,3 +54,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,6 +54,7 @@
 
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.ErrorHandler;
@@ -64,10 +65,15 @@
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @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
  */
 @Test(singleThreaded = true)
+@Listeners({jaxp.library.FilePolicy.class})
 public class SchemaFactoryTest {
 
     @BeforeClass
@@ -398,3 +404,4 @@
     private Document xsdDoc2;
     private byte[] xml;
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,7 @@
 import javax.xml.validation.TypeInfoProvider;
 import javax.xml.validation.ValidatorHandler;
 
-import jaxp.library.JAXPFileBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
@@ -49,9 +48,14 @@
 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()
  */
-public class TypeInfoProviderTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class TypeInfoProviderTest {
 
     private ValidatorHandler validatorHandler;
 
@@ -91,3 +95,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.ErrorHandler;
@@ -46,8 +47,13 @@
 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
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class ValidatorHandlerTest {
     @BeforeClass
     public void setup() throws SAXException {
@@ -142,3 +148,4 @@
     private Schema schema;
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,10 +45,9 @@
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
-import jaxp.library.JAXPFileBaseTest;
-
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.ErrorHandler;
@@ -59,9 +58,14 @@
 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
  */
-public class ValidatorTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class ValidatorTest {
 
     @BeforeClass
     public void setup() throws SAXException, IOException, ParserConfigurationException {
@@ -205,3 +209,4 @@
     private Document xmlDoc;
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,26 +23,28 @@
 
 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.NODE;
 import static javax.xml.xpath.XPathConstants.NODESET;
 import static javax.xml.xpath.XPathConstants.NUMBER;
 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.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.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -52,7 +54,14 @@
 /**
  * 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.
      */
@@ -89,7 +98,6 @@
      */
     @BeforeTest
     public void setup() throws Exception {
-        setPermissions(new FilePermission(XML_PATH.toFile().toString(), "read"));
         document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(XML_PATH.toFile());
         xpath = XPathFactory.newInstance().newXPath();
     }
@@ -264,7 +272,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPathExpression15() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.compile(EXPRESSION_NAME_A).
@@ -287,7 +295,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void testCheckXPathExpression17() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.compile(null).evaluate(new InputSource(is));
@@ -300,7 +308,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class)
+    @Test(expectedExceptions = XPathExpressionException.class)
     public void testCheckXPathExpression18() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.compile("-*&").evaluate(new InputSource(is));
@@ -313,7 +321,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class)
+    @Test(expectedExceptions = XPathExpressionException.class)
     public void testCheckXPathExpression19() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.compile(" ").evaluate(new InputSource(is));
@@ -326,7 +334,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPathExpression20() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.compile(EXPRESSION_NAME_A).
@@ -351,7 +359,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void testCheckXPathExpression22() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.compile(null).evaluate(new InputSource(is), STRING);
@@ -364,7 +372,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void testCheckXPathExpression23() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.compile(EXPRESSION_NAME_A).evaluate(new InputSource(is), null);
@@ -377,7 +385,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class)
+    @Test(expectedExceptions = XPathExpressionException.class)
     public void testCheckXPathExpression24() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.compile("-*&").evaluate(new InputSource(is), STRING);
@@ -390,7 +398,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class)
+    @Test(expectedExceptions = XPathExpressionException.class)
     public void testCheckXPathExpression25() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.compile(" ").evaluate(new InputSource(is), STRING);
@@ -404,7 +412,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testCheckXPathExpression26() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.compile(EXPRESSION_NAME_A).evaluate(new InputSource(is), TEST_QNAME);
@@ -417,7 +425,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPathExpression27() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.compile(EXPRESSION_NAME_A).
@@ -431,7 +439,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPathExpression28() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.compile(EXPRESSION_NAME_B).
@@ -445,7 +453,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPathExpression29() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.compile(EXPRESSION_NAME_A).
@@ -459,7 +467,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPathExpression30() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             Attr attr = (Attr) xpath.compile(EXPRESSION_NAME_A).
@@ -474,7 +482,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPathExpression31() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             NodeList nodeList = (NodeList) xpath.compile(EXPRESSION_NAME_A).
@@ -483,3 +491,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,22 +24,29 @@
 package javax.xml.xpath.ptests;
 
 import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL;
+import static org.testng.Assert.assertNotNull;
 
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathFactory;
 import javax.xml.xpath.XPathFactoryConfigurationException;
 
 import jaxp.library.JAXPDataProvider;
-import jaxp.library.JAXPBaseTest;
-import static org.testng.Assert.assertNotNull;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /**
  * 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.
      */
@@ -211,3 +218,5 @@
         assertNotNull(XPathFactory.newInstance(DOM_OBJECT_MODEL));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,18 +23,27 @@
 
 package javax.xml.xpath.ptests;
 
+import static org.testng.Assert.assertEquals;
+
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
-import jaxp.library.JAXPBaseTest;
-import static org.testng.Assert.assertEquals;
+
 import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /**
  * 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.
      */
@@ -73,3 +82,5 @@
         assertEquals(xpath.evaluate(null, "5"), "2");
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,30 +23,32 @@
 
 package javax.xml.xpath.ptests;
 
-import java.io.FilePermission;
+import static javax.xml.xpath.XPathConstants.BOOLEAN;
+import static javax.xml.xpath.XPathConstants.NODE;
+import static javax.xml.xpath.XPathConstants.NODESET;
+import static javax.xml.xpath.XPathConstants.NUMBER;
+import static javax.xml.xpath.XPathConstants.STRING;
+import static javax.xml.xpath.ptests.XPathTestConst.XML_DIR;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+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 static javax.xml.xpath.XPathConstants.BOOLEAN;
-import static javax.xml.xpath.XPathConstants.NODE;
-import static javax.xml.xpath.XPathConstants.NODESET;
-import static javax.xml.xpath.XPathConstants.NUMBER;
-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 jaxp.library.JAXPFileReadOnlyBaseTest;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
+
 import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -56,7 +58,14 @@
 /**
  * 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.
      */
@@ -93,7 +102,6 @@
      */
     @BeforeTest
     public void setup() throws Exception {
-        setPermissions(new FilePermission(XML_DIR + "-", "read"));
         document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(XML_PATH.toFile());
         xpath = XPathFactory.newInstance().newXPath();
     }
@@ -347,7 +355,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test (groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath22() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is)), "6");
@@ -371,7 +379,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void testCheckXPath24() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.evaluate(null, new InputSource(is));
@@ -385,7 +393,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class)
+    @Test(expectedExceptions = XPathExpressionException.class)
     public void testCheckXPath25() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.evaluate("-*&", new InputSource(is));
@@ -398,7 +406,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class)
+    @Test(expectedExceptions = XPathExpressionException.class)
     public void testCheckXPath26() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.evaluate(" ", new InputSource(is));
@@ -411,7 +419,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath27() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), STRING), "6");
@@ -435,7 +443,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void testCheckXPath29() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.evaluate(null, new InputSource(is), STRING);
@@ -448,7 +456,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void testCheckXPath30() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), null);
@@ -461,7 +469,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class)
+    @Test(expectedExceptions = XPathExpressionException.class)
     public void testCheckXPath31() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.evaluate("-*&", new InputSource(is), STRING);
@@ -474,7 +482,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = XPathExpressionException.class)
+    @Test(expectedExceptions = XPathExpressionException.class)
     public void testCheckXPath32() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.evaluate(" ", new InputSource(is), STRING);
@@ -488,7 +496,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testCheckXPath33() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is), TEST_QNAME);
@@ -501,7 +509,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath34() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is),
@@ -515,7 +523,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath35() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is),
@@ -529,7 +537,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath36() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is),
@@ -543,7 +551,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath37() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A,
@@ -557,7 +565,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath38() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A,
@@ -573,7 +581,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath52() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.evaluate(EXPRESSION_NAME_B, new InputSource(is),
@@ -587,7 +595,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath53() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(xpath.evaluate(EXPRESSION_NAME_A, new InputSource(is),
@@ -601,7 +609,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath54() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             assertEquals(((Attr)xpath.evaluate(EXPRESSION_NAME_A,
@@ -615,7 +623,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckXPath55() throws Exception {
         try (InputStream is = Files.newInputStream(XML_PATH)) {
             NodeList nodeList = (NodeList)xpath.evaluate(EXPRESSION_NAME_A,
@@ -749,3 +757,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AbstractCharacterDataTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AbstractCharacterDataTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,8 +31,6 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
-import jaxp.library.JAXPFileBaseTest;
-
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 import org.w3c.dom.CharacterData;
@@ -42,7 +40,7 @@
 /*
  * @summary common test for the CharacterData Interface
  */
-public abstract class AbstractCharacterDataTest extends JAXPFileBaseTest {
+public abstract class AbstractCharacterDataTest {
     @DataProvider(name = "data-for-length")
     public Object[][] getDataForTestLength() {
         return new Object[][] {
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,8 @@
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 import static org.w3c.dom.ptests.DOMTestUtil.createDOM;
-import jaxp.library.JAXPFileBaseTest;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -38,9 +38,14 @@
 
 
 /*
+ * @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
  */
-public class AttrTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class AttrTest {
     /*
      * Verify getName method against both existing Attr and new Attr.
      */
@@ -146,3 +151,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,13 +28,19 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.testng.annotations.Listeners;
 import org.w3c.dom.CharacterData;
 import org.w3c.dom.Document;
 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)
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CommentTest extends AbstractCharacterDataTest {
     @Override
     protected CharacterData createCharacterData(String text) throws IOException, SAXException, ParserConfigurationException {
@@ -42,3 +48,4 @@
         return document.createComment(text);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,9 @@
 import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED;
 import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS;
 import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument;
-import jaxp.library.JAXPFileBaseTest;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
@@ -42,9 +42,14 @@
 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
  */
-public class DocumentTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class DocumentTest {
 
     @DataProvider(name = "invalid-nsuri")
     public Object[][] getInvalidNamespaceURI() {
@@ -170,3 +175,4 @@
         doc.createElement("!nc$%^*(!");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,22 @@
 
 import static org.testng.Assert.assertEquals;
 import static org.w3c.dom.ptests.DOMTestUtil.createDOM;
-import jaxp.library.JAXPFileBaseTest;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DocumentType;
 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
  */
-public class DocumentTypeTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class DocumentTypeTest {
 
     /*
      * Test testGetEntities method, and verify the entity items.
@@ -87,3 +92,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,18 +27,22 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
-import jaxp.library.JAXPBaseTest;
-
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 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
  */
-public class DomImplementationTest extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class DomImplementationTest {
     /*
      * Test createDocument method with a namespace uri, qualified name and null
      * for the doctype
@@ -125,3 +129,4 @@
         assertEquals(documentType.getName(), name);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,9 +37,8 @@
 
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import jaxp.library.JAXPFileBaseTest;
-
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
@@ -50,9 +49,14 @@
 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
  */
-public class ElementTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class ElementTest {
     @Test
     public void testGetAttributeNS() throws Exception {
         Document document = createDOMWithNS("ElementSample01.xml");
@@ -251,3 +255,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,17 +30,21 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import jaxp.library.JAXPFileBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 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.
  */
-public class EntityChildTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class EntityChildTest {
 
     @Test
     public void test() throws Exception {
@@ -57,3 +61,4 @@
         assertEquals(nl.getLength(), 3);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,8 @@
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
 import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS;
-import jaxp.library.JAXPFileBaseTest;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -35,9 +35,14 @@
 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
  */
-public class NamedNodeMapTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class NamedNodeMapTest {
     /*
      * 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.
@@ -116,3 +121,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,20 +24,25 @@
 
 import static org.testng.Assert.assertEquals;
 import static org.w3c.dom.ptests.DOMTestUtil.createDOM;
-import jaxp.library.JAXPFileBaseTest;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 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
  * bound, the last element of a NodeList returns null. The bug has been fixed
  * in jaxp 1.1.1 build.
  */
-public class NodeListTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class NodeListTest {
 
     @DataProvider(name = "xml")
     public Object[][] getTestData() {
@@ -59,3 +64,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 package org.w3c.dom.ptests;
 
 import static jaxp.library.JAXPTestUtilities.compareWithGold;
+import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotEquals;
@@ -33,6 +34,7 @@
 import static org.w3c.dom.ptests.DOMTestUtil.createNewDocument;
 
 import java.io.File;
+import java.util.PropertyPermission;
 
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
@@ -41,9 +43,8 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
-import jaxp.library.JAXPFileBaseTest;
-
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -53,9 +54,14 @@
 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
  */
-public class NodeTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class NodeTest {
     @DataProvider(name = "feature-supported")
     public Object[][] getFeatureSupportedList() throws Exception {
         Document document = createDOMWithNS("Node01.xml");
@@ -153,7 +159,7 @@
 
         String outputfile = "InsertBefore.out";
         String goldfile = GOLDEN_DIR + "InsertBeforeGF.out";
-        outputXml(document, outputfile);
+        tryRunWithTmpPermission(() -> outputXml(document, outputfile), new PropertyPermission("user.dir", "read"));
         assertTrue(compareWithGold(goldfile, outputfile));
     }
 
@@ -171,7 +177,7 @@
 
         String outputfile = "ReplaceChild3.out";
         String goldfile = GOLDEN_DIR + "ReplaceChild3GF.out";
-        outputXml(document, outputfile);
+        tryRunWithTmpPermission(() -> outputXml(document, outputfile), new PropertyPermission("user.dir", "read"));
         assertTrue(compareWithGold(goldfile, outputfile));
     }
 
@@ -205,3 +211,4 @@
         transformer.transform(domSource, streamResult);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,8 +29,7 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
-import jaxp.library.JAXPFileBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
@@ -38,9 +37,14 @@
 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
  */
-public class NotationTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class NotationTest {
     /*
      * Test getSystemId method.
      */
@@ -70,3 +74,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,16 +24,21 @@
 
 import static org.testng.Assert.assertEquals;
 import static org.w3c.dom.ptests.DOMTestUtil.createDOMWithNS;
-import jaxp.library.JAXPFileBaseTest;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 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
  */
-public class PITest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class PITest {
     /*
      * Test getData, setData and getTarget methods
      */
@@ -49,3 +54,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.CharacterData;
 import org.w3c.dom.Document;
@@ -39,8 +40,13 @@
 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)
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class TextTest extends AbstractCharacterDataTest {
     /*
      * Verify splitText method works as the spec.
@@ -68,3 +74,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,8 +30,7 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import jaxp.library.JAXPBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -39,9 +38,14 @@
 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
  */
-public class TypeInfoTest extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class TypeInfoTest {
     /*
      * Get the TypeInfo of the root element, and verify it.
      */
@@ -136,3 +140,4 @@
 
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,16 +22,24 @@
  */
 package org.xml.sax.ptests;
 
-import jaxp.library.JAXPBaseTest;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.helpers.AttributesImpl;
 
 /**
  * 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_LOCALNAME = "part";
@@ -194,3 +202,5 @@
         attr.removeAttribute(1);
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,17 +22,20 @@
  */
 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.compareWithGold;
 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.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
  * ContentHandler has Attributes as one of its arguments. Attributes
@@ -40,7 +43,14 @@
  * of Attributes interfaces are tested. This program uses Namespace processing
  * 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.
      *
@@ -64,3 +74,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,17 +22,20 @@
  */
 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.compareWithGold;
 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.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
  * ContentHandler has Attributes as one of its arguments. Attributes
@@ -41,7 +44,14 @@
  * This program uses Namespace processing without any namepsaces in xml file.
  * 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
      * file. Check it with golden file.
@@ -66,3 +76,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,15 +22,20 @@
  */
 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.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
+
 import javax.xml.parsers.SAXParserFactory;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
@@ -38,15 +43,20 @@
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 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
  * transverses XML and print all visited node  when XMLreader parses XML. Test
  * 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.
      *
@@ -254,3 +264,5 @@
             bWriter.close();
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,30 +22,40 @@
  */
 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.File;
 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.compareWithGold;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 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
  * 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.
      *
@@ -262,3 +272,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,31 +22,41 @@
  */
 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.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 jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.XMLReader;
 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
  * 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
      * output file is same as golden file.
@@ -125,3 +135,5 @@
         bWriter.close();
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,17 +22,26 @@
  */
 package org.xml.sax.ptests;
 
-import java.util.Enumeration;
-import jaxp.library.JAXPBaseTest;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
+
+import java.util.Enumeration;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.helpers.NamespaceSupport;
 
 /**
  * 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.
      */
@@ -122,3 +131,5 @@
         assertNull(support.getURI(DC_PREFIX));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,11 +22,13 @@
  */
 package org.xml.sax.ptests;
 
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
 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.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.XMLReader;
 
@@ -34,7 +36,14 @@
  * Class containing the test cases for Namespace Table defined at
  * 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 =
                         "http://xml.org/sax/features/namespaces";
     private static final String NAMESPACE_PREFIXES =
@@ -159,3 +168,5 @@
         assertFalse(spf.getFeature(NAMESPACE_PREFIXES));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,12 +22,16 @@
  */
 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.assertNotNull;
 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.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
@@ -37,14 +41,20 @@
 import org.xml.sax.helpers.ParserAdapter;
 import org.xml.sax.helpers.XMLFilterImpl;
 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
  * 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.
      */
@@ -234,7 +244,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class)
+    @Test(expectedExceptions = SAXException.class)
     public void parse02() throws Exception {
         try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) {
             InputSource is = new InputSource(fis);
@@ -247,7 +257,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void parse03() throws Exception {
         try(FileInputStream fis = new FileInputStream(XML_DIR + "correct.xml")) {
             InputSource is = new InputSource(fis);
@@ -255,3 +265,5 @@
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,28 +22,45 @@
  */
 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.FileInputStream;
 import java.io.FileWriter;
 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.SAXParserFactory;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 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
  * 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.
      *
@@ -54,6 +71,11 @@
         String goldFile = GOLDEN_DIR + "EntityResolverGF.out";
         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);
                 MyEntityResolver eResolver = new MyEntityResolver(outputFile)) {
             SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
@@ -97,7 +119,7 @@
     @Override
     public InputSource resolveEntity(String publicid, String systemid)
             throws SAXException, IOException {
-        String str = "In resolveEntity.." + " " + publicid + " " + systemid;
+        String str = "In resolveEntity.." + " " + publicid + " " + getFileName(systemid);
         bWriter.write( str, 0,str.length());
         bWriter.newLine();
         return super.resolveEntity(publicid, systemid);
@@ -112,4 +134,14 @@
         bWriter.flush();
         bWriter.close();
     }
+
+    private String getFileName(String systemid) {
+        try {
+            return Paths.get(new URI(systemid)).getFileName().toString();
+        } catch (URISyntaxException e) {
+            throw new RuntimeException(e);
+        }
+    }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/SAXParserNSTableTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/SAXParserNSTableTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,21 +22,31 @@
  */
 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.compareWithGold;
 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.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
  * 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.
      * So it is a True-True combination.
@@ -97,3 +107,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,15 +22,21 @@
  */
 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.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
+
 import javax.xml.parsers.SAXParserFactory;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.Locator;
@@ -38,14 +44,20 @@
 import org.xml.sax.SAXParseException;
 import org.xml.sax.XMLReader;
 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
  * 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.
      *
@@ -273,3 +285,5 @@
             bWriter.close();
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,23 +22,33 @@
  */
 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.assertNotNull;
 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.xml.sax.InputSource;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLFilterImpl;
-import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
 
 /**
  * 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.
      */
@@ -217,7 +227,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void parse02() throws Exception {
         try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) {
             new XMLFilterImpl().parse(new InputSource(fis));
@@ -229,10 +239,12 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void parse03() throws Exception {
         try(FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) {
             new XMLFilterImpl().parse(new InputSource(fis));
         }
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,24 +22,33 @@
  */
 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.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.xml.sax.HandlerBase;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLReaderAdapter;
-import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
 
 /**
  * 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.
      */
@@ -92,7 +101,6 @@
      */
     @Test
     public void parse01() throws Exception {
-        setPermissions(new FilePermission(XML_DIR + "/-", "read"));
         try (FileInputStream fis = new FileInputStream(XML_DIR + "namespace1.xml")) {
             XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
             if (!xmlReader.getFeature(NM_PREFIXES_PROPERTY)) {
@@ -102,6 +110,7 @@
             xmlRA.setDocumentHandler(new HandlerBase());
             xmlRA.parse(new InputSource(fis));
         }
-        setPermissions();
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,11 @@
  */
 package org.xml.sax.ptests;
 
-import jaxp.library.JAXPBaseTest;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import static org.testng.Assert.assertNotNull;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.XMLReaderFactory;
@@ -31,7 +34,14 @@
 /**
  * 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.
      * @throws org.xml.sax.SAXException when xml reader creation failed.
@@ -66,3 +76,5 @@
         XMLReaderFactory.createXMLReader("org.apache.crimson.parser.ABCD");
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,23 +22,35 @@
  */
 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.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.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;
-import static org.xml.sax.ptests.SAXTestConst.GOLDEN_DIR;
-import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
 
 /** This class contains the testcases to test XMLReader with regard to
   * Namespace Table defined at
   * 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.
      */
@@ -109,7 +121,7 @@
         String goldFile = GOLDEN_DIR + "NSTableFTGF.out";
 
         SAXParserFactory spf = SAXParserFactory.newInstance();
-        spf.setNamespaceAware(true);
+        //NamespaceAware is false by default, so don't need to set here
         XMLReader xmlReader = spf.newSAXParser().getXMLReader();
         try (FileInputStream fis = new FileInputStream(xmlFile);
             MyNSContentHandler handler = new MyNSContentHandler(outputFile)) {
@@ -119,3 +131,5 @@
         assertTrue(compareWithGold(goldFile, outputFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,14 +22,18 @@
  */
 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.assertFalse;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
 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.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -39,12 +43,18 @@
 import org.xml.sax.ext.DeclHandler;
 import org.xml.sax.ext.LexicalHandler;
 import org.xml.sax.helpers.XMLFilterImpl;
-import static org.xml.sax.ptests.SAXTestConst.XML_DIR;
 
 /**
  * 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.
@@ -434,7 +444,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"}, expectedExceptions = SAXException.class)
+    @Test(expectedExceptions = SAXException.class)
     public void parse02() throws Exception {
         try (FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) {
             SAXParserFactory spf = SAXParserFactory.newInstance();
@@ -448,7 +458,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void parse03() throws Exception {
         try (FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) {
             SAXParserFactory spf = SAXParserFactory.newInstance();
@@ -661,3 +671,5 @@
     public void internalEntityDecl(String name, String value) {
     }
 }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/familytree.dtd	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,1 @@
+<familytree>purplelustrous</familytree>
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/out/EntityResolverGF.out	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/out/EntityResolverGF.out	Mon Aug 08 12:50:00 2016 +0800
@@ -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.. null http://sc11152338.us.oracle.com:8080/xmlsqe/jaxp/web/testfiles/JAXPREP/familytree.dtd
+In resolveEntity.. -//mkrishna mohan//DTD//music pub//EN/ publishers.dtd
+In resolveEntity.. null familytree.dtd
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/out/NSTableFTGF.out	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/out/NSTableFTGF.out	Mon Aug 08 12:50:00 2016 +0800
@@ -1,109 +1,59 @@
 setDocumentLocator...
 startDocument...
-startPrefixMapping...
-prefix: <xml> uri: <http://www.w3.org/XML/1998/namespace>
-startPrefixMapping...
-prefix: <xmlns> uri: <http://www.w3.org/2000/xmlns/>
 startElement...
 namespaceURI: <> localName: <> qName: <html> Number of Attributes: <2> Line# <3>
 characters...length is:3
 <
   >
-startPrefixMapping...
-prefix: <xml> uri: <http://www.w3.org/XML/1998/namespace>
-startPrefixMapping...
-prefix: <xmlns> uri: <http://www.w3.org/2000/xmlns/>
 startElement...
 namespaceURI: <> localName: <> qName: <head> Number of Attributes: <0> Line# <4>
 characters...length is:5
 <
     >
-startPrefixMapping...
-prefix: <xml> uri: <http://www.w3.org/XML/1998/namespace>
-startPrefixMapping...
-prefix: <xmlns> uri: <http://www.w3.org/2000/xmlns/>
 startElement...
 namespaceURI: <> localName: <> qName: <title> Number of Attributes: <0> Line# <5>
 characters...length is:10
 <Typography>
 endElement...
 namespaceURI: <> localName: <> qName: <title>
-endPrefixMapping...
-prefix: <xml>
-endPrefixMapping...
-prefix: <xmlns>
 characters...length is:3
 <
   >
 endElement...
 namespaceURI: <> localName: <> qName: <head>
-endPrefixMapping...
-prefix: <xml>
-endPrefixMapping...
-prefix: <xmlns>
 characters...length is:4
 <
 
   >
-startPrefixMapping...
-prefix: <xml> uri: <http://www.w3.org/XML/1998/namespace>
-startPrefixMapping...
-prefix: <xmlns> uri: <http://www.w3.org/2000/xmlns/>
 startElement...
 namespaceURI: <> localName: <> qName: <body> Number of Attributes: <0> Line# <8>
 characters...length is:5
 <
     >
-startPrefixMapping...
-prefix: <xml> uri: <http://www.w3.org/XML/1998/namespace>
-startPrefixMapping...
-prefix: <xmlns> uri: <http://www.w3.org/2000/xmlns/>
 startElement...
 namespaceURI: <> localName: <> qName: <p> Number of Attributes: <0> Line# <9>
 characters...length is:77
 < Welcome to the world of typography! Here is a book that you may find useful.>
 endElement...
 namespaceURI: <> localName: <> qName: <p>
-endPrefixMapping...
-prefix: <xml>
-endPrefixMapping...
-prefix: <xmlns>
 characters...length is:5
 <
     >
-startPrefixMapping...
-prefix: <xml> uri: <http://www.w3.org/XML/1998/namespace>
-startPrefixMapping...
-prefix: <xmlns> uri: <http://www.w3.org/2000/xmlns/>
 startElement...
 namespaceURI: <> localName: <> qName: <b:title> Number of Attributes: <1> Line# <10>
 characters...length is:18
 <Digital Typography>
 endElement...
 namespaceURI: <> localName: <> qName: <b:title>
-endPrefixMapping...
-prefix: <xml>
-endPrefixMapping...
-prefix: <xmlns>
-characters...length is:1
-< >
 characters...length is:5
 <
     >
-startPrefixMapping...
-prefix: <xml> uri: <http://www.w3.org/XML/1998/namespace>
-startPrefixMapping...
-prefix: <xmlns> uri: <http://www.w3.org/2000/xmlns/>
 startElement...
 namespaceURI: <> localName: <> qName: <b:author> Number of Attributes: <0> Line# <11>
 characters...length is:12
 <Donald Knuth>
 endElement...
 namespaceURI: <> localName: <> qName: <b:author>
-endPrefixMapping...
-prefix: <xml>
-endPrefixMapping...
-prefix: <xmlns>
 characters...length is:5
 <
     >
@@ -113,18 +63,10 @@
   >
 endElement...
 namespaceURI: <> localName: <> qName: <body>
-endPrefixMapping...
-prefix: <xml>
-endPrefixMapping...
-prefix: <xmlns>
 characters...length is:2
 <
 
 >
 endElement...
 namespaceURI: <> localName: <> qName: <html>
-endPrefixMapping...
-prefix: <xml>
-endPrefixMapping...
-prefix: <xmlns>
 endDocument...
--- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/publish.xml	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/publish.xml	Mon Aug 08 12:50:00 2016 +0800
@@ -1,6 +1,5 @@
 <?xml version="1.0" standalone="no"?>
-<!DOCTYPE document PUBLIC "-//mkrishna mohan//DTD//music pub//EN/"
-		"http://sc11152338.us.oracle.com:8080/xmlsqe/jaxp/web/testfiles/JAXPREP/publishers.dtd">
+<!DOCTYPE document PUBLIC "-//mkrishna mohan//DTD//music pub//EN/" "publishers.dtd">
 <document>
 	Publishers of the Music of New York Women Composers
 	<title>The Publishers </title>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/xmlfiles/publishers.dtd	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,16 @@
+<!ELEMENT document ANY>
+<!ELEMENT title (#PCDATA)>
+<!ELEMENT publisher_list (publisher*)>
+<!ELEMENT publisher (name, email?, homepage?, address?, voice?, fax?, dtdname?)>
+<!ELEMENT name (#PCDATA)>
+<!ELEMENT email (#PCDATA)>
+<!ELEMENT homepage (#PCDATA)>
+<!ELEMENT address (street+, city, state, zip, country?)>
+<!ELEMENT street (#PCDATA)>
+<!ELEMENT city (#PCDATA)>
+<!ELEMENT state (#PCDATA)>
+<!ELEMENT zip (#PCDATA)>
+<!ELEMENT country (#PCDATA)>
+<!ELEMENT voice (#PCDATA)>
+<!ELEMENT fax (#PCDATA)>
+<!ENTITY  familytree SYSTEM "familytree.dtd">
--- a/jaxp/test/javax/xml/jaxp/functional/test/astro/AstroTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/AstroTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 package test.astro;
 
 import static java.lang.String.valueOf;
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
 import static org.testng.Assert.assertEquals;
 import static test.astro.AstroConstants.ASTROCAT;
 import static test.astro.AstroConstants.GOLDEN_DIR;
@@ -35,13 +36,16 @@
 
 import javax.xml.transform.sax.TransformerHandler;
 
-import jaxp.library.JAXPFileBaseTest;
-
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.astro.AstroTest
+ * @run testng/othervm test.astro.AstroTest
  * @summary run astro application, test xslt
  *
  * There are vast amounts of textual astronomical data, typically user is
@@ -66,7 +70,8 @@
  * AstroProcessor to test different JAXP classes and features.
  *
  */
-public class AstroTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class AstroTest {
     private FiltersAndGolden[] data;
 
     @BeforeClass
@@ -107,7 +112,7 @@
         for (int i = 0; i < filterCreators.length; i++)
             filters[i] = filterCreators[i].createFilter(astro);
 
-        String outputfile = Files.createTempFile(Paths.get("").toAbsolutePath(), "query" + processNum + ".out.", null).toString();
+        String outputfile = Files.createTempFile(Paths.get(USER_DIR), "query" + processNum + ".out.", null).toString();
         System.out.println("output file: " + outputfile);
         astro.process(outputfile, filters);
         assertEquals(Files.readAllLines(Paths.get(outputfile)), goldenfileContent);
@@ -140,3 +145,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,8 +40,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import jaxp.library.JAXPFileBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -52,9 +51,14 @@
 import org.w3c.dom.ls.LSSerializer;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.astro.DocumentLSTest
+ * @run testng/othervm test.astro.DocumentLSTest
  * @summary org.w3c.dom.ls tests
  */
-public class DocumentLSTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class DocumentLSTest {
     /*
      * Test creating an empty Document
      */
@@ -178,3 +182,4 @@
         return dbf.newDocumentBuilder();
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,14 +28,18 @@
 
 import javax.xml.namespace.QName;
 
-import jaxp.library.JAXPBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.astro.NamespaceContextTest
+ * @run testng/othervm test.astro.NamespaceContextTest
  * @summary javax.xml.namespace.QName tests
  */
-public class NamespaceContextTest extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class NamespaceContextTest {
     private static final String PREFIX = "astro";
     private static final String LOCAL_PART = "stardb";
     private static final String NS_URI = "http://www.astro.com";
@@ -85,3 +89,4 @@
         assertEquals(QName.valueOf(qname.toString()), qname);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/astro/SAX201Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/SAX201Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,15 +24,19 @@
 
 import javax.xml.parsers.SAXParserFactory;
 
-import jaxp.library.JAXPBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.XMLReader;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.astro.SAX201Test
+ * @run testng/othervm test.astro.SAX201Test
  * @summary verify SAX 2.0.1 allows to use null in setters
  */
-public class SAX201Test extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class SAX201Test {
     @Test
     public void test() throws Exception {
         SAXParserFactory spf = SAXParserFactory.newInstance();
@@ -44,3 +48,4 @@
         reader.setDTDHandler(null); // SAX 2.0.1 allows
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,16 +33,20 @@
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
-import jaxp.library.JAXPFileBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.astro.SchemaValidationTest
+ * @run testng/othervm test.astro.SchemaValidationTest
  * @summary test parser sets schema related properties to do validation
  */
-public class SchemaValidationTest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class SchemaValidationTest {
     /*
      * Only set the schemaLanguage, without setting schemaSource. It should
      * work.
@@ -72,3 +76,4 @@
         return spf.newSAXParser();
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/astro/XPathAPITest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/XPathAPITest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,20 +45,24 @@
 import javax.xml.xpath.XPathFactory;
 import javax.xml.xpath.XPathVariableResolver;
 
-import jaxp.library.JAXPFileBaseTest;
-
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.astro.XPathAPITest
+ * @run testng/othervm test.astro.XPathAPITest
  * @summary test XPath API
  */
 @Test(singleThreaded = true)
-public class XPathAPITest extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class XPathAPITest {
     private static final String STARDB_STAR_3_CONSTELLATION = "//astro:stardb/astro:star[3]/astro:constellation";
     private static final String STARDB_STAR = "//astro:stardb/astro:star";
     private Document doc;
@@ -167,3 +171,4 @@
         return new InputSource(filenameToURL(ASTROCAT));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,18 +22,23 @@
  */
 package test.auctionportal;
 
-import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE;
-import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE;
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+import static jaxp.library.JAXPTestUtilities.bomStream;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
+import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE;
+import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE;
+import static test.auctionportal.HiBidConstants.PORTAL_ACCOUNT_NS;
+import static test.auctionportal.HiBidConstants.XML_DIR;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.math.BigInteger;
 import java.nio.file.Paths;
 import java.util.GregorianCalendar;
-import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+
 import javax.xml.datatype.DatatypeConstants;
 import javax.xml.datatype.DatatypeFactory;
 import javax.xml.datatype.Duration;
@@ -46,8 +51,8 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
-import jaxp.library.JAXPFileReadOnlyBaseTest;
-import static jaxp.library.JAXPTestUtilities.bomStream;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMConfiguration;
@@ -58,20 +63,25 @@
 import org.w3c.dom.bootstrap.DOMImplementationRegistry;
 import org.w3c.dom.ls.DOMImplementationLS;
 import org.w3c.dom.ls.LSSerializer;
-import static test.auctionportal.HiBidConstants.PORTAL_ACCOUNT_NS;
-import static test.auctionportal.HiBidConstants.XML_DIR;
 
 /**
  * This is the user controller  class for the Auction portal HiBid.com.
  */
-public class AuctionController extends JAXPFileReadOnlyBaseTest {
+/*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.auctionportal.AuctionController
+ * @run testng/othervm test.auctionportal.AuctionController
+ */
+@Listeners({jaxp.library.FilePolicy.class})
+public class AuctionController {
     /**
      * Check for DOMErrorHandler handling DOMError. Before fix of bug 4890927
      * DOMConfiguration.setParameter("well-formed",true) throws an exception.
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCreateNewItem2Sell() throws Exception {
         String xmlFile = XML_DIR + "novelsInvalid.xml";
 
@@ -94,7 +104,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCreateNewItem2SellRetry() throws Exception  {
         String xmlFile = XML_DIR + "accountInfo.xml";
 
@@ -126,7 +136,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCreateID() throws Exception {
         String xmlFile = XML_DIR + "accountInfo.xml";
 
@@ -147,7 +157,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckingUserData() throws Exception {
         String xmlFile = XML_DIR + "accountInfo.xml";
 
@@ -184,7 +194,7 @@
      * @throws Exception If any errors occur.
      * @see <a href="content/movies.xml">movies.xml</a>
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testCheckingEncoding() throws Exception {
         // Note since movies.xml is UTF-16 encoding. We're not using stanard XML
         // file suffix.
@@ -206,7 +216,7 @@
      * @throws Exception If any errors occur.
      * @see <a href="content/userDetails.xsd">userDetails.xsd</a>
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testGetOwnerInfo() throws Exception {
         String schemaFile = XML_DIR + "userDetails.xsd";
         String xmlFile = XML_DIR + "userDetails.xml";
@@ -241,7 +251,7 @@
      * @see <a href="content/coins.xsd">coins.xsd</a>
      * @see <a href="content/coinsImportMe.xsd">coinsImportMe.xsd</a>
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testGetOwnerItemList() throws Exception {
         String xsdFile = XML_DIR + "coins.xsd";
         String xmlFile = XML_DIR + "coins.xml";
@@ -277,7 +287,7 @@
      * @see <a href="content/coinsImportMe.xsd">coinsImportMe.xsd</a>
      */
 
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testGetOwnerItemList1() throws Exception {
         String xsdFile = XML_DIR + "coins.xsd";
         String xmlFile = XML_DIR + "coins.xml";
@@ -299,7 +309,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testGetItemDuration() throws Exception {
         String xmlFile = XML_DIR + "itemsDuration.xml";
 
@@ -332,7 +342,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testGetTypeInfo() throws Exception {
         String xmlFile = XML_DIR + "accountInfo.xml";
 
@@ -356,3 +366,5 @@
         assertTrue(roletypeInfo.getTypeNamespace().equals(PORTAL_ACCOUNT_NS));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,18 +22,26 @@
  */
 package test.auctionportal;
 
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
+import static javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING;
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
+import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static test.auctionportal.HiBidConstants.GOLDEN_DIR;
+import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE;
+import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE;
 import static test.auctionportal.HiBidConstants.SP_ENTITY_EXPANSION_LIMIT;
 import static test.auctionportal.HiBidConstants.SP_MAX_OCCUR_LIMIT;
-import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE;
-import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE;
-import static org.testng.Assert.assertTrue;
+import static test.auctionportal.HiBidConstants.XML_DIR;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.io.FilePermission;
 import java.io.InputStream;
-import static javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING;
-import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.SAXParser;
@@ -41,20 +49,23 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold;
-import static org.testng.Assert.assertFalse;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXParseException;
-import static test.auctionportal.HiBidConstants.GOLDEN_DIR;
-import static test.auctionportal.HiBidConstants.XML_DIR;
 
 /**
  * This is a test class for the Auction portal HiBid.com.
  */
-public class AuctionItemRepository extends JAXPFileBaseTest {
+/*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.auctionportal.AuctionItemRepository
+ * @run testng/othervm test.auctionportal.AuctionItemRepository
+ */
+@Listeners({jaxp.library.FilePolicy.class})
+public class AuctionItemRepository {
     /**
      * XML file for parsing.
      */
@@ -84,7 +95,6 @@
         SAXParser parser = factory.newSAXParser();
 
         MyErrorHandler fatalHandler = new MyErrorHandler();
-        setPermissions(new FilePermission(ENTITY_XML, "read"));
         parser.parse(new File(ENTITY_XML), fatalHandler);
         assertFalse(fatalHandler.isAnyError());
     }
@@ -107,7 +117,6 @@
 
         SAXParser parser = factory.newSAXParser();
         MyErrorHandler fatalHandler = new MyErrorHandler();
-        setPermissions(new FilePermission(ENTITY_XML, "read"));
         parser.parse(new File(ENTITY_XML), fatalHandler);
     }
 
@@ -127,7 +136,6 @@
         setSystemProperty(SP_MAX_OCCUR_LIMIT, String.valueOf(10000));
         SAXParser parser = factory.newSAXParser();
         parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
-        setPermissions(new FilePermission(XML_DIR + "-", "read"));
         parser.setProperty(JAXP_SCHEMA_SOURCE, new File(schema_file));
         try (InputStream is = new FileInputStream(xml_file)) {
             MyErrorHandler eh = new MyErrorHandler();
@@ -150,13 +158,8 @@
         DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
         MyErrorHandler eh = new MyErrorHandler();
         dBuilder.setErrorHandler(eh);
-        try {
-            setPermissions(new FilePermission(ENTITY_XML, "read"));
-            dBuilder.parse(ENTITY_XML);
-            assertFalse(eh.isAnyError());
-        } finally {
-            setPermissions();
-        }
+        dBuilder.parse(ENTITY_XML);
+        assertFalse(eh.isAnyError());
     }
 
     /**
@@ -174,7 +177,6 @@
         DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
         MyErrorHandler eh = new MyErrorHandler();
         dBuilder.setErrorHandler(eh);
-        setPermissions(new FilePermission(ENTITY_XML, "read"));
         dBuilder.parse(ENTITY_XML);
     }
 
@@ -369,3 +371,5 @@
         assertTrue(compareDocumentWithGold(goldFile, resultFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/UserController.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/UserController.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,20 +22,26 @@
  */
 package test.auctionportal;
 
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
+import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static test.auctionportal.HiBidConstants.GOLDEN_DIR;
 import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE;
-import static org.testng.Assert.assertFalse;
+import static test.auctionportal.HiBidConstants.PORTAL_ACCOUNT_NS;
+import static test.auctionportal.HiBidConstants.XML_DIR;
+
 import java.io.FileOutputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
-import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -46,14 +52,18 @@
 import org.w3c.dom.ls.DOMImplementationLS;
 import org.w3c.dom.ls.LSParser;
 import org.w3c.dom.ls.LSSerializer;
-import static test.auctionportal.HiBidConstants.GOLDEN_DIR;
-import static test.auctionportal.HiBidConstants.PORTAL_ACCOUNT_NS;
-import static test.auctionportal.HiBidConstants.XML_DIR;
 
 /**
  * This is the user controller class for the Auction portal HiBid.com.
  */
-public class UserController extends JAXPFileBaseTest {
+/*
+ * @test
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.auctionportal.UserController
+ * @run testng/othervm test.auctionportal.UserController
+ */
+@Listeners({jaxp.library.FilePolicy.class})
+public class UserController {
     /**
      * Checking when creating an XML document using DOM Level 2 validating
      * it without having a schema source or a schema location It must throw a
@@ -150,7 +160,7 @@
      *
      * @throws Exception If any errors occur.
      */
-    @Test(groups = {"readLocalFiles"})
+    @Test
     public void testMoreUserInfo() throws Exception {
         String xmlFile = XML_DIR + "accountInfo.xml";
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@@ -294,3 +304,5 @@
         assertTrue(compareDocumentWithGold(goldFile, resultFile));
     }
 }
+
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,16 +29,19 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamSource;
 
-import jaxp.library.JAXPBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4511326
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.gaptest.Bug4511326
+ * @run testng/othervm test.gaptest.Bug4511326
  * @summary In forwards-compatible mode the attribute isn't ignored
  */
-
-public class Bug4511326 extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class Bug4511326 {
 
     private static final String XSL = "<xsl:stylesheet version='2.0' "
                                + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>"
@@ -61,3 +64,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,15 +34,19 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamSource;
 
-import jaxp.library.JAXPBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4512806
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.gaptest.Bug4512806
+ * @run testng/othervm test.gaptest.Bug4512806
  * @summary test transformer.setOutputProperties(null)
  */
-public class Bug4512806 extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class Bug4512806 {
 
     @Test
     public void testProperty() throws TransformerConfigurationException {
@@ -86,3 +90,4 @@
 
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,16 +31,19 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
-import jaxp.library.JAXPBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4515047
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.gaptest.Bug4515047
+ * @run testng/othervm test.gaptest.Bug4515047
  * @summary test transform an empty dom source
  */
-
-public class Bug4515047 extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class Bug4515047 {
 
     @Test
     public void testCreateTxDoc() throws TransformerException, ParserConfigurationException {
@@ -59,3 +62,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,9 @@
 
 package test.gaptest;
 
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+
 import static org.testng.Assert.assertTrue;
 
 import java.io.IOException;
@@ -39,21 +42,25 @@
 import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.stream.StreamResult;
 
-import jaxp.library.JAXPBaseTest;
-
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.XMLFilterImpl;
 
 /*
+ * @test
  * @bug 4515660
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.gaptest.Bug4515660
+ * @run testng/othervm test.gaptest.Bug4515660
  * @summary verify property org.xml.sax.driver is used by SAXTransformerFactory
  */
 @Test(singleThreaded = true)
-public class Bug4515660 extends JAXPBaseTest {
+@Listeners({jaxp.library.BasePolicy.class})
+public class Bug4515660 {
 
     @BeforeClass
     public void setSaxDrier() {
@@ -62,7 +69,7 @@
 
     @AfterClass
     public void clearSaxDrier() {
-        setSystemProperty("org.xml.sax.driver", null);
+        clearSystemProperty("org.xml.sax.driver");
     }
 
     @Test
@@ -121,3 +128,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,24 +42,28 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
-import jaxp.library.JAXPFileBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 4693341
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.gaptest.Bug4693341
+ * @run testng/othervm test.gaptest.Bug4693341
  * @summary test transforming to stream with external dtd
  */
 
-public class Bug4693341 extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class Bug4693341 {
 
     @Test
     public void test() throws TransformerException, ParserConfigurationException, SAXException, IOException {
 
         Transformer transformer = TransformerFactory.newInstance().newTransformer();
 
-        String out = USER_DIR + File.separator + "Bug4693341.out";
+        String out = USER_DIR + "Bug4693341.out";
         StreamResult result = new StreamResult(new File(out));
 
         String in = XML_DIR + "Bug4693341.xml";
@@ -69,7 +73,7 @@
         System.out.println(source.getSystemId());
 
         Files.copy(Paths.get(XML_DIR + "Bug4693341.dtd"),
-                Paths.get(USER_DIR + File.separator + "Bug4693341.dtd"), REPLACE_EXISTING);
+                Paths.get(USER_DIR + "Bug4693341.dtd"), REPLACE_EXISTING);
 
         transformer.transform(source, result);
 
@@ -77,3 +81,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,8 +32,7 @@
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
-import jaxp.library.JAXPFileBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.InputSource;
@@ -42,11 +41,15 @@
 import org.xml.sax.XMLReader;
 
 /*
+ * @test
  * @bug 4848653
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.gaptest.Bug4848653
+ * @run testng/othervm test.gaptest.Bug4848653
  * @summary Verify JAXP schemaLanguage property is ignored if setValidating(false)
  */
-
-public class Bug4848653 extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class Bug4848653 {
 
     @Test
     public void test() throws IOException, SAXException, ParserConfigurationException {
@@ -78,3 +81,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,19 +37,22 @@
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.stream.StreamSource;
 
-import jaxp.library.JAXPFileBaseTest;
-
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 /*
+ * @test
  * @bug 4858685 4894410
+ * @library /javax/xml/jaxp/libs
+ * @run testng/othervm -DrunSecMngr=true test.gaptest.Bug4858685
+ * @run testng/othervm test.gaptest.Bug4858685
  * @summary test transforming text node
  */
-
-public class Bug4858685 extends JAXPFileBaseTest {
+@Listeners({jaxp.library.FilePolicy.class})
+public class Bug4858685 {
     @Test
     public void test() throws TransformerException, IOException {
         String uri = XML_DIR + "certificate.xml";
@@ -244,3 +247,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/internaltest/TEST.properties	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-# jaxp test uses TestNG
-TestNG.dirs = javax/xml/common/bug6979306 javax/xml/parsers/bug8003147 javax/xml/transform/bug6551616 javax/xml/transform/cli
-
--- a/jaxp/test/javax/xml/jaxp/internaltest/javax/xml/parsers/bug8003147/Bug8003147Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @modules java.xml/com.sun.org.apache.bcel.internal.classfile
- *          java.xml/com.sun.org.apache.bcel.internal.generic
- * @bug 8003147
- * @summary Test port fix for BCEL bug 39695.
- */
-
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.sun.org.apache.bcel.internal.classfile.ClassParser;
-import com.sun.org.apache.bcel.internal.classfile.ConstantClass;
-import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
-import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
-import com.sun.org.apache.bcel.internal.classfile.JavaClass;
-import com.sun.org.apache.bcel.internal.classfile.Method;
-import com.sun.org.apache.bcel.internal.generic.ClassGen;
-import com.sun.org.apache.bcel.internal.generic.MethodGen;
-
-public class Bug8003147Test {
-
-    @Test
-    public void test() throws Exception {
-        String classfile = getClass().getResource("Bug8003147Test.class").getPath();
-        JavaClass jc = new ClassParser(classfile).parse();
-        // rename class
-        ConstantPool cp = jc.getConstantPool();
-        int cpIndex = ((ConstantClass) cp.getConstant(jc.getClassNameIndex())).getNameIndex();
-        cp.setConstant(cpIndex, new ConstantUtf8("Bug8003147TestPrime"));
-        ClassGen gen = new ClassGen(jc);
-        Method[] methods = jc.getMethods();
-        int index;
-        for (index = 0; index < methods.length; index++) {
-            if (methods[index].getName().equals("doSomething")) {
-                break;
-            }
-        }
-        Method m = methods[index];
-        MethodGen mg = new MethodGen(m, gen.getClassName(), gen.getConstantPool());
-        gen.replaceMethod(m, mg.getMethod());
-        String path = classfile.replace("Bug8003147Test", "Bug8003147TestPrime");
-        gen.getJavaClass().dump(new FileOutputStream(path));
-
-        try {
-            Class.forName("Bug8003147TestPrime");
-        } catch (ClassFormatError cfe) {
-            cfe.printStackTrace();
-            Assert.fail("modified version of class does not pass verification");
-        }
-    }
-
-    public void doSomething(double d, ArrayList<Integer> list) {
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/bug6551616/Bug6551616.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @modules java.xml/com.sun.org.apache.xalan.internal.xsltc.trax
- * @bug 6551616
- * @summary Test SAX2StAXEventWriter.
- */
-
-import java.io.InputStream;
-import java.io.StringBufferInputStream;
-
-import javax.xml.stream.XMLEventWriter;
-import javax.xml.stream.XMLOutputFactory;
-
-import org.testng.annotations.Test;
-
-import com.sun.org.apache.xalan.internal.xsltc.trax.SAX2StAXEventWriter;
-
-public class Bug6551616 {
-    String _cache = "";
-
-
-    @Test
-    public void test() throws Exception {
-        final String XML = "" + "<?xml version='1.0'?>" + "<doc xmlns:foo='http://example.com/foo/' xml:lang='us-en'><p>Test</p></doc>";
-
-        javax.xml.parsers.SAXParserFactory saxFactory = javax.xml.parsers.SAXParserFactory.newInstance();
-
-        javax.xml.parsers.SAXParser parser = saxFactory.newSAXParser();
-
-        XMLOutputFactory outFactory = XMLOutputFactory.newInstance();
-        XMLEventWriter writer = outFactory.createXMLEventWriter(System.out);
-
-        SAX2StAXEventWriter handler = new SAX2StAXEventWriter(writer);
-
-        InputStream is = new StringBufferInputStream(XML);
-
-        parser.parse(is, handler);
-
-        // if it doesn't blow up, it succeeded.
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/cli/CLITest.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @modules java.xml/com.sun.org.apache.xml.internal.utils
- * @summary Test internal transform CLI.
- */
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class CLITest {
-
-    @Test
-    public void testCLI() {
-        try {
-            String[] args = new String[] { "-XSLTC", "-XSL", getClass().getResource("tigertest.xsl").toString(), "-IN",
-                    getClass().getResource("tigertest-in.xml").toString(), };
-            ProcessXSLT.main(args);
-        } catch (Exception e) {
-            Assert.fail(e.getMessage());
-        }
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/cli/ProcessXSLT.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,913 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: Process.java,v 1.2.4.2 2005/09/15 18:21:57 jeffsuttor Exp $
- */
-
-// This file is a copied and modified version of
-// com/sun/org/apache/xalan/internal/xslt/Process.java
-// which has been modified to only use public exported APIs.
-// The only adherence is with
-// com.sun.org.apache.xml.internal.utils.DefaultErrorHandler
-// which we try to instantiate using reflection, as that class
-// can do a better job at reporting error location.
-// We however don't have a hard dependency on it. We will use
-// our own ErrorHandler if the default one is not accessible.
-//
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.util.Properties;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.SourceLocator;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-/**
- * The main() method handles the Xalan command-line interface.
- */
-public class ProcessXSLT
-{
-
-    /**
-     * Prints argument options.
-     *
-     */
-    protected static void printArgOptions() {
-        System.out.println("xslproc options: ");
-        System.out.println("\n\t\t\t" + "-Common Options-" + "\n");
-        System.out.println("   [-XSLTC (use XSLTC for transformation)]");  //"    [-XSLTC (use XSLTC for transformation)]
-        System.out.println("   [-IN inputXMLURL]");  //"    [-IN inputXMLURL]");
-        System.out.println("   [-XSL XSLTransformationURL]");  //"   [-XSL XSLTransformationURL]");
-        System.out.println("   [-OUT outputFileName]");  //"   [-OUT outputFileName]");
-
-        System.out.println("   [-E (Do not expand entity refs)]");  //"   [-V (Version info)]");
-
-        System.out.println("   [-EDUMP {optional filename} (Do stackdump on error.)]");  //"   [-EDUMP {optional filename} (Do stackdump on error.)]");
-        System.out.println("   [-XML (Use XML formatter and add XML header.)]");  //"   [-XML (Use XML formatter and add XML header.)]");
-        System.out.println("   [-TEXT (Use simple Text formatter.)]");  //"   [-TEXT (Use simple Text formatter.)]");
-        System.out.println("   [-HTML (Use HTML formatter.)]");  //"   [-HTML (Use HTML formatter.)]");
-        System.out.println( "   [-PARAM name expression (Set a stylesheet parameter)]");  //"   [-PARAM name expression (Set a stylesheet parameter)]");
-
-        System.out.println("   [-MEDIA mediaType (use media attribute to find stylesheet associated with a document.)]");
-        System.out.println("   [-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform.)] ");
-        System.out.println("   [-DIAG (Print overall milliseconds transform took.)]");
-        System.out.println("   [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]");  //"   [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]");
-        System.out.println("   [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]");  //"   [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]");
-        waitForReturnKey();
-        System.out.println("   [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]");  //"   [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]");
-        System.out.println("   [-SECURE (set the secure processing feature to true.)]"); //"   [-SECURE (set the secure processing feature to true)]");
-
-
-        System.out.println("\n\t\t\t"+  "-Options for XSLTC-" + "\n");
-        System.out.println("   [-XO [transletName] (assign the name to the generated translet)]");
-        waitForReturnKey();
-        System.out.println("   [-XD destinationDirectory (specify a destination directory for translet)]");
-        System.out.println("   [-XJ jarfile (packages translet classes into a jar file of name <jarfile>)]");
-        System.out.println("   [-XP package (specifies a package name prefix for all generated translet classes)]");
-        System.out.println("   [-XN (enables template inlining)]");
-        System.out.println("   [-XX (turns on additional debugging message output)]");
-        System.out.println("   [-XT (use translet to transform if possible)]");
-    }
-
-  /**
-   * Command line interface to transform an XML document according to
-   * the instructions found in an XSL stylesheet.
-   * <p>The Process class provides basic functionality for
-   * performing transformations from the command line.  To see a
-   * list of arguments supported, call with zero arguments.</p>
-   * <p>To set stylesheet parameters from the command line, use
-   * <code>-PARAM name expression</code>. If you want to set the
-   * parameter to a string value, simply pass the string value
-   * as-is, and it will be interpreted as a string.  (Note: if
-   * the value has spaces in it, you may need to quote it depending
-   * on your shell environment).</p>
-   *
-   * @param argv Input parameters from command line
-   */
-    public static void main(String argv[]) {
-
-        // Runtime.getRuntime().traceMethodCalls(false); // turns Java tracing off
-        boolean doStackDumpOnError = false;
-        boolean doDiag = false;
-        boolean setQuietMode = false;
-        String msg = null;
-        boolean isSecureProcessing = false;
-
-        // Runtime.getRuntime().traceMethodCalls(false);
-        // Runtime.getRuntime().traceInstructions(false);
-        /**
-         * The default diagnostic writer...
-         */
-        java.io.PrintWriter diagnosticsWriter = new PrintWriter(System.err, true);
-        java.io.PrintWriter dumpWriter = diagnosticsWriter;
-        String flavor = "s2s";
-
-        if (argv.length < 1) {
-            printArgOptions();
-        } else {
-             // J2SE does not support Xalan interpretive
-            // false -> true
-            boolean useXSLTC = true;
-            for (int i = 0; i < argv.length; i++) {
-                if ("-XSLTC".equalsIgnoreCase(argv[i])) {
-                    useXSLTC = true;
-                }
-            }
-
-            TransformerFactory tfactory;
-            if (useXSLTC) {
-                String key = "javax.xml.transform.TransformerFactory";
-                String value = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
-                Properties props = System.getProperties();
-                props.put(key, value);
-                System.setProperties(props);
-            }
-
-            try {
-                tfactory = TransformerFactory.newInstance();
-                tfactory.setErrorListener(createDefaultErrorListener());
-            } catch (TransformerFactoryConfigurationError pfe) {
-                pfe.printStackTrace(dumpWriter);
-                //      "XSL Process was not successful.");
-                msg = "XSL Process was not successful.";
-                diagnosticsWriter.println(msg);
-
-                tfactory = null;  // shut up compiler
-
-                doExit(msg);
-            }
-
-            boolean formatOutput = false;
-            boolean useSourceLocation = false;
-            String inFileName = null;
-            String outFileName = null;
-            String dumpFileName = null;
-            String xslFileName = null;
-            String treedumpFileName = null;
-            String outputType = null;
-            String media = null;
-            List<String> params = new ArrayList<>();
-            boolean quietConflictWarnings = false;
-            URIResolver uriResolver = null;
-            EntityResolver entityResolver = null;
-            ContentHandler contentHandler = null;
-            int recursionLimit = -1;
-
-            for (int i = 0; i < argv.length; i++) {
-                if ("-XSLTC".equalsIgnoreCase(argv[i])) {
-                    // The -XSLTC option has been processed.
-                } // J2SE does not support Xalan interpretive
-                else if ("-INDENT".equalsIgnoreCase(argv[i])) {
-                    int indentAmount;
-
-                    if (((i + 1) < argv.length) && (argv[i + 1].charAt(0) != '-')) {
-                        indentAmount = Integer.parseInt(argv[++i]);
-                    } else {
-                        indentAmount = 0;
-                    }
-
-                } else if ("-IN".equalsIgnoreCase(argv[i])) {
-                    if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                        inFileName = argv[++i];
-                    } else {
-                        System.err.println("Missing argument for -IN");
-                    }
-                } else if ("-MEDIA".equalsIgnoreCase(argv[i])) {
-                    if (i + 1 < argv.length) {
-                        media = argv[++i];
-                    } else {
-                        System.err.println("Missing argument for -MEDIA");  //"Missing argument for);
-                    }
-                } else if ("-OUT".equalsIgnoreCase(argv[i])) {
-                    if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                        outFileName = argv[++i];
-                    } else {
-                        System.err.println("Missing argument for -OUT");  //"Missing argument for);
-                    }
-                } else if ("-XSL".equalsIgnoreCase(argv[i])) {
-                    if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                        xslFileName = argv[++i];
-                    } else {
-                        System.err.println("Missing argument for -XSL");  //"Missing argument for);
-                    }
-                } else if ("-FLAVOR".equalsIgnoreCase(argv[i])) {
-                    if (i + 1 < argv.length) {
-                        flavor = argv[++i];
-                    } else {
-                        System.err.println("Missing argument for -FLAVOR");  //"Missing argument for);
-                    }
-                } else if ("-PARAM".equalsIgnoreCase(argv[i])) {
-                    if (i + 2 < argv.length) {
-                        String name = argv[++i];
-
-                        params.add(name);
-
-                        String expression = argv[++i];
-
-                        params.add(expression);
-                    } else {
-                        System.err.println("Missing argument for -PARAM");  //"Missing argument for);
-                    }
-                } else if ("-E".equalsIgnoreCase(argv[i])) {
-
-                } else if ("-V".equalsIgnoreCase(argv[i])) {
-                    diagnosticsWriter.println(">>>>>>> Java Version "
-                            + System.getProperty("java.version") + ", "
-                            + /* xmlProcessorLiaison.getParserDescription()+ */ "<<<<<<<");
-                } // J2SE does not support Xalan interpretive
-                /*
-                 else if ("-QC".equalsIgnoreCase(argv[i]))
-                 {
-                 if (!useXSLTC)
-                 quietConflictWarnings = true;
-                 else
-                 printInvalidXSLTCOption("-QC");
-                 }
-                 */ else if ("-Q".equalsIgnoreCase(argv[i])) {
-                    setQuietMode = true;
-                } else if ("-DIAG".equalsIgnoreCase(argv[i])) {
-                    doDiag = true;
-                } else if ("-XML".equalsIgnoreCase(argv[i])) {
-                    outputType = "xml";
-                } else if ("-TEXT".equalsIgnoreCase(argv[i])) {
-                    outputType = "text";
-                } else if ("-HTML".equalsIgnoreCase(argv[i])) {
-                    outputType = "html";
-                } else if ("-EDUMP".equalsIgnoreCase(argv[i])) {
-                    doStackDumpOnError = true;
-
-                    if (((i + 1) < argv.length) && (argv[i + 1].charAt(0) != '-')) {
-                        dumpFileName = argv[++i];
-                    }
-                } else if ("-URIRESOLVER".equalsIgnoreCase(argv[i])) {
-                    if (i + 1 < argv.length) {
-                        try {
-                            Class<?> uriResolverClass = Class.forName(argv[++i]);
-                            Constructor<?> ctor = uriResolverClass.getConstructor();
-                            ctor.setAccessible(true);
-                            uriResolver = (URIResolver) ctor.newInstance();
-
-                            tfactory.setURIResolver(uriResolver);
-                        } catch (Throwable cnfe) {
-                            msg = "Class not found for option -URIResolver";
-                            System.err.println(msg);
-                            doExit(msg);
-                        }
-                    } else {
-                        msg = "Missing argument for -URIResolver";
-                        System.err.println(msg);  //"Missing argument for);
-                        doExit(msg);
-                    }
-                } else if ("-ENTITYRESOLVER".equalsIgnoreCase(argv[i])) {
-                    if (i + 1 < argv.length) {
-                        try {
-                            Class<?> entityResolverClass = Class.forName(argv[++i]);
-                            Constructor<?> ctor = entityResolverClass.getConstructor();
-                            ctor.setAccessible(true);
-                            entityResolver = (EntityResolver) ctor.newInstance();
-                        } catch (Throwable cnfe) {
-                            msg = "Class not found for option -EntityResolver";
-                            System.err.println(msg);
-                            doExit(msg);
-                        }
-                    } else {
-                        //            "Missing argument for);
-                        msg = "Missing argument for -EntityResolver";
-                        System.err.println(msg);
-                        doExit(msg);
-                    }
-                } else if ("-CONTENTHANDLER".equalsIgnoreCase(argv[i])) {
-                    if (i + 1 < argv.length) {
-                        try {
-                            Class<?> contentHandlerClass = Class.forName(argv[++i]);
-                            Constructor<?> ctor = contentHandlerClass.getConstructor();
-                            ctor.setAccessible(true);
-                            contentHandler = (ContentHandler) ctor.newInstance();
-                        } catch (Throwable cnfe) {
-                            msg = "Class not found for option -ContentHandler";
-                            System.err.println(msg);
-                            doExit(msg);
-                        }
-                    } else {
-                        //            "Missing argument for);
-                        msg = "Missing argument for -ContentHandler";
-                        System.err.println(msg);
-                        doExit(msg);
-                    }
-                } else if ("-XO".equalsIgnoreCase(argv[i])) {
-                    if (useXSLTC) {
-                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                            tfactory.setAttribute("generate-translet", "true");
-                            tfactory.setAttribute("translet-name", argv[++i]);
-                        } else {
-                            tfactory.setAttribute("generate-translet", "true");
-                        }
-                    } else {
-                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                            i++;
-                        }
-                        printInvalidXalanOption("-XO");
-                    }
-                } // Specify the destination directory for the translet classes.
-                else if ("-XD".equalsIgnoreCase(argv[i])) {
-                    if (useXSLTC) {
-                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                            tfactory.setAttribute("destination-directory", argv[++i]);
-                        } else {
-                            System.err.println("Missing argument for -XD");  //"Missing argument for);
-                        }
-                    } else {
-                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                            i++;
-                        }
-
-                        printInvalidXalanOption("-XD");
-                    }
-                } // Specify the jar file name which the translet classes are packaged into.
-                else if ("-XJ".equalsIgnoreCase(argv[i])) {
-                    if (useXSLTC) {
-                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                            tfactory.setAttribute("generate-translet", "true");
-                            tfactory.setAttribute("jar-name", argv[++i]);
-                        } else {
-                            System.err.println("Missing argument for -XJ");  //"Missing argument for);
-                        }
-                    } else {
-                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                            i++;
-                        }
-
-                        printInvalidXalanOption("-XJ");
-                    }
-
-                } // Specify the package name prefix for the generated translet classes.
-                else if ("-XP".equalsIgnoreCase(argv[i])) {
-                    if (useXSLTC) {
-                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                            tfactory.setAttribute("package-name", argv[++i]);
-                        } else {
-                            System.err.println("Missing argument for -XP");  //"Missing argument for);
-                        }
-                    } else {
-                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
-                            i++;
-                        }
-
-                        printInvalidXalanOption("-XP");
-                    }
-
-                } // Enable template inlining.
-                else if ("-XN".equalsIgnoreCase(argv[i])) {
-                    if (useXSLTC) {
-                        tfactory.setAttribute("enable-inlining", "true");
-                    } else {
-                        printInvalidXalanOption("-XN");
-                    }
-                } // Turns on additional debugging message output
-                else if ("-XX".equalsIgnoreCase(argv[i])) {
-                    if (useXSLTC) {
-                        tfactory.setAttribute("debug", "true");
-                    } else {
-                        printInvalidXalanOption("-XX");
-                    }
-                } // Create the Transformer from the translet if the translet class is newer
-                // than the stylesheet.
-                else if ("-XT".equalsIgnoreCase(argv[i])) {
-                    if (useXSLTC) {
-                        tfactory.setAttribute("auto-translet", "true");
-                    } else {
-                        printInvalidXalanOption("-XT");
-                    }
-                } else if ("-SECURE".equalsIgnoreCase(argv[i])) {
-                    isSecureProcessing = true;
-                    try {
-                        tfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-                    } catch (TransformerConfigurationException e) {
-                    }
-                } else {
-                    System.err.println("Invalid argument: " + argv[i]);  //"Invalid argument:);
-                }
-            }
-
-            // Print usage instructions if no xml and xsl file is specified in the command line
-            if (inFileName == null && xslFileName == null) {
-                msg = "Error: No stylesheet or input xml is specified. Run this command without any option for usage instructions.";
-                System.err.println(msg);
-                doExit(msg);
-            }
-
-      // Note that there are usage cases for calling us without a -IN arg
-            // The main XSL transformation occurs here!
-            try {
-                long start = System.currentTimeMillis();
-
-                if (null != dumpFileName) {
-                    dumpWriter = new PrintWriter(new FileWriter(dumpFileName));
-                }
-
-                Templates stylesheet = null;
-
-                if (null != xslFileName) {
-                    if (flavor.equals("d2d")) {
-
-                        // Parse in the xml data into a DOM
-                        DocumentBuilderFactory dfactory
-                                = DocumentBuilderFactory.newInstance();
-
-                        dfactory.setNamespaceAware(true);
-
-                        if (isSecureProcessing) {
-                            try {
-                                dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-                            } catch (ParserConfigurationException pce) {
-                            }
-                        }
-
-                        DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-                        Node xslDOM = docBuilder.parse(new InputSource(xslFileName));
-
-                        stylesheet = tfactory.newTemplates(new DOMSource(xslDOM,
-                                xslFileName));
-                    } else {
-                        // System.out.println("Calling newTemplates: "+xslFileName);
-                        stylesheet = tfactory.newTemplates(new StreamSource(xslFileName));
-                        // System.out.println("Done calling newTemplates: "+xslFileName);
-                    }
-                }
-
-                PrintWriter resultWriter;
-                StreamResult strResult;
-
-                if (null != outFileName) {
-                    strResult = new StreamResult(new FileOutputStream(outFileName));
-                    // One possible improvement might be to ensure this is
-                    //  a valid URI before setting the systemId, but that
-                    //  might have subtle changes that pre-existing users
-                    //  might notice; we can think about that later -sc r1.46
-                    strResult.setSystemId(outFileName);
-                } else {
-                    strResult = new StreamResult(System.out);
-                    // We used to default to incremental mode in this case.
-                    // We've since decided that since the -INCREMENTAL switch is
-                    // available, that default is probably not necessary nor
-                    // necessarily a good idea.
-                }
-
-                SAXTransformerFactory stf = (SAXTransformerFactory) tfactory;
-
-                // Did they pass in a stylesheet, or should we get it from the
-                // document?
-                if (null == stylesheet) {
-                    Source source
-                            = stf.getAssociatedStylesheet(new StreamSource(inFileName), media,
-                                    null, null);
-
-                    if (null != source) {
-                        stylesheet = tfactory.newTemplates(source);
-                    } else {
-                        if (null != media) {
-                            throw new TransformerException("No stylesheet found in:  "
-                                    + inFileName + ", media=" + media); //"No stylesheet found in: "
-                        } // + inFileName + ", media="
-                        // + media);
-                        else {
-                            throw new TransformerException("No xml-stylesheet PI found in: " + inFileName); //"No xml-stylesheet PI found in: "
-                        }                                             //+ inFileName);
-                    }
-                }
-
-                if (null != stylesheet) {
-                    Transformer transformer = flavor.equals("th") ? null : stylesheet.newTransformer();
-                    transformer.setErrorListener(createDefaultErrorListener());
-
-                    // Override the output format?
-                    if (null != outputType) {
-                        transformer.setOutputProperty(OutputKeys.METHOD, outputType);
-                    }
-
-                    int nParams = params.size();
-
-                    for (int i = 0; i < nParams; i += 2) {
-                        transformer.setParameter((String) params.get(i),
-                                (String) params.get(i + 1));
-                    }
-
-                    if (uriResolver != null) {
-                        transformer.setURIResolver(uriResolver);
-                    }
-
-                    if (null != inFileName) {
-                        if (flavor.equals("d2d")) {
-
-                            // Parse in the xml data into a DOM
-                            DocumentBuilderFactory dfactory
-                                    = DocumentBuilderFactory.newInstance();
-
-                            dfactory.setCoalescing(true);
-                            dfactory.setNamespaceAware(true);
-
-                            if (isSecureProcessing) {
-                                try {
-                                    dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-                                } catch (ParserConfigurationException pce) {
-                                }
-                            }
-
-                            DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
-
-                            if (entityResolver != null) {
-                                docBuilder.setEntityResolver(entityResolver);
-                            }
-
-                            Node xmlDoc = docBuilder.parse(new InputSource(inFileName));
-                            Document doc = docBuilder.newDocument();
-                            org.w3c.dom.DocumentFragment outNode
-                                    = doc.createDocumentFragment();
-
-                            transformer.transform(new DOMSource(xmlDoc, inFileName),
-                                    new DOMResult(outNode));
-
-                            // Now serialize output to disk with identity transformer
-                            Transformer serializer = stf.newTransformer();
-                            serializer.setErrorListener(createDefaultErrorListener());
-
-                            Properties serializationProps
-                                    = stylesheet.getOutputProperties();
-
-                            serializer.setOutputProperties(serializationProps);
-
-                            if (contentHandler != null) {
-                                SAXResult result = new SAXResult(contentHandler);
-
-                                serializer.transform(new DOMSource(outNode), result);
-                            } else {
-                                serializer.transform(new DOMSource(outNode), strResult);
-                            }
-                        } else if (flavor.equals("th")) {
-                            for (int i = 0; i < 1; i++) // Loop for diagnosing bugs with inconsistent behavior
-                            {
-                                // System.out.println("Testing the TransformerHandler...");
-
-                                XMLReader reader = null;
-
-                                // Use JAXP1.1 ( if possible )
-                                try {
-                                    javax.xml.parsers.SAXParserFactory factory
-                                            = javax.xml.parsers.SAXParserFactory.newInstance();
-
-                                    factory.setNamespaceAware(true);
-
-                                    if (isSecureProcessing) {
-                                        try {
-                                            factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-                                        } catch (org.xml.sax.SAXException se) {
-                                        }
-                                    }
-
-                                    javax.xml.parsers.SAXParser jaxpParser
-                                            = factory.newSAXParser();
-
-                                    reader = jaxpParser.getXMLReader();
-                                } catch (javax.xml.parsers.ParserConfigurationException ex) {
-                                    throw new org.xml.sax.SAXException(ex);
-                                } catch (javax.xml.parsers.FactoryConfigurationError ex1) {
-                                    throw new org.xml.sax.SAXException(ex1.toString());
-                                } catch (NoSuchMethodError ex2) {
-                                } catch (AbstractMethodError ame) {
-                                }
-
-                                if (null == reader) {
-                                    reader = XMLReaderFactory.createXMLReader();
-                                }
-
-                                TransformerHandler th = stf.newTransformerHandler(stylesheet);
-
-                                reader.setContentHandler(th);
-                                reader.setDTDHandler(th);
-
-                                if (th instanceof org.xml.sax.ErrorHandler) {
-                                    reader.setErrorHandler((org.xml.sax.ErrorHandler) th);
-                                }
-
-                                try {
-                                    reader.setProperty(
-                                            "http://xml.org/sax/properties/lexical-handler", th);
-                                } catch (org.xml.sax.SAXNotRecognizedException e) {
-                                } catch (org.xml.sax.SAXNotSupportedException e) {
-                                }
-                                try {
-                                    reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
-                                            true);
-                                } catch (org.xml.sax.SAXException se) {
-                                }
-
-                                th.setResult(strResult);
-
-                                reader.parse(new InputSource(inFileName));
-                            }
-                        } else {
-                            if (entityResolver != null) {
-                                XMLReader reader = null;
-
-                                // Use JAXP1.1 ( if possible )
-                                try {
-                                    javax.xml.parsers.SAXParserFactory factory
-                                            = javax.xml.parsers.SAXParserFactory.newInstance();
-
-                                    factory.setNamespaceAware(true);
-
-                                    if (isSecureProcessing) {
-                                        try {
-                                            factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-                                        } catch (org.xml.sax.SAXException se) {
-                                        }
-                                    }
-
-                                    javax.xml.parsers.SAXParser jaxpParser
-                                            = factory.newSAXParser();
-
-                                    reader = jaxpParser.getXMLReader();
-                                } catch (javax.xml.parsers.ParserConfigurationException ex) {
-                                    throw new org.xml.sax.SAXException(ex);
-                                } catch (javax.xml.parsers.FactoryConfigurationError ex1) {
-                                    throw new org.xml.sax.SAXException(ex1.toString());
-                                } catch (NoSuchMethodError ex2) {
-                                } catch (AbstractMethodError ame) {
-                                }
-
-                                if (null == reader) {
-                                    reader = XMLReaderFactory.createXMLReader();
-                                }
-
-                                reader.setEntityResolver(entityResolver);
-
-                                if (contentHandler != null) {
-                                    SAXResult result = new SAXResult(contentHandler);
-
-                                    transformer.transform(
-                                            new SAXSource(reader, new InputSource(inFileName)),
-                                            result);
-                                } else {
-                                    transformer.transform(
-                                            new SAXSource(reader, new InputSource(inFileName)),
-                                            strResult);
-                                }
-                            } else if (contentHandler != null) {
-                                SAXResult result = new SAXResult(contentHandler);
-
-                                transformer.transform(new StreamSource(inFileName), result);
-                            } else {
-                                // System.out.println("Starting transform");
-                                transformer.transform(new StreamSource(inFileName),
-                                        strResult);
-                                // System.out.println("Done with transform");
-                            }
-                        }
-                    } else {
-                        StringReader reader
-                                = new StringReader("<?xml version=\"1.0\"?> <doc/>");
-
-                        transformer.transform(new StreamSource(reader), strResult);
-                    }
-                } else {
-                    //          "XSL Process was not successful.");
-                    msg = "XSL Process was not successful.";
-                    diagnosticsWriter.println(msg);
-                    doExit(msg);
-                }
-
-                // close output streams
-                if (null != outFileName && strResult != null) {
-                    java.io.OutputStream out = strResult.getOutputStream();
-                    java.io.Writer writer = strResult.getWriter();
-                    try {
-                        if (out != null) {
-                            out.close();
-                        }
-                        if (writer != null) {
-                            writer.close();
-                        }
-                    } catch (java.io.IOException ie) {
-                    }
-                }
-
-                long stop = System.currentTimeMillis();
-                long millisecondsDuration = stop - start;
-
-                if (doDiag) {
-                    msg = " --------- Transform of " + inFileName + " via "
-                            + xslFileName + " took " + millisecondsDuration + " ms";
-                    diagnosticsWriter.println('\n');
-                    diagnosticsWriter.println(msg);
-                }
-
-            } catch (Throwable throwable) {
-                doStackDumpOnError = true;
-
-                diagnosticsWriter.println();
-
-                if (doStackDumpOnError) {
-                    throwable.printStackTrace(dumpWriter);
-                } else {
-                    printLocation(diagnosticsWriter, throwable);
-                    diagnosticsWriter.println("Unexpected exception: " + throwable);
-                }
-
-                // diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL, null)); //"XSL Process was not successful.");
-                if (null != dumpFileName) {
-                    dumpWriter.close();
-                }
-
-                doExit(throwable.getMessage());
-            }
-
-            if (null != dumpFileName) {
-                dumpWriter.close();
-            }
-
-            if (null != diagnosticsWriter) {
-
-                // diagnosticsWriter.close();
-            }
-
-            // if(!setQuietMode)
-            //  diagnosticsWriter.println(resbundle.getString("xsldone")); //"Xalan: done");
-            // else
-            // diagnosticsWriter.println("");  //"Xalan: done");
-        }
-    }
-
-    /**
-     * It is _much_ easier to debug under VJ++ if I can set a single breakpoint
-     * before this blows itself out of the water... (I keep checking this in, it
-     * keeps vanishing. Grr!)
-     *
-     */
-    static void doExit(String msg) {
-        throw new RuntimeException(msg);
-    }
-
-    /**
-     * Wait for a return key to continue
-     *
-     * @param resbundle The resource bundle
-     */
-    private static void waitForReturnKey() {
-        System.out.println("(press <return> to continue)");
-        try {
-            while (System.in.read() != '\n');
-        } catch (java.io.IOException e) {
-        }
-    }
-
-    /**
-     * Print a message if an option cannot be used with -XSLTC.
-     *
-     * @param option The option String
-     */
-    private static void printInvalidXSLTCOption(String option) {
-        System.err.println("The option " + option + " is not supported in XSLTC mode.");
-    }
-
-    /**
-     * Print a message if an option can only be used with -XSLTC.
-     *
-     * @param option The option String
-     */
-    private static void printInvalidXalanOption(String option) {
-        System.err.println("The option " + option + " can only be used with -XSLTC.");
-    }
-
-    static class DummyErrorListenerHandler implements ErrorHandler, ErrorListener {
-        @Override
-        public void warning(SAXParseException exception) throws SAXException {
-            System.err.println("WARNING: " + exception);
-        }
-        @Override
-        public void error(SAXParseException exception) throws SAXException {
-            throw exception;
-        }
-        @Override
-        public void fatalError(SAXParseException exception) throws SAXException {
-            throw exception;
-        }
-        @Override
-        public void warning(TransformerException exception) throws TransformerException {
-            System.err.println("WARNING: " + exception);
-        }
-        @Override
-        public void error(TransformerException exception) throws TransformerException {
-            throw exception;
-        }
-        @Override
-        public void fatalError(TransformerException exception) throws TransformerException {
-            throw exception;
-        }
-    }
-
-    static ErrorListener createDefaultErrorListener() {
-        try {
-            Class<?> errorHandler =
-                    Class.forName("com.sun.org.apache.xml.internal.utils.DefaultErrorHandler");
-            Constructor<?> ctor = errorHandler.getConstructor();
-            return (ErrorListener) ctor.newInstance();
-        } catch (Throwable r) {
-            return new DummyErrorListenerHandler();
-        }
-    }
-
-    private static void printLocation(PrintWriter diagnosticsWriter, Throwable throwable) {
-        try {
-            Class<?> errorHandler =
-                    Class.forName("com.sun.org.apache.xml.internal.utils.DefaultErrorHandler");
-            Method m = errorHandler.getMethod("printLocation", PrintWriter.class, Throwable.class);
-            m.invoke(null, diagnosticsWriter, throwable);
-        } catch (Throwable t) {
-            SourceLocator locator = null;
-            Throwable cause = throwable;
-
-            // Try to find the locator closest to the cause.
-            do {
-                if (cause instanceof TransformerException) {
-                    SourceLocator causeLocator = ((TransformerException) cause).getLocator();
-                    if (null != causeLocator) {
-                        locator = causeLocator;
-                    }
-                    cause = ((TransformerException) cause).getCause();
-                } else if (cause instanceof SAXException) {
-                    cause = ((SAXException) cause).getException();
-                } else {
-                    cause = cause.getCause();
-                }
-            } while (null != cause);
-
-            if (null != locator) {
-                // m_pw.println("Parser fatal error: "+exception.getMessage());
-                String id = (null != locator.getPublicId())
-                        ? locator.getPublicId()
-                        : (null != locator.getSystemId())
-                                ? locator.getSystemId() : "SystemId Unknown"; //"SystemId Unknown";
-
-                diagnosticsWriter.print(id + "; " + "line: " + locator.getLineNumber()
-                        + "; column: " + locator.getColumnNumber() + "; ");
-            }
-            diagnosticsWriter.print("(" + throwable + ": unknown location)");
-        }
-    }
-
-}
--- a/jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/cli/tigertest-in.xml	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<office:document xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style"  office:class="text" office:version="1.0">
-	<office:styles>
-		<style:default-style style:family="graphics"/>
-		<style:default-style style:family="paragraph"/>
-	</office:styles>
-</office:document>
--- a/jaxp/test/javax/xml/jaxp/internaltest/javax/xml/transform/cli/tigertest.xsl	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-<?xml version='1.0' encoding="UTF-8"?>
-<xsl:stylesheet version="1.0"
-		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-		xmlns:office="http://openoffice.org/2000/office"
-		xmlns:style="http://openoffice.org/2000/style">
-
-	<xsl:output method="xml" encoding="UTF-8"/>
-
-	<xsl:template match="/">
-		<xsl:variable name="copyData">
-			<xsl:call-template name="copy-by-template" />
-		</xsl:variable>
-		<test>
-  		   <xsl:copy-of select="$copyData"/>
-		</test>
-	</xsl:template>
-
-	<xsl:template name="copy-by-template">
-		<xsl:copy-of select="/"/>
-	</xsl:template>
-</xsl:stylesheet>
--- a/jaxp/test/javax/xml/jaxp/isolatedjdk/TEST.properties	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-lib.dirs=/javax/xml/jaxp/libs
-
-# Declare module dependency
-modules=java.xml
\ No newline at end of file
--- a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java	Mon Aug 08 12:50:00 2016 +0800
@@ -37,6 +37,8 @@
 import javax.xml.catalog.CatalogResolver;
 import javax.xml.catalog.CatalogUriResolver;
 
+import jaxp.library.JAXPTestUtilities;
+
 /*
  * Utilities for testing XML Catalog API.
  */
@@ -126,24 +128,10 @@
     static String getCatalogPath(String catalogName) {
         return catalogName == null
                 ? null
-                : getPathByClassName(CatalogTestUtils.class, "catalogFiles")
+                : JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles")
                         + catalogName;
     }
 
-    /*
-     * Acquire a full path string by given class name and relative path string.
-     */
-    private static String getPathByClassName(Class<?> clazz,
-            String relativeDir) {
-        String packageName = FILE_SEP
-                + clazz.getPackage().getName().replaceAll("[.]", FILE_SEP);
-        String javaSourcePath = System.getProperty("test.src").replaceAll(
-                "\\" + File.separator, FILE_SEP) + packageName + FILE_SEP;
-        String normalizedPath = Paths.get(javaSourcePath,
-                relativeDir).normalize().toAbsolutePath().toString();
-        return normalizedPath.replace("\\", FILE_SEP) + FILE_SEP;
-    }
-
     /* ********** jaxp.properties ********** */
 
     /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/BasePolicy.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jaxp.library;
+
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+/**
+ * This policy includes default permissions.
+ * It should be used as one listener: either TestListener or MethodListener.
+ */
+public class BasePolicy implements ITestListener {
+
+    @Override
+    public void onFinish(ITestContext arg0) {
+        try {
+            JAXPPolicyManager.teardownPolicyManager();
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to teardonw the policy manager", e);
+        }
+    }
+
+    @Override
+    public void onStart(ITestContext arg0) {
+        // suppose to only run othervm mode
+        if (isRunWithSecurityManager())
+            JAXPPolicyManager.getJAXPPolicyManager(true);
+    }
+
+    @Override
+    public void onTestFailedButWithinSuccessPercentage(ITestResult arg0) {
+    }
+
+    @Override
+    public void onTestFailure(ITestResult arg0) {
+    }
+
+    @Override
+    public void onTestSkipped(ITestResult arg0) {
+    }
+
+    @Override
+    public void onTestStart(ITestResult arg0) {
+    }
+
+    @Override
+    public void onTestSuccess(ITestResult arg0) {
+    }
+
+    protected boolean isRunWithSecurityManager() {
+        final String runSecMngr = JAXPTestUtilities.getSystemProperty("runSecMngr");
+        return runSecMngr != null && runSecMngr.equals("true");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/FilePolicy.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jaxp.library;
+
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
+import java.io.FilePermission;
+
+import org.testng.ITestContext;
+
+/**
+ * This policy can access local XML files.
+ */
+public class FilePolicy extends BasePolicy {
+
+    @Override
+    public void onStart(ITestContext arg0) {
+        // suppose to only run othervm mode
+        if (isRunWithSecurityManager()) {
+            JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(true);
+            String userdir = getSystemProperty("user.dir");
+            policyManager.addPermission(new FilePermission(userdir + "/-", "read,write,delete"));
+            String testSrc = System.getProperty("test.src");
+            // to handle the directory structure of some functional test suite
+            if (testSrc.endsWith("ptests"))
+                testSrc = testSrc.substring(0, testSrc.length() - 7);
+            policyManager.addPermission(new FilePermission(testSrc + "/-", "read"));
+            policyManager.addPermission(new FilePermission(userdir, "read"));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/InternalAPIPolicy.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jaxp.library;
+
+import org.testng.ITestContext;
+
+/**
+ * This policy can access internal jaxp packages.
+ */
+public class InternalAPIPolicy extends BasePolicy {
+
+    @Override
+    public void onStart(ITestContext arg0) {
+        // suppose to only run othervm mode
+        if (isRunWithSecurityManager()) {
+            JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(true);
+            policyManager.addPermission(new RuntimePermission("accessClassInPackage.com.sun.org.apache.xerces.internal.jaxp"));
+            policyManager.addPermission(new RuntimePermission("accessClassInPackage.com.sun.org.apache.bcel.internal.classfile"));
+            policyManager.addPermission(new RuntimePermission("accessClassInPackage.com.sun.org.apache.bcel.internal.generic"));
+            policyManager.addPermission(new RuntimePermission("accessClassInPackage.com.sun.org.apache.xalan.internal.xsltc.trax"));
+        }
+    }
+}
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPBaseTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jaxp.library;
-
-import java.security.Permission;
-import java.security.Permissions;
-import java.security.Policy;
-import java.util.PropertyPermission;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-
-/**
- * This is a base class that every test class must extend if it needs to be run
- * with security mode.
- */
-public class JAXPBaseTest {
-    /**
-     * Backing up policy.
-     */
-    protected static Policy policy;
-
-    /**
-     * Backing up security manager.
-     */
-    private static SecurityManager sm;
-
-    /*
-     * Install a SecurityManager along with a base Policy to allow testNG to
-     * run when there is a security manager.
-     */
-    @BeforeClass
-    public void setUpClass() throws Exception {
-        setPolicy(new TestPolicy());
-        System.setSecurityManager(new SecurityManager());
-    }
-
-    /*
-     * Install the original Policy and SecurityManager when there is a security
-     * manager.
-     */
-    @AfterClass
-    public void tearDownClass() throws Exception {
-        System.setSecurityManager(sm);
-        setPolicy(policy);
-    }
-
-    /*
-     * Utility Method used to set the current Policy.
-     */
-    protected static void setPolicy(Policy p) {
-        Policy.setPolicy(p);
-    }
-
-    /*
-     * Add the specified permission(s) to the test policy.
-     * Note there is no way to add permissions to current permissions. Reset
-     * test policy by setting minimal permmisons in addition to specified
-     * permissions when calling this method.
-     */
-    protected static void setPermissions(Permission... ps) {
-        Policy.setPolicy(new TestPolicy(ps));
-    }
-
-    /*
-     * Add the specified permission(s) to the test policy.
-     * Note there is no way to add permissions to current permissions. Reset
-     * test policy by setting minimal permmisons in addition to specified
-     * permissions when calling this method.
-     */
-    protected static void setPermissions(Permissions ps) {
-        Policy.setPolicy(new TestPolicy(ps));
-    }
-
-    /**
-     * Backing up policy and security manager for restore when there is a
-     * security manager.
-     */
-    public JAXPBaseTest() {
-        policy = Policy.getPolicy();
-        sm = System.getSecurityManager();
-    }
-
-    /**
-     * Safety acquire a system property.
-     * Note invocation of this method will restore permission to limited
-     * minimal permission of tests. If there is additional permission set
-     * already, you need restore permission by yourself.
-     * @param propName System property name to be acquired.
-     * @return property value
-     */
-    protected String getSystemProperty(final String propName) {
-        setPermissions(new PropertyPermission(propName, "read"));
-        try {
-            return System.getProperty(propName);
-        } finally {
-            setPermissions();
-        }
-    }
-
-    /**
-     * Safety set a system property by given system value.
-     *
-     * @param propName System property name to be set.
-     * @param propValue System property value to be set.
-     */
-    protected void setSystemProperty(final String propName, final String propValue) {
-        setPermissions(new PropertyPermission(propName, "write"));
-        try {
-            if (propValue == null) {
-                System.clearProperty(propName);
-            } else {
-                System.setProperty(propName, propValue);
-            }
-        } finally {
-            setPermissions();
-        }
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPFileBaseTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jaxp.library;
-
-import java.io.FilePermission;
-import java.security.Permission;
-import java.security.Permissions;
-import java.security.Policy;
-import static jaxp.library.JAXPBaseTest.setPolicy;
-import org.testng.annotations.BeforeClass;
-
-/**
- * This is a base class that every test class that need to access local XML
- * files must extend if it needs to be run with security mode.
- */
-public class JAXPFileBaseTest extends JAXPBaseTest {
-    /*
-     * Install a SecurityManager along with a base Policy to allow testNG to
-     * run when there is a security manager.
-     */
-    @BeforeClass
-    @Override
-    public void setUpClass() throws Exception {
-        setPolicy(new FileTestPolicy());
-        System.setSecurityManager(new SecurityManager());
-    }
-
-    /*
-     * Add the specified permission(s) to the test policy.
-     * Note there is no way to add permissions to current permissions. Reset
-     * test policy by setting minimal permmisons in addition to specified
-     * permissions when calling this method.
-     */
-    protected static void setPermissions(Permission... ps) {
-        Policy.setPolicy(new FileTestPolicy(ps));
-    }
-
-    /*
-     * Add the specified permission(s) to the test policy.
-     * Note there is no way to add permissions to current permissions. Reset
-     * test policy by setting minimal permmisons in addition to specified
-     * permissions when calling this method.
-     */
-    protected static void setPermissions(Permissions ps) {
-        Policy.setPolicy(new FileTestPolicy(ps));
-    }
-}
-
-/**
- * This policy is only given to tests that need access local files. Additional
- * permissions for accessing local files have been granted by default.
- * @author HaiboYan
- */
-class FileTestPolicy extends TestPolicy {
-    /**
-     * Constructor which sets the minimum permissions by default allowing testNG
-     * to work with a SecurityManager.
-     * @param ps permissions to be added.
-     */
-    public FileTestPolicy(Permissions ps) {
-        super(ps);
-    }
-
-    /**
-     * Constructor which sets the minimum permissions by default allowing testNG
-     * to work with a SecurityManager.
-     * @param ps permission array to be added.
-     */
-    public FileTestPolicy(Permission... ps) {
-        super(ps);
-    }
-
-    /**
-     * Defines the minimal permissions required by testNG when running these
-     * tests
-     */
-    @Override
-    protected void setMinimalPermissions() {
-        super.setMinimalPermissions();
-        permissions.add(new FilePermission(System.getProperty("user.dir") + "/-",
-                "read, write"));
-        permissions.add(new FilePermission(System.getProperty("test.src") + "/-",
-                "read"));
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPFileReadOnlyBaseTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jaxp.library;
-
-import java.io.FilePermission;
-import static jaxp.library.JAXPBaseTest.setPermissions;
-import org.testng.annotations.AfterGroups;
-import org.testng.annotations.BeforeGroups;
-
-/**
- * This is a base class that every test class that need to reading local XML
- * files must extend if it needs to be run with security mode.
- */
-public class JAXPFileReadOnlyBaseTest extends JAXPBaseTest {
-    /**
-     * Source files/XML files directory.
-     */
-    private final String SRC_DIR = getSystemProperty("test.src");
-
-    /**
-     * Allowing access local file system for this group.
-     */
-    @BeforeGroups (groups = {"readLocalFiles"})
-    public void setFilePermissions() {
-        setPermissions(new FilePermission(SRC_DIR + "/-", "read"));
-    }
-
-    /**
-     * Restore the system property.
-     */
-    @AfterGroups (groups = {"readLocalFiles"})
-    public void restoreFilePermissions() {
-        setPermissions();
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPPolicyManager.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jaxp.library;
+
+
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.security.SecurityPermission;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.PropertyPermission;
+import java.util.StringJoiner;
+
+
+/*
+ * This is a base class that every test class must extend if it needs to be run
+ * with security mode.
+ */
+public class JAXPPolicyManager {
+    /*
+     * Backing up policy.
+     */
+    private Policy policyBackup;
+
+    /*
+     * Backing up security manager.
+     */
+    private SecurityManager smBackup;
+
+    /*
+     * Current policy.
+     */
+    private TestPolicy policy = new TestPolicy();
+
+    /*
+     * JAXPPolicyManager singleton.
+     */
+    private static JAXPPolicyManager policyManager = null;
+
+    /*
+     * Install a SecurityManager along with a default Policy to allow testNG to
+     * run when there is a security manager.
+     */
+    private JAXPPolicyManager() {
+        // Backing up policy and security manager for restore
+        policyBackup = Policy.getPolicy();
+        smBackup = System.getSecurityManager();
+
+        // Set customized policy
+        setDefaultPermissions();
+        Policy.setPolicy(policy);
+        System.setSecurityManager(new SecurityManager());
+    }
+
+    static synchronized JAXPPolicyManager getJAXPPolicyManager(boolean createIfNone) {
+        if (policyManager == null & createIfNone)
+            policyManager = new JAXPPolicyManager();
+        return policyManager;
+    }
+
+    private void teardown() throws Exception {
+        System.setSecurityManager(smBackup);
+        Policy.setPolicy(policyBackup);
+    }
+
+    /*
+     * Restore the original Policy and SecurityManager.
+     */
+    static synchronized void teardownPolicyManager() throws Exception {
+        if (policyManager != null) {
+            policyManager.teardown();
+            policyManager = null;
+        }
+    }
+
+    /*
+     * Set default permissions, sub-class of JAXPBaseTest should override this
+     * method.
+     */
+    private void setDefaultPermissions() {
+        //Permissions to set security manager and policy
+        addPermission(new SecurityPermission("getPolicy"));
+        addPermission(new SecurityPermission("setPolicy"));
+        addPermission(new RuntimePermission("setSecurityManager"));
+        //Properties that jtreg and TestNG require
+        addPermission(new PropertyPermission("testng.show.stack.frames", "read"));
+        addPermission(new PropertyPermission("test.src", "read"));
+        addPermission(new PropertyPermission("test.classes", "read"));
+        addPermission(new PropertyPermission("dataproviderthreadcount", "read"));
+        addPermission(new PropertyPermission("experimental", "read"));
+    }
+
+    /*
+     * Add permission to the TestPolicy.
+     *
+     * @param permission to be added.
+     */
+    void addPermission(Permission p) {
+        policy.addPermission(p);
+    }
+
+    /*
+     * Add a temporary permission in current thread context. This won't impact
+     * global policy and doesn't support permission combination.
+     *
+     * @param permission
+     *            to add.
+     * @return index of the added permission.
+     */
+    int addTmpPermission(Permission p) {
+        return policy.addTmpPermission(p);
+    }
+
+    /*
+     * set allowAll in current thread context.
+     */
+    void setAllowAll(boolean allow) {
+        policy.setAllowAll(allow);
+    }
+
+    /*
+     * Remove a temporary permission from current thread context.
+     *
+     * @param index to remove.
+     *
+     * @throws RuntimeException if no temporary permission list in current
+     *             thread context or no permission correlated to the index.
+     */
+    void removeTmpPermission(int index) {
+        policy.removeTmpPermission(index);
+    }
+
+
+}
+
+/*
+ * Simple Policy class that supports the required Permissions to validate the
+ * JAXP concrete classes.
+ */
+class TestPolicy extends Policy {
+    private final PermissionCollection permissions = new Permissions();
+
+    private ThreadLocal<Map<Integer, Permission>> transientPermissions = new ThreadLocal<>();
+    private ThreadLocal<Boolean> allowAll = new ThreadLocal<>();
+
+    private static Policy defaultPolicy = Policy.getPolicy();
+
+    /*
+     * Add permission to this policy.
+     *
+     * @param permission to be added.
+     */
+    void addPermission(Permission p) {
+        permissions.add(p);
+    }
+
+    /*
+     * Set all permissions. Caution: this should not called carefully unless
+     * it's really needed.
+     *
+     * private void setAllPermissions() { permissions.add(new AllPermission());
+     * }
+     */
+
+    /*
+     * Overloaded methods from the Policy class.
+     */
+    @Override
+    public String toString() {
+        StringJoiner sj = new StringJoiner("\n", "policy: ", "");
+        Enumeration<Permission> perms = permissions.elements();
+        while (perms.hasMoreElements()) {
+            sj.add(perms.nextElement().toString());
+        }
+        return sj.toString();
+
+    }
+
+    @Override
+    public PermissionCollection getPermissions(ProtectionDomain domain) {
+        return permissions;
+    }
+
+    @Override
+    public PermissionCollection getPermissions(CodeSource codesource) {
+        return permissions;
+    }
+
+    @Override
+    public boolean implies(ProtectionDomain domain, Permission perm) {
+        if (allowAll())
+            return true;
+
+        if (defaultPolicy.implies(domain, perm))
+            return true;
+
+        if (permissions.implies(perm))
+            return true;
+        else
+            return tmpImplies(perm);
+    }
+
+    /*
+     * Add a temporary permission in current thread context. This won't impact
+     * global policy and doesn't support permission combination.
+     *
+     * @param permission to add.
+     * @return index of the added permission.
+     */
+    int addTmpPermission(Permission p) {
+        Map<Integer, Permission> tmpPermissions = transientPermissions.get();
+        if (tmpPermissions == null)
+            tmpPermissions = new HashMap<>();
+
+        int id = tmpPermissions.size();
+        tmpPermissions.put(id, p);
+        transientPermissions.set(tmpPermissions);
+        return id;
+    }
+
+    /*
+     * Remove a temporary permission from current thread context.
+     *
+     * @param index to remove.
+     *
+     * @throws RuntimeException if no temporary permission list in current
+     *             thread context or no permission correlated to the index.
+     */
+    void removeTmpPermission(int index) {
+        try {
+            Map<Integer, Permission> tmpPermissions = transientPermissions.get();
+            tmpPermissions.remove(index);
+        } catch (NullPointerException | IndexOutOfBoundsException e) {
+            throw new RuntimeException("Tried to delete a non-existent temporary permission", e);
+        }
+    }
+
+    /*
+     * Checks to see if the specified permission is implied by temporary
+     * permission list in current thread context.
+     *
+     * @param permission the Permission object to compare.
+     *
+     * @return true if "permission" is implied by any permission in the
+     *         temporary permission list, false if not.
+     */
+    private boolean tmpImplies(Permission perm) {
+        Map<Integer, Permission> tmpPermissions = transientPermissions.get();
+        if (tmpPermissions != null) {
+            for (Permission p : tmpPermissions.values()) {
+                if (p.implies(perm))
+                    return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+     * Checks to see if allow all permission requests in current thread context.
+     */
+    private boolean allowAll() {
+        Boolean allow = allowAll.get();
+        if (allow != null) {
+            return allow;
+        }
+        return false;
+    }
+
+    /*
+     * set allowAll in current thread context.
+     */
+    void setAllowAll(boolean allow) {
+        allowAll.set(allow);
+    }
+}
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,8 @@
  */
 package jaxp.library;
 
+import static org.testng.Assert.fail;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
@@ -34,12 +36,18 @@
 import java.nio.charset.UnsupportedCharsetException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.security.Permission;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Supplier;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -48,7 +56,7 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
-import static org.testng.Assert.fail;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -74,12 +82,6 @@
     public static final String FILE_SEP = "/";
 
     /**
-     * Current test directory.
-     */
-    public static final String USER_DIR =
-            System.getProperty("user.dir", ".") + FILE_SEP;;
-
-    /**
      * A map storing every test's current test file pointer. File number should
      * be incremental and it's a thread-safe reading on this file number.
      */
@@ -89,7 +91,7 @@
     /**
      * BOM table for storing BOM header.
      */
-    private final static Map<String, byte[]> bom = new HashMap<>();
+    private final static Map<String, byte[]> bom = new HashMap();
 
     /**
      * Initialize all BOM headers.
@@ -130,8 +132,15 @@
      */
     public static boolean compareWithGold(String goldfile, String outputfile,
              Charset cs) throws IOException {
-        return Files.readAllLines(Paths.get(goldfile)).
+        boolean isSame = Files.readAllLines(Paths.get(goldfile)).
                 equals(Files.readAllLines(Paths.get(outputfile), cs));
+        if (!isSame) {
+            System.err.println("Golden file " + goldfile + " :");
+            Files.readAllLines(Paths.get(goldfile)).forEach(System.err::println);
+            System.err.println("Output file " + outputfile + " :");
+            Files.readAllLines(Paths.get(outputfile), cs).forEach(System.err::println);
+        }
+        return isSame;
     }
 
     /**
@@ -308,10 +317,10 @@
         int nextNumber = currentFileNumber.contains(clazz)
                 ? currentFileNumber.get(clazz) + 1 : 1;
         Integer i = currentFileNumber.putIfAbsent(clazz, nextNumber);
-        if (i != null && i != nextNumber) {
+        if (i != null) {
             do {
                 nextNumber = currentFileNumber.get(clazz) + 1;
-            } while (currentFileNumber.replace(clazz, nextNumber -1, nextNumber));
+            } while (!currentFileNumber.replace(clazz, nextNumber - 1, nextNumber));
         }
         return USER_DIR + clazz.getName() + nextNumber + ".out";
     }
@@ -324,12 +333,177 @@
      * @return a string represents the full path of accessing path.
      */
     public static String getPathByClassName(Class clazz, String relativeDir) {
-        String packageName = FILE_SEP +
-                clazz.getPackage().getName().replaceAll("[.]", FILE_SEP);
-        String javaSourcePath = System.getProperty("test.src").replaceAll("\\" + File.separator, FILE_SEP)
-                + packageName + FILE_SEP;
+        String javaSourcePath = System.getProperty("test.src").replaceAll("\\" + File.separator, FILE_SEP);
         String normalizedPath = Paths.get(javaSourcePath, relativeDir).normalize().
                 toAbsolutePath().toString();
         return normalizedPath.replace("\\", FILE_SEP) + FILE_SEP;
     }
+
+
+    /**
+     * Run the supplier with all permissions. This won't impact global policy.
+     *
+     * @param s
+     *            Supplier to run
+     */
+    public static <T> T runWithAllPerm(Supplier<T> s) {
+        Optional<JAXPPolicyManager> policyManager = Optional.ofNullable(JAXPPolicyManager
+                .getJAXPPolicyManager(false));
+        policyManager.ifPresent(manager -> manager.setAllowAll(true));
+        try {
+            return s.get();
+        } finally {
+            policyManager.ifPresent(manager -> manager.setAllowAll(false));
+        }
+    }
+
+    /**
+     * Run the supplier with all permissions. This won't impact global policy.
+     *
+     * @param s
+     *            Supplier to run
+     */
+    public static <T> T tryRunWithAllPerm(Callable<T> c) throws Exception {
+        Optional<JAXPPolicyManager> policyManager = Optional.ofNullable(JAXPPolicyManager
+                .getJAXPPolicyManager(false));
+        policyManager.ifPresent(manager -> manager.setAllowAll(true));
+        try {
+            return c.call();
+        } finally {
+            policyManager.ifPresent(manager -> manager.setAllowAll(false));
+        }
+    }
+
+    /**
+     * Run the Runnable with all permissions. This won't impact global policy.
+     *
+     * @param s
+     *            Supplier to run
+     */
+    public static void runWithAllPerm(Runnable r) {
+        Optional<JAXPPolicyManager> policyManager = Optional.ofNullable(JAXPPolicyManager
+                .getJAXPPolicyManager(false));
+        policyManager.ifPresent(manager -> manager.setAllowAll(true));
+        try {
+            r.run();
+        } finally {
+            policyManager.ifPresent(manager -> manager.setAllowAll(false));
+        }
+    }
+
+    /**
+     * Acquire a system property.
+     *
+     * @param name
+     *            System property name to be acquired.
+     * @return property value
+     */
+    public static String getSystemProperty(String name) {
+        return runWithAllPerm(() -> System.getProperty(name));
+    }
+
+    /**
+     * Set a system property by given system value.
+     *
+     * @param name
+     *            System property name to be set.
+     * @param value
+     *            System property value to be set.
+     */
+    public static void setSystemProperty(String name, String value) {
+        runWithAllPerm(() -> System.setProperty(name, value));
+    }
+
+    /**
+     * Clear a system property.
+     *
+     * @param name
+     *            System property name to be cleared.
+     */
+    public static void clearSystemProperty(String name) {
+        runWithAllPerm(() -> System.clearProperty(name));
+    }
+
+    /**
+     * Run the runnable with assigning temporary permissions. This won't impact
+     * global policy.
+     *
+     * @param r
+     *            Runnable to run
+     * @param ps
+     *            assigning permissions to add.
+     */
+    public static void runWithTmpPermission(Runnable r, Permission... ps) {
+        JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(false);
+        List<Integer> tmpPermissionIndexes = new ArrayList();
+        if (policyManager != null) {
+            for (Permission p : ps)
+                tmpPermissionIndexes.add(policyManager.addTmpPermission(p));
+        }
+        try {
+            r.run();
+        } finally {
+            for (int index: tmpPermissionIndexes)
+                policyManager.removeTmpPermission(index);
+        }
+    }
+
+    /**
+     * Run the supplier with assigning temporary permissions. This won't impact
+     * global policy.
+     *
+     * @param s
+     *            Supplier to run
+     * @param ps
+     *            assigning permissions to add.
+     */
+    public static <T> T runWithTmpPermission(Supplier<T> s, Permission... ps) {
+        JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(false);
+        List<Integer> tmpPermissionIndexes = new ArrayList();
+        if (policyManager != null) {
+            for (Permission p : ps)
+                tmpPermissionIndexes.add(policyManager.addTmpPermission(p));
+        }
+        try {
+            return s.get();
+        } finally {
+            for (int index: tmpPermissionIndexes)
+                policyManager.removeTmpPermission(index);
+        }
+    }
+
+    /**
+     * Run the RunnableWithException with assigning temporary permissions. This
+     * won't impact global policy.
+     *
+     * @param r
+     *            RunnableWithException to execute
+     * @param ps
+     *            assigning permissions to add.
+     */
+    public static void tryRunWithTmpPermission(RunnableWithException r, Permission... ps) throws Exception {
+        JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(false);
+        List<Integer> tmpPermissionIndexes = new ArrayList();
+        if (policyManager != null) {
+            for (Permission p : ps)
+                tmpPermissionIndexes.add(policyManager.addTmpPermission(p));
+        }
+        try {
+            r.run();
+        } finally {
+            for (int index: tmpPermissionIndexes)
+                policyManager.removeTmpPermission(index);
+        }
+    }
+
+    @FunctionalInterface
+    public interface RunnableWithException {
+        void run() throws Exception;
+    }
+
+    /**
+     * Current test directory.
+     */
+    public static final String USER_DIR = getSystemProperty("user.dir") + FILE_SEP;;
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/NetAccessPolicy.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jaxp.library;
+
+import java.net.SocketPermission;
+
+import org.testng.ITestContext;
+
+/**
+ * This policy can access network.
+ */
+public class NetAccessPolicy extends BasePolicy {
+
+    @Override
+    public void onStart(ITestContext arg0) {
+        // suppose to only run othervm mode
+        if (isRunWithSecurityManager()) {
+            JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(true);
+            policyManager.addPermission(new SocketPermission("openjdk.java.net:80", "connect,resolve"));
+            policyManager.addPermission(new SocketPermission("www.w3.org:80", "connect,resolve"));
+        }
+    }
+}
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/TestPolicy.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jaxp.library;
-
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.Policy;
-import java.security.ProtectionDomain;
-import java.security.SecurityPermission;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.PropertyPermission;
-import java.util.StringJoiner;
-
-
-/*
- * Simple Policy class that supports the required Permissions to validate the
- * JAXP concrete classes.
- * Note: permission can only be added. You may want to create a new TestPolicy
- *       instance if you need remove permissions.
- */
-public class TestPolicy extends Policy {
-    protected final PermissionCollection permissions = new Permissions();
-
-    private static Policy defaultPolicy = Policy.getPolicy();
-
-    /**
-     * Constructor which sets the minimum permissions by default allowing testNG
-     * to work with a SecurityManager.
-     */
-    public TestPolicy() {
-        setMinimalPermissions();
-    }
-
-    /**
-     * Construct an instance with the minimal permissions required by the test
-     * environment and additional permission(s) as specified.
-     * @param ps permissions to be added.
-     */
-    public TestPolicy(Permissions ps) {
-        setMinimalPermissions();
-        TestPolicy.this.addPermissions(ps);
-    }
-
-    /**
-     * Construct an instance with the minimal permissions required by the test
-     * environment and additional permission(s) as specified.
-     * @param ps permission array to be added.
-     */
-    public TestPolicy(Permission... ps) {
-        setMinimalPermissions();
-        addPermissions(ps);
-    }
-
-    /**
-     * Defines the minimal permissions required by testNG when running these
-     * tests
-     */
-    protected void setMinimalPermissions() {
-        permissions.add(new SecurityPermission("getPolicy"));
-        permissions.add(new SecurityPermission("setPolicy"));
-        permissions.add(new RuntimePermission("getClassLoader"));
-        permissions.add(new RuntimePermission("setSecurityManager"));
-        permissions.add(new RuntimePermission("createSecurityManager"));
-        permissions.add(new PropertyPermission("testng.show.stack.frames",
-                "read"));
-        permissions.add(new PropertyPermission("user.dir", "read"));
-        permissions.add(new PropertyPermission("test.src", "read"));
-        permissions.add(new PropertyPermission("fileStringBuffer", "read"));
-        permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
-    }
-
-    /*
-     * Add permissions for your tests.
-     * @param permissions to be added.
-     */
-    private void addPermissions(Permissions ps) {
-        Collections.list(ps.elements()).forEach(p -> permissions.add(p));
-    }
-
-
-    /*
-     * Add permissions for your tests.
-     * @param permissions to be added.
-     */
-    private void addPermissions(Permission[] ps) {
-        Arrays.stream(ps).forEach(p -> permissions.add(p));
-    }
-
-    /**
-     * Set all permissions. Caution: this should not called carefully unless
-     * it's really needed.
-     */
-    private void setAllPermissions() {
-        permissions.add(new AllPermission());
-    }
-
-    /*
-     * Overloaded methods from the Policy class.
-     */
-    @Override
-    public String toString() {
-        StringJoiner sj = new StringJoiner("\n", "policy: ", "");
-        Enumeration<Permission> perms = permissions.elements();
-        while (perms.hasMoreElements()) {
-            sj.add(perms.nextElement().toString());
-        }
-        return sj.toString();
-
-    }
-
-    @Override
-    public PermissionCollection getPermissions(ProtectionDomain domain) {
-        return permissions;
-    }
-
-    @Override
-    public PermissionCollection getPermissions(CodeSource codesource) {
-        return permissions;
-    }
-
-    @Override
-    public boolean implies(ProtectionDomain domain, Permission perm) {
-        if (defaultPolicy.implies(domain, perm))
-            return true;
-
-        return permissions.implies(perm);
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/test/astro/DOML3InputSourceFactoryImpl.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/libs/test/astro/DOML3InputSourceFactoryImpl.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,6 +23,7 @@
 package test.astro;
 
 import static jaxp.library.JAXPTestUtilities.filenameToURL;
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
 import static org.w3c.dom.ls.DOMImplementationLS.MODE_SYNCHRONOUS;
 import static org.w3c.dom.traversal.NodeFilter.SHOW_ELEMENT;
 
@@ -81,7 +82,7 @@
 
         // Use DOM L3 LSSerializer (previously called a DOMWriter)
         // to serialize the xml doc DOM to a file stream.
-        String tmpCatalog = Files.createTempFile(Paths.get("").toAbsolutePath(), "catalog.xml", null).toString();
+        String tmpCatalog = Files.createTempFile(Paths.get(USER_DIR), "catalog.xml", null).toString();
 
         LSSerializer domserializer = impl.createLSSerializer();
         domserializer.setFilter(new MyDOMWriterFilter());
--- a/jaxp/test/javax/xml/jaxp/module/TEST.properties	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-# Tests that must run in othervm mode
-othervm.dirs= .
-
-# Declare module dependency
-modules=java.xml
--- a/jaxp/test/javax/xml/jaxp/unittest/TEST.properties	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/TEST.properties	Mon Aug 08 12:50:00 2016 +0800
@@ -1,9 +1,8 @@
-# jaxp test uses TestNG
-TestNG.dirs = .
-
-lib.dirs = /javax/xml/jaxp/libs
-
 # Declare module dependency
 modules=java.xml/com.sun.org.apache.xerces.internal.impl \
         java.xml/com.sun.org.apache.xerces.internal.jaxp \
-        java.xml/com.sun.org.apache.xml.internal.serialize
+        java.xml/com.sun.org.apache.xml.internal.serialize \
+        java.xml/com.sun.org.apache.bcel.internal.classfile \
+        java.xml/com.sun.org.apache.bcel.internal.generic \
+        java.xml/com.sun.org.apache.xalan.internal.xsltc.trax \
+        java.xml/com.sun.org.apache.xml.internal.utils
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java	Mon Aug 08 12:50:00 2016 +0800
@@ -25,20 +25,27 @@
 
 import java.io.File;
 import java.io.StringReader;
+
 import javax.xml.transform.Source;
 import javax.xml.transform.URIResolver;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
+
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.InputSource;
 
 /**
+ * @test
  * @bug 8158084 8162438 8162442
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport
+ * @run testng/othervm catalog.CatalogSupport
  * @summary verifies the use of Catalog in SAX/DOM/StAX/Validation/Transform.
  * The two main scenarios for all processors are:
  * A custom resolver is used whether or not there's a Catalog;
@@ -60,6 +67,7 @@
  *
  * @author huizhe.wang@oracle.com
  */
+@Listeners({jaxp.library.FilePolicy.class, jaxp.library.NetAccessPolicy.class})
 public class CatalogSupport extends CatalogSupportBase {
     /*
      * Initializing fields
@@ -159,7 +167,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_SAXA")
-    Object[][] getDataSAX() {
+    public Object[][] getDataSAX() {
         String[] systemIds = {"system.xsd"};
         InputSource[] returnValues = {new InputSource(new StringReader(dtd_systemResolved))};
         MyEntityHandler entityHandler = new MyEntityHandler(systemIds, returnValues, elementInSystem);
@@ -175,7 +183,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_XIA")
-    Object[][] getDataXI() {
+    public Object[][] getDataXI() {
         String[] systemIds = {"XI_simple.xml"};
         InputSource[] returnValues = {new InputSource(xml_xIncludeSimple)};
         MyEntityHandler entityHandler = new MyEntityHandler(systemIds, returnValues, elementInXISimple);
@@ -191,7 +199,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_DOMA")
-    Object[][] getDataDOM() {
+    public Object[][] getDataDOM() {
         String[] systemIds = {"system.xsd"};
         InputSource[] returnValues = {new InputSource(new StringReader(dtd_systemResolved))};
         MyEntityHandler entityHandler = new MyEntityHandler(systemIds, returnValues, elementInSystem);
@@ -213,7 +221,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver
      */
     @DataProvider(name = "data_SchemaA")
-    Object[][] getDataSchema() {
+    public Object[][] getDataSchema() {
         String[] systemIds = {"pathto/XMLSchema.dtd", "datatypes.dtd"};
         XmlInput[] returnValues = {new XmlInput(null, dtd_xmlSchema, null), new XmlInput(null, dtd_datatypes, null)};
         LSResourceResolver resolver = new SourceResolver(null, systemIds, returnValues);
@@ -248,7 +256,7 @@
        Data: source, resolver1, resolver2, catalog1, a catalog2
      */
     @DataProvider(name = "data_ValidatorA")
-    Object[][] getDataValidator() {
+    public Object[][] getDataValidator() {
         DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);
 
         SAXSource ss = new SAXSource(new InputSource(xml_val_test));
@@ -289,7 +297,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsl file, xml file, a URIResolver, expected result
      */
     @DataProvider(name = "data_XSLA")
-    Object[][] getDataXSL() {
+    public Object[][] getDataXSL() {
         // XSLInclude.xsl has one import XSLImport_html.xsl and two includes,
         // XSLInclude_header.xsl and XSLInclude_footer.xsl;
         String[] hrefs = {"XSLImport_html.xsl", "XSLInclude_header.xsl", "XSLInclude_footer.xsl"};
@@ -319,3 +327,4 @@
         };
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,8 +23,12 @@
 
 package catalog;
 
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import java.io.File;
 import java.io.StringReader;
+
 import javax.xml.catalog.CatalogFeatures.Feature;
 import javax.xml.transform.Source;
 import javax.xml.transform.URIResolver;
@@ -32,15 +36,21 @@
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
+
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 8158084 8162438 8162442
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport1
+ * @run testng/othervm catalog.CatalogSupport1
  * @summary extends CatalogSupport, verifies that the catalog file can be set
  * using the System property.
  */
@@ -51,6 +61,7 @@
  *
  * @author huizhe.wang@oracle.com
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CatalogSupport1 extends CatalogSupportBase {
     /*
      * Initializing fields
@@ -58,12 +69,12 @@
     @BeforeClass
     public void setUpClass() throws Exception {
         setUp();
-        System.setProperty(Feature.FILES.getPropertyName(), xml_catalog);
+        setSystemProperty(Feature.FILES.getPropertyName(), xml_catalog);
     }
 
     @AfterClass
     public void tearDownClass() throws Exception {
-        System.clearProperty(Feature.FILES.getPropertyName());
+        clearSystemProperty(Feature.FILES.getPropertyName());
     }
 
     /*
@@ -149,7 +160,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_SAXC")
-    Object[][] getDataSAXC() {
+    public Object[][] getDataSAXC() {
         return new Object[][]{
             {false, true, null, xml_system, new MyHandler(elementInSystem), expectedWCatalog}
 
@@ -161,7 +172,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_XIC")
-    Object[][] getDataXIC() {
+    public Object[][] getDataXIC() {
         return new Object[][]{
             {false, true, null, xml_xInclude, new MyHandler(elementInXISimple), contentInUIutf8Catalog},
         };
@@ -172,7 +183,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_DOMC")
-    Object[][] getDataDOMC() {
+    public Object[][] getDataDOMC() {
         return new Object[][]{
             {false, true, null, xml_system, new MyHandler(elementInSystem), expectedWCatalog}
         };
@@ -183,7 +194,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver
      */
     @DataProvider(name = "data_SchemaC")
-    Object[][] getDataSchemaC() {
+    public Object[][] getDataSchemaC() {
 
         return new Object[][]{
             // for resolving DTD in xsd
@@ -201,7 +212,7 @@
        Data: source, resolver1, resolver2, catalog1, a catalog2
      */
     @DataProvider(name = "data_ValidatorC")
-    Object[][] getDataValidator() {
+    public Object[][] getDataValidator() {
         DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, false, true, null);
 
         SAXSource ss = new SAXSource(new InputSource(xml_val_test));
@@ -242,7 +253,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsl file, xml file, a URIResolver, expected
      */
     @DataProvider(name = "data_XSLC")
-    Object[][] getDataXSLC() {
+    public Object[][] getDataXSLC() {
         SAXSource xslSourceDTD = new SAXSource(new InputSource(new StringReader(xsl_includeDTD)));
         StreamSource xmlSourceDTD = new StreamSource(new StringReader(xml_xslDTD));
 
@@ -257,3 +268,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,10 +23,15 @@
 
 package catalog;
 
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.StringReader;
 import java.net.SocketTimeoutException;
+
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.URIResolver;
@@ -34,9 +39,11 @@
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
+
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.InputSource;
@@ -44,7 +51,11 @@
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 8158084 8162438 8162442
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport2
+ * @run testng/othervm catalog.CatalogSupport2
  * @summary extends CatalogSupport tests, verifies that the use of the Catalog may
  * be disabled through the System property.
  */
@@ -56,11 +67,12 @@
  *
  * @author huizhe.wang@oracle.com
  */
+@Listeners({jaxp.library.FilePolicy.class, jaxp.library.NetAccessPolicy.class})
 public class CatalogSupport2 extends CatalogSupportBase {
     static final String TTIMEOUTREAD = "sun.net.client.defaultReadTimeout";
     static final String TIMEOUTCONNECT = "sun.net.client.defaultConnectTimeout";
-    static String timeoutRead = System.getProperty(TTIMEOUTREAD);
-    static String timeoutConnect = System.getProperty(TIMEOUTCONNECT);
+    static String timeoutRead = getSystemProperty(TTIMEOUTREAD);
+    static String timeoutConnect = getSystemProperty(TIMEOUTCONNECT);
 
     /*
      * Initializing fields
@@ -68,18 +80,18 @@
     @BeforeClass
     public void setUpClass() throws Exception {
         setUp();
-        System.setProperty(SP_USE_CATALOG, "false");
-        timeoutRead = System.getProperty(TTIMEOUTREAD);
-        timeoutConnect = System.getProperty(TIMEOUTCONNECT);
-        System.setProperty(TTIMEOUTREAD, "1000");
-        System.setProperty(TIMEOUTCONNECT, "1000");
+        setSystemProperty(SP_USE_CATALOG, "false");
+        timeoutRead = getSystemProperty(TTIMEOUTREAD);
+        timeoutConnect = getSystemProperty(TIMEOUTCONNECT);
+        setSystemProperty(TTIMEOUTREAD, "1000");
+        setSystemProperty(TIMEOUTCONNECT, "1000");
     }
 
     @AfterClass
     public void tearDownClass() throws Exception {
-        System.clearProperty(SP_USE_CATALOG);
-        System.setProperty(TIMEOUTCONNECT, "-1");
-        System.setProperty(TTIMEOUTREAD, "-1");
+        clearSystemProperty(SP_USE_CATALOG);
+        setSystemProperty(TIMEOUTCONNECT, "-1");
+        setSystemProperty(TTIMEOUTREAD, "-1");
     }
 
     /*
@@ -165,7 +177,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_SAXC")
-    Object[][] getDataSAXC() {
+    public Object[][] getDataSAXC() {
         return new Object[][]{
             {false, true, xml_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog}
 
@@ -177,7 +189,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_XIC")
-    Object[][] getDataXIC() {
+    public Object[][] getDataXIC() {
         return new Object[][]{
             {false, true, xml_catalog, xml_xInclude, new MyHandler(elementInXISimple), contentInUIutf8Catalog},
         };
@@ -188,7 +200,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_DOMC")
-    Object[][] getDataDOMC() {
+    public Object[][] getDataDOMC() {
         return new Object[][]{
             {false, true, xml_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog}
         };
@@ -199,7 +211,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver
      */
     @DataProvider(name = "data_SchemaC")
-    Object[][] getDataSchemaC() {
+    public Object[][] getDataSchemaC() {
 
         return new Object[][]{
             // for resolving DTD in xsd
@@ -217,7 +229,7 @@
        Data: source, resolver1, resolver2, catalog1, a catalog2
      */
     @DataProvider(name = "data_ValidatorC")
-    Object[][] getDataValidator() {
+    public Object[][] getDataValidator() {
         DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, true, true, xml_catalog);
 
         SAXSource ss = new SAXSource(new InputSource(xml_val_test));
@@ -246,7 +258,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsl file, xml file, a URIResolver, expected
      */
     @DataProvider(name = "data_XSLC")
-    Object[][] getDataXSLC() {
+    public Object[][] getDataXSLC() {
         SAXSource xslSourceDTD = new SAXSource(new InputSource(new StringReader(xsl_includeDTD)));
         StreamSource xmlSourceDTD = new StreamSource(new StringReader(xml_xslDTD));
 
@@ -260,3 +272,4 @@
         };
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,10 +23,14 @@
 
 package catalog;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.StringReader;
 import java.net.SocketTimeoutException;
+
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.URIResolver;
@@ -34,9 +38,11 @@
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
+
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.InputSource;
@@ -44,7 +50,11 @@
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 8158084 8162438 8162442
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport3
+ * @run testng/othervm catalog.CatalogSupport3
  * @summary extends CatalogSupport tests, verifies that the use of the Catalog may
  * be disabled through the API property.
  */
@@ -56,27 +66,28 @@
  *
  * @author huizhe.wang@oracle.com
  */
+@Listeners({jaxp.library.FilePolicy.class, jaxp.library.NetAccessPolicy.class})
 public class CatalogSupport3 extends CatalogSupportBase {
     static final String TTIMEOUTREAD = "sun.net.client.defaultReadTimeout";
     static final String TIMEOUTCONNECT = "sun.net.client.defaultConnectTimeout";
-    static String timeoutRead = System.getProperty(TTIMEOUTREAD);
-    static String timeoutConnect = System.getProperty(TIMEOUTCONNECT);
+    static String timeoutRead = getSystemProperty(TTIMEOUTREAD);
+    static String timeoutConnect = getSystemProperty(TIMEOUTCONNECT);
     /*
      * Initializing fields
      */
     @BeforeClass
     public void setUpClass() throws Exception {
         setUp();
-        timeoutRead = System.getProperty(TTIMEOUTREAD);
-        timeoutConnect = System.getProperty(TIMEOUTCONNECT);
-        System.setProperty(TTIMEOUTREAD, "1000");
-        System.setProperty(TIMEOUTCONNECT, "1000");
+        timeoutRead = getSystemProperty(TTIMEOUTREAD);
+        timeoutConnect = getSystemProperty(TIMEOUTCONNECT);
+        setSystemProperty(TTIMEOUTREAD, "1000");
+        setSystemProperty(TIMEOUTCONNECT, "1000");
     }
 
     @AfterClass
     public void tearDownClass() throws Exception {
-        System.setProperty(TIMEOUTCONNECT, "-1");
-        System.setProperty(TTIMEOUTREAD, "-1");
+        setSystemProperty(TIMEOUTCONNECT, "-1");
+        setSystemProperty(TTIMEOUTREAD, "-1");
     }
 
     /*
@@ -167,7 +178,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_SAXC")
-    Object[][] getDataSAXC() {
+    public Object[][] getDataSAXC() {
         return new Object[][]{
             {true, false, xml_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog}
 
@@ -179,7 +190,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_XIC")
-    Object[][] getDataXIC() {
+    public Object[][] getDataXIC() {
         return new Object[][]{
             {true, false, xml_catalog, xml_xInclude, new MyHandler(elementInXISimple), contentInUIutf8Catalog},
         };
@@ -190,7 +201,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_DOMC")
-    Object[][] getDataDOMC() {
+    public Object[][] getDataDOMC() {
         return new Object[][]{
             {true, false, xml_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog}
         };
@@ -201,7 +212,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver
      */
     @DataProvider(name = "data_SchemaC")
-    Object[][] getDataSchemaC() {
+    public Object[][] getDataSchemaC() {
 
         return new Object[][]{
             // for resolving DTD in xsd
@@ -219,7 +230,7 @@
        Data: source, resolver1, resolver2, catalog1, a catalog2
      */
     @DataProvider(name = "data_ValidatorC")
-    Object[][] getDataValidator() {
+    public Object[][] getDataValidator() {
         DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);
 
         SAXSource ss = new SAXSource(new InputSource(xml_val_test));
@@ -257,7 +268,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsl file, xml file, a URIResolver, expected
      */
     @DataProvider(name = "data_XSLC")
-    Object[][] getDataXSLC() {
+    public Object[][] getDataXSLC() {
         SAXSource xslSourceDTD = new SAXSource(new InputSource(new StringReader(xsl_includeDTD)));
         StreamSource xmlSourceDTD = new StreamSource(new StringReader(xml_xslDTD));
 
@@ -271,3 +282,4 @@
         };
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,23 +23,33 @@
 
 package catalog;
 
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import java.io.File;
 import java.io.StringReader;
+
 import javax.xml.transform.Source;
 import javax.xml.transform.URIResolver;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
+
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.InputSource;
 
 /**
+ * @test
  * @bug 8158084 8162438 8162442
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport4
+ * @run testng/othervm catalog.CatalogSupport4
  * @summary verifies the overriding over of the USE_CATALOG feature. Extending
  * CatalogSupport tests, the USE_CATALOG is turned off system-wide, however,
  * a JAXP processor may decide to use Catalog by enabling it through the factory
@@ -54,6 +64,7 @@
  *
  * @author huizhe.wang@oracle.com
  */
+@Listeners({jaxp.library.FilePolicy.class, jaxp.library.NetAccessPolicy.class})
 public class CatalogSupport4 extends CatalogSupportBase {
     /*
      * Initializing fields
@@ -62,12 +73,12 @@
     public void setUpClass() throws Exception {
         setUp();
         //turn off USE_CATALOG system-wide
-        System.setProperty(SP_USE_CATALOG, "false");
+        setSystemProperty(SP_USE_CATALOG, "false");
     }
 
     @AfterClass
     public void tearDownClass() throws Exception {
-        System.clearProperty(SP_USE_CATALOG);
+        clearSystemProperty(SP_USE_CATALOG);
     }
 
     /*
@@ -160,7 +171,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_SAXA")
-    Object[][] getDataSAX() {
+    public Object[][] getDataSAX() {
         return new Object[][]{
             {true, true, xml_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog},
         };
@@ -171,7 +182,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_XIA")
-    Object[][] getDataXI() {
+    public Object[][] getDataXI() {
         return new Object[][]{
             {true, true, xml_catalog, xml_xInclude, new MyHandler(elementInXISimple), contentInUIutf8Catalog},
         };
@@ -182,7 +193,7 @@
        Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string
      */
     @DataProvider(name = "data_DOMA")
-    Object[][] getDataDOM() {
+    public Object[][] getDataDOM() {
         return new Object[][]{
             {true, true, xml_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog},
         };
@@ -197,7 +208,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver
      */
     @DataProvider(name = "data_SchemaA")
-    Object[][] getDataSchema() {
+    public Object[][] getDataSchema() {
         return new Object[][]{
             // for resolving DTD in xsd
             {true, true, xml_catalog, xsd_xmlSchema, null},
@@ -213,7 +224,7 @@
        Data: source, resolver1, resolver2, catalog1, a catalog2
      */
     @DataProvider(name = "data_ValidatorA")
-    Object[][] getDataValidator() {
+    public Object[][] getDataValidator() {
         DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, true, true, xml_catalog);
 
         SAXSource ss = new SAXSource(new InputSource(xml_val_test));
@@ -242,7 +253,7 @@
        Data: set use_catalog, use_catalog, catalog file, xsl file, xml file, a URIResolver, expected result
      */
     @DataProvider(name = "data_XSLA")
-    Object[][] getDataXSL() {
+    public Object[][] getDataXSL() {
         // XSLInclude.xsl has one import XSLImport_html.xsl and two includes,
         // XSLInclude_header.xsl and XSLInclude_footer.xsl;
         SAXSource xslSourceDTD = new SAXSource(new InputSource(new StringReader(xsl_includeDTD)));
@@ -258,3 +269,4 @@
         };
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,6 +23,8 @@
 
 package catalog;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -33,6 +35,7 @@
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
+
 import javax.xml.XMLConstants;
 import javax.xml.catalog.CatalogFeatures;
 import javax.xml.parsers.DocumentBuilder;
@@ -58,8 +61,8 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
+
 import org.testng.Assert;
-import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.ls.LSInput;
@@ -89,7 +92,7 @@
 
     protected void setUp() {
         String file1 = getClass().getResource("CatalogSupport.xml").getFile();
-        if (System.getProperty("os.name").contains("Windows")) {
+        if (getSystemProperty("os.name").contains("Windows")) {
             filepath = file1.substring(1, file1.lastIndexOf("/") + 1);
             slash = "/";
         } else {
@@ -932,3 +935,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -22,8 +22,15 @@
  */
 package catalog;
 
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
+import java.io.FilePermission;
 import java.io.IOException;
 import java.nio.file.Paths;
+import java.util.PropertyPermission;
+
 import javax.xml.catalog.Catalog;
 import javax.xml.catalog.CatalogException;
 import javax.xml.catalog.CatalogFeatures;
@@ -35,9 +42,13 @@
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.Source;
+
+import jaxp.library.JAXPTestUtilities;
+
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.ErrorHandler;
@@ -47,9 +58,14 @@
 import org.xml.sax.ext.DefaultHandler2;
 
 /*
- * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969, 8151162, 8152527, 8154220
+ * @test
+ * @bug 8081248 8144966 8146606 8146237 8151154 8150969 8151162 8152527 8154220
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true catalog.CatalogTest
+ * @run testng/othervm catalog.CatalogTest
  * @summary Tests basic Catalog functions.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CatalogTest {
     static final String KEY_FILES = "javax.xml.catalog.files";
 
@@ -61,7 +77,7 @@
     @BeforeClass
     public void setUpClass() throws Exception {
         String file1 = getClass().getResource("first_cat.xml").getFile();
-        if (System.getProperty("os.name").contains("Windows")) {
+        if (getSystemProperty("os.name").contains("Windows")) {
             filepath = file1.substring(1, file1.lastIndexOf("/") + 1);
         } else {
             filepath = file1.substring(0, file1.lastIndexOf("/") + 1);
@@ -112,12 +128,12 @@
         String files = file1 + ";" + file2;
 
         try {
-            System.setProperty(KEY_FILES, files);
+            setSystemProperty(KEY_FILES, files);
             CatalogResolver catalogResolver = CatalogManager.catalogResolver(CatalogFeatures.defaults());
             String sysId = catalogResolver.resolveEntity(null, systemId).getSystemId();
             Assert.assertEquals(sysId, Paths.get(filepath + expectedUri).toUri().toString().replace("///", "/"), "System ID match not right");
         } finally {
-            System.clearProperty(KEY_FILES);
+            clearSystemProperty(KEY_FILES);
         }
 
     }
@@ -203,9 +219,12 @@
      */
     @Test(dataProvider = "invalidPaths", expectedExceptions = IllegalArgumentException.class)
     public void testFileInput(String file) {
+        JAXPTestUtilities.runWithTmpPermission(() -> {
             CatalogFeatures features = CatalogFeatures.builder()
                 .with(CatalogFeatures.Feature.FILES, file)
                 .build();
+        }, new FilePermission("/../../..", "read"), new FilePermission("c:\\te:t", "read"),
+                new FilePermission("c:\\te?t", "read"), new PropertyPermission("user.dir", "read"));
     }
 
     /**
@@ -371,7 +390,7 @@
         This DataProvider is copied from JCK ResolveTests' dataMatch1
      */
     @DataProvider(name = "resolveUri")
-    Object[][] getDataForUriResolver() {
+    public Object[][] getDataForUriResolver() {
         return new Object[][]{
             {"uri.xml", "urn:publicid:-:Acme,+Inc.:DTD+Book+Version+1.0", null, "http://local/base/dtd/book.dtd", "Uri in publicId namespace is incorrectly unwrapped"},
         };
@@ -382,7 +401,7 @@
     hierarchyOfCatFiles2.
      */
     @DataProvider(name = "hierarchyOfCatFilesData")
-    Object[][] getHierarchyOfCatFilesData() {
+    public Object[][] getHierarchyOfCatFilesData() {
         return new Object[][]{
             {"http://www.oracle.com/sequence.dtd", "first.dtd"},
             {"http://www.oracle.com/sequence_next.dtd", "next.dtd"},
@@ -396,7 +415,7 @@
         catalog, prefer, systemId, publicId, expectedUri, expectedFile, msg
      */
     @DataProvider(name = "resolveEntity")
-    Object[][] getDataForMatchingBothIds() {
+    public Object[][] getDataForMatchingBothIds() {
         String expected = "http://www.groupxmlbase.com/dtds/rewrite.dtd";
         return new Object[][]{
             {"rewriteSystem_id.xml", "system", "http://www.sys00test.com/rewrite.dtd", "PUB-404", expected, expected, "Relative rewriteSystem with xml:base at group level failed"},
@@ -411,7 +430,7 @@
         prefer, catalog, publicId, systemId, expected result
      */
     @DataProvider(name = "matchWithPrefer")
-    Object[][] getDataForMatch() {
+    public Object[][] getDataForMatch() {
         return new Object[][]{
             {"public", "pubOnly.xml", id, "", "http://local/base/dtd/public.dtd"},
             {"public", "sysOnly.xml", id, "", null},
@@ -435,7 +454,7 @@
         prefer, catalog, publicId, systemId, expected result
      */
     @DataProvider(name = "resolveWithPrefer")
-    Object[][] getDataForResolve() {
+    public Object[][] getDataForResolve() {
         return new Object[][]{
             {"system", "pubOnly.xml", id, "", "http://local/base/dtd/public.dtd"},
             {"system", "pubOnly.xml", "", id, null},
@@ -462,7 +481,7 @@
                      The defer attribute is set to false.
      */
     @DataProvider(name = "invalidAltCatalogs")
-    Object[][] getCatalogs() {
+    public Object[][] getCatalogs() {
         return new Object[][]{
             {"defer_false_2.xml"},
             {"defer_del_false.xml"}
@@ -474,7 +493,7 @@
                      the CatalogFeatures builder
      */
     @DataProvider(name = "invalidPaths")
-    Object[][] getFiles() {
+    public Object[][] getFiles() {
         return new Object[][]{
             {null},
             {""},
@@ -493,7 +512,7 @@
        document.
      */
     @DataProvider(name = "catalog")
-    Object[][] getCatalog() {
+    public Object[][] getCatalog() {
         return new Object[][]{
             {"testSystem", "Test system entry", "catalog.xml", "system.xml", getParser()},
             {"testRewriteSystem", "Test rewritesystem entry", "catalog.xml", "rewritesystem.xml", getParser()},
@@ -517,7 +536,6 @@
         return saxParser;
     }
 
-
     /**
      * SAX handler
      */
@@ -536,7 +554,8 @@
         }
 
         @Override
-        public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+        public void startElement(String uri, String localName, String qName, Attributes attributes)
+                throws SAXException {
             textContent.delete(0, textContent.length());
             try {
                 System.out.println("Element: " + uri + ":" + localName + " " + qName);
@@ -552,3 +571,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6350682.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6350682.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,23 +23,31 @@
 
 package common;
 
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.TransformerFactoryConfigurationError;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6350682
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true common.Bug6350682
+ * @run testng/othervm common.Bug6350682
  * @summary Test SAXParserFactory and TransformerFactory can newInstance when setContextClassLoader(null).
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6350682 {
 
     @Test
     public void testSAXParserFactory() {
         try {
-            Thread.currentThread().setContextClassLoader(null);
+            runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
             if (Bug6350682.class.getClassLoader() == null)
                 System.out.println("this class loader is NULL");
             else
@@ -55,7 +63,7 @@
     @Test
     public void testTransformerFactory() {
         try {
-            Thread.currentThread().setContextClassLoader(null);
+            runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
             TransformerFactory factory = TransformerFactory.newInstance();
             Assert.assertTrue(factory != null, "Failed to get an instance of a TransformerFactory");
         } catch (Exception e) {
@@ -67,3 +75,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6723276Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6723276Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 package common;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 import java.net.URL;
@@ -31,9 +32,14 @@
 import javax.xml.parsers.SAXParserFactory;
 
 /*
+ * @test
  * @bug 6723276
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true common.Bug6723276Test
+ * @run testng/othervm common.Bug6723276Test
  * @summary Test JAXP class can be loaded by bootstrap classloader.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6723276Test {
 
     @Test
@@ -62,3 +68,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6941169Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6941169Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,13 @@
 
 package common;
 
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
+import java.io.FilePermission;
 import java.io.InputStream;
 import java.io.StringWriter;
-import java.security.AllPermission;
-import java.security.Permission;
-import java.security.Permissions;
 
 import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
@@ -44,15 +46,24 @@
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathFactory;
 
+import jaxp.library.JAXPTestUtilities;
+
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 6941169
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true common.Bug6941169Test
+ * @run testng/othervm common.Bug6941169Test
  * @summary Test use-service-mechanism feature.
  */
+@Test(singleThreaded = true)
+@Listeners({ jaxp.library.FilePolicy.class })
 public class Bug6941169Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -71,7 +82,7 @@
         System.out.println("Validation using SAX Source;  Service mechnism is turned off;  SAX Impl should be the default:");
         InputSource is = new InputSource(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"));
         SAXSource ss = new SAXSource(is);
-        System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
+        setSystemProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
         long start = System.currentTimeMillis();
         try {
             SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -94,7 +105,7 @@
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.clearProperty(SAX_FACTORY_ID);
+        clearSystemProperty(SAX_FACTORY_ID);
     }
 
     @Test
@@ -102,7 +113,7 @@
         System.out.println("Validation using SAX Source. Using service mechnism (by default) to find SAX Impl:");
         InputSource is = new InputSource(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"));
         SAXSource ss = new SAXSource(is);
-        System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
+        setSystemProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
         long start = System.currentTimeMillis();
         try {
             SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -121,18 +132,18 @@
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.clearProperty(SAX_FACTORY_ID);
+        clearSystemProperty(SAX_FACTORY_ID);
     }
 
     @Test
-    public void testValidation_SAX_withSM() {
+    public void testValidation_SAX_withSM() throws Exception {
+        if(System.getSecurityManager() == null)
+            return;
+
         System.out.println("Validation using SAX Source with security manager:");
         InputSource is = new InputSource(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"));
         SAXSource ss = new SAXSource(is);
-        System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
-        Permissions granted = new java.security.Permissions();
-        granted.add(new AllPermission());
-        System.setSecurityManager(new MySM(granted));
+        setSystemProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
 
         long start = System.currentTimeMillis();
         try {
@@ -152,13 +163,11 @@
             // System.out.println(e.getMessage());
 
         } finally {
-            System.clearProperty(SAX_FACTORY_ID);
-            System.setSecurityManager(null);
+            clearSystemProperty(SAX_FACTORY_ID);
         }
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.setSecurityManager(null);
 
     }
 
@@ -170,7 +179,7 @@
 
         // DOMSource domSource = new
         // DOMSource(getDocument(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml")));
-        System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
+        setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
         long start = System.currentTimeMillis();
         try {
             TransformerFactory factory = TransformerFactory.newInstance();
@@ -210,7 +219,7 @@
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.clearProperty(DOM_FACTORY_ID);
+        clearSystemProperty(DOM_FACTORY_ID);
     }
 
     /** this is by default */
@@ -222,7 +231,7 @@
 
         // DOMSource domSource = new
         // DOMSource(getDocument(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml")));
-        System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
+        setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
         long start = System.currentTimeMillis();
         try {
             TransformerFactory factory = TransformerFactory.newInstance();
@@ -254,21 +263,20 @@
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.clearProperty(DOM_FACTORY_ID);
+        clearSystemProperty(DOM_FACTORY_ID);
     }
 
     @Test
-    public void testTransform_DOM_withSM() {
+    public void testTransform_DOM_withSM() throws Exception {
+        if(System.getSecurityManager() == null)
+            return;
         System.out.println("Transform using DOM Source;  Security Manager is set:");
         DOMSource domSource = new DOMSource();
         domSource.setSystemId(_xml);
 
         // DOMSource domSource = new
         // DOMSource(getDocument(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml")));
-        Permissions granted = new java.security.Permissions();
-        granted.add(new AllPermission());
-        System.setSecurityManager(new MySM(granted));
-        System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
+        setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
         long start = System.currentTimeMillis();
         try {
             TransformerFactory factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
@@ -301,13 +309,12 @@
             // System.out.println(e.getMessage());
 
         } finally {
-            System.clearProperty(DOM_FACTORY_ID);
-            System.setSecurityManager(null);
+            clearSystemProperty(DOM_FACTORY_ID);
         }
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.clearProperty(DOM_FACTORY_ID);
+
     }
 
     @Test
@@ -315,7 +322,7 @@
         final String XPATH_EXPRESSION = "/fooTest";
         System.out.println("Evaluate DOM Source;  Service mechnism is turned off;  Default DOM Impl should be used:");
         Document doc = getDocument(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"));
-        System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
+        setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
         long start = System.currentTimeMillis();
         try {
             XPathFactory xPathFactory = XPathFactory.newInstance();
@@ -352,7 +359,7 @@
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.clearProperty(DOM_FACTORY_ID);
+        clearSystemProperty(DOM_FACTORY_ID);
     }
 
     @Test
@@ -361,7 +368,7 @@
         System.out.println("Evaluate DOM Source;  Service mechnism is on by default;  It would try to use MyDOMFactoryImpl:");
         InputStream input = getClass().getResourceAsStream("Bug6941169.xml");
         InputSource source = new InputSource(input);
-        System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
+        setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
         long start = System.currentTimeMillis();
         try {
             XPathFactory xPathFactory = XPathFactory.newInstance();
@@ -400,19 +407,18 @@
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.clearProperty(DOM_FACTORY_ID);
+        clearSystemProperty(DOM_FACTORY_ID);
     }
 
     @Test
-    public void testXPath_DOM_withSM() {
+    public void testXPath_DOM_withSM() throws Exception {
+        if(System.getSecurityManager() == null)
+            return;
         final String XPATH_EXPRESSION = "/fooTest";
         System.out.println("Evaluate DOM Source;  Security Manager is set:");
-        Permissions granted = new java.security.Permissions();
-        granted.add(new AllPermission());
-        System.setSecurityManager(new MySM(granted));
         InputStream input = getClass().getResourceAsStream("Bug6941169.xml");
         InputSource source = new InputSource(input);
-        System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
+        setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
         long start = System.currentTimeMillis();
         try {
             XPathFactory xPathFactory = XPathFactory.newInstance("http://java.sun.com/jaxp/xpath/dom",
@@ -445,13 +451,12 @@
             // System.out.println(e.getMessage());
 
         } finally {
-            System.clearProperty(DOM_FACTORY_ID);
-            System.setSecurityManager(null);
+            clearSystemProperty(DOM_FACTORY_ID);
         }
         long end = System.currentTimeMillis();
         double elapsedTime = ((end - start));
         System.out.println("Time elapsed: " + elapsedTime);
-        System.clearProperty(DOM_FACTORY_ID);
+
     }
 
     @Test
@@ -480,22 +485,5 @@
 
         return document;
     }
-
-    class MySM extends SecurityManager {
-        Permissions granted;
-
-        public MySM(Permissions perms) {
-            granted = perms;
-        }
+}
 
-        @Override
-        public void checkPermission(Permission perm) {
-            if (granted.implies(perm)) {
-                return;
-            }
-            super.checkPermission(perm);
-        }
-
-    }
-
-}
--- a/jaxp/test/javax/xml/jaxp/unittest/common/Bug7143711Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/common/Bug7143711Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,8 @@
 
 package common;
 
-import java.security.AllPermission;
-import java.security.Permission;
-import java.security.Permissions;
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
 
 import javax.xml.XMLConstants;
 import javax.xml.transform.TransformerFactory;
@@ -33,12 +32,18 @@
 import javax.xml.xpath.XPathFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 7143711
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true common.Bug7143711Test
  * @summary Test set use-service-mechanism shall not override what's set by the constructor in secure mode.
  */
+@Listeners({ jaxp.library.BasePolicy.class })
+@Test(singleThreaded = true)
 public class Bug7143711Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -52,10 +57,7 @@
     @Test
     public void testValidation_SAX_withSM() {
         System.out.println("Validation using SAX Source with security manager:");
-        System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
-        Permissions granted = new java.security.Permissions();
-        granted.add(new AllPermission());
-        System.setSecurityManager(new MySM(granted));
+        setSystemProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
 
         try {
             SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -68,22 +70,14 @@
             Assert.fail(e.getMessage());
 
         } finally {
-            System.clearProperty(SAX_FACTORY_ID);
-            System.setSecurityManager(null);
+            clearSystemProperty(SAX_FACTORY_ID);
         }
-
-        System.setSecurityManager(null);
-
     }
 
     @Test(enabled=false) //skipped due to bug JDK-8080097
     public void testTransform_DOM_withSM() {
         System.out.println("Transform using DOM Source;  Security Manager is set:");
-
-        Permissions granted = new java.security.Permissions();
-        granted.add(new AllPermission());
-        System.setSecurityManager(new MySM(granted));
-        System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
+        setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
 
         try {
             TransformerFactory factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
@@ -96,20 +90,14 @@
         } catch (Exception e) {
             Assert.fail(e.getMessage());
         } finally {
-            System.clearProperty(DOM_FACTORY_ID);
-            System.setSecurityManager(null);
+            clearSystemProperty(DOM_FACTORY_ID);
         }
-
-        System.clearProperty(DOM_FACTORY_ID);
     }
 
     @Test
     public void testXPath_DOM_withSM() {
         System.out.println("Evaluate DOM Source;  Security Manager is set:");
-        Permissions granted = new java.security.Permissions();
-        granted.add(new AllPermission());
-        System.setSecurityManager(new MySM(granted));
-        System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
+        setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
 
         try {
             XPathFactory xPathFactory = XPathFactory.newInstance("http://java.sun.com/jaxp/xpath/dom",
@@ -122,38 +110,8 @@
         } catch (Exception e) {
             Assert.fail(e.getMessage());
         } finally {
-            System.clearProperty(DOM_FACTORY_ID);
-            System.setSecurityManager(null);
-        }
-
-        System.clearProperty(DOM_FACTORY_ID);
-    }
-
-    @Test
-    public void testSM() {
-        SecurityManager sm = System.getSecurityManager();
-        if (System.getSecurityManager() != null) {
-            System.out.println("Security manager not cleared: " + sm.toString());
-        } else {
-            System.out.println("Security manager cleared: ");
+            clearSystemProperty(DOM_FACTORY_ID);
         }
     }
-
-    class MySM extends SecurityManager {
-        Permissions granted;
-
-        public MySM(Permissions perms) {
-            granted = perms;
-        }
+}
 
-        @Override
-        public void checkPermission(Permission perm) {
-            if (granted.implies(perm)) {
-                return;
-            }
-            super.checkPermission(perm);
-        }
-
-    }
-
-}
--- a/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java	Mon Aug 08 12:50:00 2016 +0800
@@ -22,11 +22,15 @@
  */
 package common;
 
+import static jaxp.library.JAXPTestUtilities.runWithTmpPermission;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.net.URISyntaxException;
+import java.util.PropertyPermission;
+
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParserFactory;
@@ -39,8 +43,10 @@
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
+
 import org.testng.Assert;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -48,10 +54,15 @@
 import org.xml.sax.XMLReader;
 
 /*
+ * @test
  * @bug 8144967
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true common.Sources
+ * @run testng/othervm common.Sources
  * @summary Tests related to the javax.xml.transform.Source
  * and org.xml.sax.InputSource
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Sources {
 
     /**
@@ -88,7 +99,7 @@
      * DataProvider: sources that are empty
      */
     @DataProvider(name = "emptySources")
-    Object[][] getSources() throws URISyntaxException {
+    public Object[][] getSources() throws URISyntaxException {
 
         return new Object[][]{
             {new DOMSource()},
@@ -108,27 +119,29 @@
      * DataProvider: sources that are not empty
      */
     @DataProvider(name = "nonEmptySources")
-    Object[][] getSourcesEx() throws URISyntaxException {
+    public Object[][] getSourcesEx() {
         StAXSource ss = null;
         try {
             ss = new StAXSource(getXMLEventReader());
-        } catch (XMLStreamException ex) {}
+        } catch (XMLStreamException ex) {
+        }
 
-        return new Object[][]{
-            //This will set a non-null systemId on the resulting StreamSource
-            {new StreamSource(new File(""))},
-            //Can't tell because XMLStreamReader is a pull parser, cursor advancement
-            //would have been required in order to examine the reader.
-            {new StAXSource(getXMLStreamReader())},
-            {ss}
-        };
+        return new Object[][] {
+            // This will set a non-null systemId on the resulting
+            // StreamSource
+            { runWithTmpPermission(() -> new StreamSource(new File("")), new PropertyPermission("user.dir", "read")) },
+            // Can't tell because XMLStreamReader is a pull parser, cursor
+            // advancement
+            // would have been required in order to examine the reader.
+            { new StAXSource(getXMLStreamReader()) },
+            { ss } };
     }
 
     /*
      * DataProvider: sources that are empty
      */
     @DataProvider(name = "emptyInputSource")
-    Object[][] getInputSources() throws URISyntaxException {
+    public Object[][] getInputSources() throws URISyntaxException {
         byte[] utf8Bytes = null;
         try {
             utf8Bytes = "".getBytes("UTF8");
@@ -200,3 +213,4 @@
         return r;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/common/TestSAXDriver.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/common/TestSAXDriver.java	Mon Aug 08 12:50:00 2016 +0800
@@ -56,3 +56,4 @@
 
     private static final String ENT_EXP_LIMIT_PROP = "http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit";
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,29 +23,37 @@
 
 package common;
 
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import java.io.StringReader;
 import java.io.StringWriter;
+
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
 
 /*
  * @test
- * @modules javax.xml/com.sun.org.apache.xerces.internal.jaxp
  * @bug 8144593
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true common.TransformationWarningsTest
+ * @run testng/othervm common.TransformationWarningsTest
  * @summary Check that warnings about unsupported properties from parsers
  * are suppressed during the transformation process.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class TransformationWarningsTest extends WarningsTestBase {
 
     @BeforeClass
     public void setup() {
         //Set test SAX driver implementation.
-        System.setProperty("org.xml.sax.driver", "common.TestSAXDriver");
+        setSystemProperty("org.xml.sax.driver", "common.TestSAXDriver");
     }
 
     @Test
@@ -91,3 +99,4 @@
             + "</xsl:stylesheet>";
     private static final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root></root>";
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,8 +23,11 @@
 
 package common;
 
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import java.io.ByteArrayInputStream;
 import java.io.StringReader;
+
 import javax.xml.XMLConstants;
 import javax.xml.transform.Source;
 import javax.xml.transform.sax.SAXSource;
@@ -32,24 +35,29 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
 import org.xml.sax.InputSource;
 
 /*
  * @test
  * @bug 8144593
  * @key intermittent
- * @modules javax.xml/com.sun.org.apache.xerces.internal.jaxp
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true common.ValidationWarningsTest
+ * @run testng/othervm common.ValidationWarningsTest
  * @summary Check that warnings about unsupported properties from SAX
  *  parsers are suppressed during the xml validation process.
  */
+@Listeners({jaxp.library.InternalAPIPolicy.class})
 public class ValidationWarningsTest extends WarningsTestBase {
 
     @BeforeClass
     public void setup() {
         //Set test SAX driver implementation.
-        System.setProperty("org.xml.sax.driver", "common.TestSAXDriver");
+        setSystemProperty("org.xml.sax.driver", "common.TestSAXDriver");
     }
 
     @Test
@@ -76,3 +84,4 @@
     private static final String xml = "<?xml version='1.0'?><test>Element</test>";
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6320118.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6320118.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,12 +28,18 @@
 import javax.xml.datatype.XMLGregorianCalendar;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6320118
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.Bug6320118
+ * @run testng/othervm datatype.Bug6320118
  * @summary Test xml datatype XMLGregorianCalendar.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6320118 {
 
     DatatypeFactory df;
@@ -102,3 +108,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937951Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937951Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,12 +28,18 @@
 import javax.xml.datatype.XMLGregorianCalendar;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6937951
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.Bug6937951Test
+ * @run testng/othervm datatype.Bug6937951Test
  * @summary Test midnight is same as the start of the next day in XMLGregorianCalendar.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6937951Test {
 
     @Test
@@ -51,3 +57,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937964Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937964Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,12 +33,18 @@
 import javax.xml.namespace.QName;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6937964
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.Bug6937964Test
+ * @run testng/othervm datatype.Bug6937964Test
  * @summary Test Duration is normalized.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6937964Test {
     /**
      * Print debugging to System.err.
@@ -264,3 +270,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug7042647Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug7042647Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,18 @@
 import javax.xml.datatype.XMLGregorianCalendar;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 7042647
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.Bug7042647Test
+ * @run testng/othervm datatype.Bug7042647Test
  * @summary Test getFirstDayOfWeek is correct after converting XMLGregorianCalendar to a GregorianCalendar.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug7042647Test {
 
     @Test
@@ -54,3 +60,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/DatatypeFactoryTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/DatatypeFactoryTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,11 +34,17 @@
 import javax.xml.namespace.QName;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.DatatypeFactoryTest
+ * @run testng/othervm datatype.DatatypeFactoryTest
  * @summary Test DatatypeFactory.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class DatatypeFactoryTest {
 
     private static final boolean DEBUG = false;
@@ -634,3 +640,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/DurationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/DurationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,11 +39,17 @@
 import org.testng.Assert;
 import org.testng.AssertJUnit;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.DurationTest
+ * @run testng/othervm datatype.DurationTest
  * @summary Test Duration.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class DurationTest {
 
     private final static boolean DEBUG = true;
@@ -51,7 +57,7 @@
     protected Duration duration = null;
 
     @BeforeMethod
-    protected void setUp() {
+    public void setUp() {
         try {
             duration = DatatypeFactory.newInstance().newDuration(100);
         } catch (DatatypeConfigurationException dce) {
@@ -478,3 +484,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/FactoryFindTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/FactoryFindTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,45 +23,45 @@
 
 package datatype;
 
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+
 import java.net.URL;
 import java.net.URLClassLoader;
 
 import javax.xml.datatype.DatatypeFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.FactoryFindTest
+ * @run testng/othervm datatype.FactoryFindTest
  * @summary Test Classloader for DatatypeFactory.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class FactoryFindTest {
 
     boolean myClassLoaderUsed = false;
 
-    public FactoryFindTest(String name) {
-    }
+    @Test
+    public void testFactoryFind() throws Exception {
+        DatatypeFactory factory = DatatypeFactory.newInstance();
+        Assert.assertTrue(factory.getClass().getClassLoader() == null);
 
-    @Test
-    public void testFactoryFind() {
-        try {
-            // System.setProperty("jaxp.debug", "true");
-
-            DatatypeFactory factory = DatatypeFactory.newInstance();
-            Assert.assertTrue(factory.getClass().getClassLoader() == null);
+        runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
 
-            Thread.currentThread().setContextClassLoader(null);
-            factory = DatatypeFactory.newInstance();
-            Assert.assertTrue(factory.getClass().getClassLoader() == null);
+        factory = DatatypeFactory.newInstance();
+        Assert.assertTrue(factory.getClass().getClassLoader() == null);
 
-            Thread.currentThread().setContextClassLoader(new MyClassLoader());
-            factory = DatatypeFactory.newInstance();
-            if (System.getSecurityManager() == null)
-                Assert.assertTrue(myClassLoaderUsed);
-            else
-                Assert.assertFalse(myClassLoaderUsed);
-        } catch (Exception ex) {
-        }
-
+        runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(new MyClassLoader()));
+        factory = DatatypeFactory.newInstance();
+        if (System.getSecurityManager() == null)
+            Assert.assertTrue(myClassLoaderUsed);
+        else
+            Assert.assertFalse(myClassLoaderUsed);
     }
 
     class MyClassLoader extends URLClassLoader {
@@ -76,3 +76,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/JDK8068839Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/JDK8068839Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 import javax.xml.datatype.Duration;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 8068839
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.JDK8068839Test
+ * @run testng/othervm datatype.JDK8068839Test
  * @summary Verifies that Duration's edge cases
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class JDK8068839Test {
 
     @Test
@@ -45,3 +51,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/datatype/XMLGregorianCalendarTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/XMLGregorianCalendarTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,17 @@
 
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true datatype.XMLGregorianCalendarTest
+ * @run testng/othervm datatype.XMLGregorianCalendarTest
  * @summary Test XMLGregorianCalendar.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class XMLGregorianCalendarTest {
 
     private static final boolean DEBUG = false;
@@ -46,7 +52,7 @@
     private XMLGregorianCalendar calendar;
 
     @BeforeMethod
-    protected void setUp() {
+    public void setUp() {
         try {
             calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
         } catch (DatatypeConfigurationException dce) {
@@ -222,3 +228,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915524.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915524.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,16 +29,22 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 4915524
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug4915524
+ * @run testng/othervm dom.Bug4915524
  * @summary Test Document.adoptNode() shall not throw Exception when the source document object is created from different implementation.
  */
 
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4915524 {
 
     String data = "<?xml version=\"1.0\" ?>" + "<!DOCTYPE root [" + "<!ELEMENT root ANY>" + "<!ATTLIST root attr1 ID #FIXED 'xxx'"
@@ -75,3 +81,4 @@
         return docBuilder.parse(source);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915748.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915748.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.DOMConfiguration;
@@ -35,9 +36,14 @@
 import org.w3c.dom.Document;
 
 /*
+ * @test
  * @bug 4915748
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug4915748
+ * @run testng/othervm dom.Bug4915748
  * @summary Test DOMErrorHandler is called in case CDATA section is split by termination marker ']]>'.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4915748 {
 
     @Test
@@ -68,3 +74,4 @@
         Assert.assertTrue(hadError[0]);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966082.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966082.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,19 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
 /*
+ * @test
  * @bug 4966082
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug4966082
+ * @run testng/othervm dom.Bug4966082
  * @summary Test Element.getSchemaTypeInfo() returns an instance of TypeInfo instead of null when the document's schema is an XML DTD.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4966082 {
 
     @Test
@@ -47,3 +53,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966138.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966138.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,14 +27,20 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.TypeInfo;
 
 /*
+ * @test
  * @bug 4966138
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug4966138
+ * @run testng/othervm dom.Bug4966138
  * @summary Test Element's TypeInfo.getTypeName() returns a name instead of null in case the element is declared using anonymous simple type.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4966138 {
 
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
@@ -63,3 +69,4 @@
         Assert.assertTrue(typeNs.length() != 0, "returned typeNamespace shouldn't be empty");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966142.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966142.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,14 +27,20 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.TypeInfo;
 
 /*
+ * @test
  * @bug 4966142
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug4966142
+ * @run testng/othervm dom.Bug4966142
  * @summary Test TypeInfo.isDerivedFrom(...) works instead of throws UnsupportedOperationException when the TypeInfo instance refers to a simple type.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4966142 {
 
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
@@ -55,3 +61,4 @@
         Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_UNION));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966143.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966143.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,15 +27,21 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.TypeInfo;
 
 /*
+ * @test
  * @bug 4966143
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug4966143
+ * @run testng/othervm dom.Bug4966143
  * @summary Test isDerivedFrom(...) returns true only if the parameter is DERIVATION_EXTENSION,
  * in case TypeInfo instance refers to a complex type derived from another complex type by extension.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4966143 {
 
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
@@ -60,3 +66,4 @@
         Assert.assertTrue(type.isDerivedFrom("testNS", "Test", 0));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6339023.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6339023.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMImplementation;
@@ -36,9 +37,14 @@
 import org.w3c.dom.ls.LSSerializer;
 
 /*
+ * @test
  * @bug 6339023
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug6339023
+ * @run testng/othervm dom.Bug6339023
  * @summary Test normalize-characters.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6339023 {
 
     /*
@@ -133,3 +139,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6355326.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6355326.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
 
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
@@ -43,16 +44,21 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6355326
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug6355326
+ * @run testng/othervm dom.Bug6355326
  * @summary Test DOM implementation encoding.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6355326 {
 
     DOMImplementationLS implLS = null;
     String encodingXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><encodingXML/>";
 
     @BeforeMethod
-    protected void setUp() {
+    public void setUp() {
         Document doc = null;
         DocumentBuilder parser = null;
         String xml1 = "<?xml version=\"1.0\"?><ROOT></ROOT>";
@@ -112,3 +118,4 @@
         return p;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6367542.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6367542.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,20 @@
 package dom;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.bootstrap.DOMImplementationRegistry;
 
 /*
+ * @test
  * @bug 6367542
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug6367542
+ * @run testng/othervm dom.Bug6367542
  * @summary Test DOMImplementationRegistry.getDOMImplementation("XML") returns a DOMImplementation instance.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6367542 {
 
     @Test
@@ -46,3 +52,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6520131.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6520131.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMError;
@@ -37,9 +38,14 @@
 import org.w3c.dom.Text;
 
 /*
+ * @test
  * @bug 6520131
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug6520131
+ * @run testng/othervm dom.Bug6520131
  * @summary Test DOMErrorHandler reports an error for invalid character.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6520131 {
 
     @Test
@@ -77,3 +83,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6521260.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6521260.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,21 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6521260
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug6521260
+ * @run testng/othervm dom.Bug6521260
  * @summary Test setAttributeNS doesn't result in an unsorted internal list of attributes.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6521260 {
 
     @Test
@@ -71,3 +77,4 @@
         Assert.assertEquals(systemId, systemId2);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6582545Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6582545Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 
 package dom;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
 import java.io.File;
 import java.io.IOException;
 
@@ -30,7 +32,10 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import jaxp.library.JAXPTestUtilities;
+
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
@@ -38,9 +43,14 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6582545
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug6582545Test
+ * @run testng/othervm dom.Bug6582545Test
  * @summary Test the value is correct when iterating attributes.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6582545Test {
     private DocumentBuilder xmlParser = null;
     private Document document = null;
@@ -90,7 +100,7 @@
         }
 
         // Test specifique a node
-        String javaSpecificationVersion = System.getProperty("java.specification.version");
+        String javaSpecificationVersion = getSystemProperty("java.specification.version");
         for (int k = 0; k < attributes.getLength(); k++) {
             name = attributes.item(k).getNodeName();
             value = attributes.item(k).getNodeValue();
@@ -113,3 +123,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6879614Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6879614Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,14 +30,20 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6879614
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.Bug6879614Test
+ * @run testng/othervm dom.Bug6879614Test
  * @summary Test DocumentBuilder can parse the certain xml.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6879614Test {
 
     @Test
@@ -72,3 +78,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6333993Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6333993Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,14 +33,20 @@
 import javax.xml.xpath.XPathFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 
 /*
+ * @test
  * @bug 6333993
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.CR6333993Test
+ * @run testng/othervm dom.CR6333993Test
  * @summary Test NodeList.item(valid index) returns value after NodeList.item(NodeList.getLength()).
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class CR6333993Test {
 
     @Test
@@ -82,3 +88,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517707Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517707Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -40,9 +41,14 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6517707
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.CR6517707Test
+ * @run testng/othervm dom.CR6517707Test
  * @summary Test Node.setNodeValue(value) shall throw DOMException.NO_MODIFICATION_ALLOWED_ERR if the node is read-only.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class CR6517707Test {
 
     @Test
@@ -122,3 +128,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517717Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517717Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -39,9 +40,14 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6517717
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.CR6517717Test
+ * @run testng/othervm dom.CR6517717Test
  * @summary Test Node.setPrefix(prefix) shall throw DOMException.NO_MODIFICATION_ALLOWED_ERR if the node is read-only.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class CR6517717Test {
 
     @Test
@@ -80,3 +86,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6909336Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6909336Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,14 +29,20 @@
 import javax.xml.transform.dom.DOMResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.bootstrap.DOMImplementationRegistry;
 
 /*
+ * @test
  * @bug 6909336
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.CR6909336Test
+ * @run testng/othervm dom.CR6909336Test
  * @summary Test DOM writer can write more that 20 nested elements.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class CR6909336Test {
 
     @Test
@@ -66,3 +72,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/DOMConfigurationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/DOMConfigurationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
@@ -56,8 +57,13 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.DOMConfigurationTest
+ * @run testng/othervm dom.DOMConfigurationTest
  * @summary Test DOMConfiguration for supported properties.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DOMConfigurationTest {
 
     static class TestHandler implements DOMErrorHandler {
@@ -1622,3 +1628,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/DOMXPathTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/DOMXPathTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,19 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMImplementation;
 
 /*
+ * @test
  * @bug 8042244
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.DOMXPathTest
+ * @run testng/othervm dom.DOMXPathTest
  * @summary Verifies that the experimental DOM L3 XPath implementation is no longer available.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class DOMXPathTest {
     /*
        Verifies that DOMImplementation::hasFeature returns false and getFeature
@@ -48,3 +54,4 @@
         Assert.assertEquals(domImpl.getFeature("+XPath", "3.0"), null);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ElementTraversal.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ElementTraversal.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 import org.testng.Assert;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.DOMImplementation;
@@ -36,10 +37,15 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 8135283 8138721
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ElementTraversal
+ * @run testng/othervm dom.ElementTraversal
  * @summary Tests for the Element Traversal interface.
  */
 
+@Listeners({jaxp.library.FilePolicy.class})
 public class ElementTraversal {
     /*
        Verifies that ElementTraversal is supported.
@@ -111,7 +117,7 @@
      * DataProvider: a Document object
      */
     @DataProvider(name = "doc")
-    Object[][] getXPath() {
+    public Object[][] getXPath() {
         return new Object[][]{{getDoc()}};
     }
     Document getDoc() {
@@ -129,3 +135,4 @@
         return doc;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/JdkXmlDomTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/JdkXmlDomTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,19 +22,28 @@
  */
 package dom;
 
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 8078139
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.JdkXmlDomTest
+ * @run testng/othervm dom.JdkXmlDomTest
  * @summary Verifies that jdk.xml.dom classes are loaded by the ext class loader.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class JdkXmlDomTest {
     @Test
     public void test() throws ClassNotFoundException {
-        ClassLoader cl = ClassLoader.getSystemClassLoader().getParent();
+        ClassLoader cl = runWithAllPerm(() -> ClassLoader.getSystemClassLoader().getParent());
         Class<?> cls = Class.forName("org.w3c.dom.xpath.XPathEvaluator", false, cl);
 
-        Assert.assertTrue(cls.getClassLoader() != null);
+        Assert.assertTrue(runWithAllPerm(() -> cls.getClassLoader()) != null);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/TCKEncodingTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/TCKEncodingTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,14 +31,20 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.TCKEncodingTest
+ * @run testng/othervm dom.TCKEncodingTest
  * @summary Test Document.getInputEncoding().
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class TCKEncodingTest {
 
     /**
@@ -96,3 +102,4 @@
         System.out.println("OK");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug4973153.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug4973153.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMError;
 import org.w3c.dom.DOMErrorHandler;
@@ -49,9 +50,14 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 4973153
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ls.Bug4973153
+ * @run testng/othervm dom.ls.Bug4973153
  * @summary Test LSSerialiser.setEncoding() raises 'unsupported-encoding' error if encoding is invalid.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4973153 {
 
     DOMImplementationLS implLS = null;
@@ -94,7 +100,7 @@
     }
 
     @BeforeMethod
-    protected void setUp() {
+    public void setUp() {
         Document doc = null;
         DocumentBuilder parser = null;
         try {
@@ -116,7 +122,7 @@
     }
 
     @AfterMethod
-    protected void tearDown() {
+    public void tearDown() {
         implLS = null;
     }
 
@@ -198,3 +204,4 @@
         return true;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6290947.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6290947.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMImplementation;
@@ -43,10 +44,15 @@
 import org.w3c.dom.traversal.NodeFilter;
 
 /*
+ * @test
  * @bug 6290947
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ls.Bug6290947
+ * @run testng/othervm dom.ls.Bug6290947
  * @summary Test LSSerializer writes the XML declaration when LSSerializerFilter is set that rejects all nodes and
  * LSSerializer's configuration set parameter "xml-declaration" to "true".
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6290947 {
 
     private static String XML_STRING = "<?xml version=\"1.0\"?><ROOT><ELEMENT1><CHILD1/><CHILD1><COC1/></CHILD1></ELEMENT1><ELEMENT2>test1<CHILD2/></ELEMENT2></ROOT>";
@@ -141,3 +147,4 @@
         return src;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6354955.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6354955.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Comment;
@@ -40,9 +41,14 @@
 
 
 /*
+ * @test
  * @bug 6354955
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ls.Bug6354955
+ * @run testng/othervm dom.ls.Bug6354955
  * @summary Test LSSerializer can writeToString on DOM Text node with white space.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6354955 {
 
     @Test
@@ -136,3 +142,4 @@
         return documentBuilder.newDocument();
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6376823.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6376823.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMImplementation;
@@ -43,9 +44,14 @@
 import org.w3c.dom.traversal.NodeFilter;
 
 /*
+ * @test
  * @bug 6376823
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ls.Bug6376823
+ * @run testng/othervm dom.ls.Bug6376823
  * @summary Test LSSerializer works.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6376823 {
 
     private static String XML_STRING = "<?xml version=\"1.0\"?><ROOT><ELEMENT1><CHILD1/><CHILD1><COC1/></CHILD1></ELEMENT1><ELEMENT2>test1<CHILD2/></ELEMENT2></ROOT>";
@@ -115,3 +121,4 @@
         return src;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6710741Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6710741Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -34,9 +35,14 @@
 import org.w3c.dom.ls.LSException;
 
 /*
+ * @test
  * @bug 6710741
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ls.Bug6710741Test
+ * @run testng/othervm dom.ls.Bug6710741Test
  * @summary Test there should be stack trace information if LSSerializer().writeToString reports an exception.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6710741Test {
 
     @Test
@@ -74,3 +80,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTCKTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTCKTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMImplementation;
@@ -47,8 +48,13 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ls.LSParserTCKTest
+ * @run testng/othervm dom.ls.LSParserTCKTest
  * @summary Test Specifications and Descriptions for LSParser.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class LSParserTCKTest {
 
     DOMImplementationLS implLS = null;
@@ -578,3 +584,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMError;
@@ -39,8 +40,13 @@
 import org.w3c.dom.ls.LSResourceResolver;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ls.LSParserTest
+ * @run testng/othervm dom.ls.LSParserTest
  * @summary Test LSParser's DOMConfiguration for supported properties.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class LSParserTest {
 
     @Test
@@ -103,3 +109,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSSerializerTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSSerializerTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMError;
@@ -48,9 +49,14 @@
 
 
 /*
+ * @test
  * @bug 6439439 8080906
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true dom.ls.LSSerializerTest
+ * @run testng/othervm dom.ls.LSSerializerTest
  * @summary Test LSSerializer.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class LSSerializerTest {
     private static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print";
 
@@ -313,3 +319,4 @@
         Assert.assertEquals(XML11_DOCUMENT_OUTPUT, defaultSerialization, "Invalid serialization of XML 1.1 document: ");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4674384_MAX_OCCURS_Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4674384_MAX_OCCURS_Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,13 +29,19 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4674384
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug4674384_MAX_OCCURS_Test
+ * @run testng/othervm parsers.Bug4674384_MAX_OCCURS_Test
  * @summary Test large maxOccurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4674384_MAX_OCCURS_Test {
 
     @Test
@@ -64,3 +70,4 @@
         System.out.println("Success: File " + XML_FILE_NAME + " was parsed with a large value of maxOccurs.");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4934208.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4934208.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -35,9 +36,14 @@
 import util.DraconianErrorHandler;
 
 /*
+ * @test
  * @bug 4934208
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug4934208
+ * @run testng/othervm parsers.Bug4934208
  * @summary Test SAXParser can parse keyref constraint with a selector that is a union xpath expression selecting a node and its child.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4934208 {
     @Test
     public void test1() throws Exception {
@@ -68,3 +74,4 @@
         r.parse(is);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4967002.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4967002.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,16 +33,22 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 4967002
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug4967002
+ * @run testng/othervm parsers.Bug4967002
  * @summary Test DocumentBuilderFactory.newDocumentBuilder() throws ParserConfigurationException
  * when it uses the "http://java.sun.com/xml/jaxp/properties/schemaSource" property
  * and/or the "http://java.sun.com/xml/jaxp/properties/schemaLanguage" property
  * in conjunction with setting a Schema object.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4967002 {
     String schemaSource = "<?xml version='1.0'?>\n" + "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>\n" + "  <xsd:element name='test101'>\n"
             + "    <xsd:complexType>\n" + "      <xsd:attribute name='attr'/>\n" + "      <xsd:attribute name='attr2' default='DEF'/>\n"
@@ -95,3 +101,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4985486.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4985486.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,20 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4985486
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug4985486
+ * @run testng/othervm parsers.Bug4985486
  * @summary Test SAXParser can parse large characters(more than 10000).
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4985486 {
 
     @Test
@@ -62,3 +68,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991020.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991020.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,12 +26,18 @@
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4991020
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug4991020
+ * @run testng/othervm parsers.Bug4991020
  * @summary Test XPath like "node_name/." can be parsed.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4991020 {
 
     protected static SAXParser createParser() throws Exception {
@@ -50,3 +56,4 @@
         parser.parse(Bug4991020.class.getResource("Bug4991020.xml").toExternalForm(), new util.DraconianErrorHandler());
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991946.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991946.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,12 +26,18 @@
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4991946
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug4991946
+ * @run testng/othervm parsers.Bug4991946
  * @summary Can parse the element type is anyType in the schema and is substituted by the simple type via the 'xsi:type' attribute in xml document.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4991946 {
 
     protected static SAXParser createParser() throws Exception {
@@ -50,3 +56,4 @@
         parser.parse(Bug4991946.class.getResource("Bug4991946.xml").toExternalForm(), new util.DraconianErrorHandler());
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5010072.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5010072.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,15 +26,21 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 5010072
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug5010072
+ * @run testng/othervm parsers.Bug5010072
  * @summary Test SchemaFactory throws SAXException if xpath is "@".
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug5010072 {
 
     protected static class ErrorHandler extends DefaultHandler {
@@ -71,3 +77,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5025825.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5025825.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,15 +33,21 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 5025825
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug5025825
+ * @run testng/othervm parsers.Bug5025825
  * @summary Test if SAXParserFactory set a Schema object, when SAXParser sets "http://java.sun.com/xml/jaxp/properties/schemaSource" property
  * and/or "http://java.sun.com/xml/jaxp/properties/schemaLanguage" property, it shall throw SAXException.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug5025825 {
 
     String schemaSource = "<?xml version='1.0'?>\n" + "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>\n" + "  <xsd:element name='test101'>\n"
@@ -83,3 +89,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6309988.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6309988.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,9 @@
 
 package parsers;
 
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import java.io.File;
 import java.io.InputStream;
 
@@ -33,31 +36,28 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 6309988
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6309988
+ * @run testng/othervm parsers.Bug6309988
  * @summary Test elementAttributeLimit, maxOccurLimit, entityExpansionLimit.
  */
+@Test(singleThreaded = true)
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6309988 {
 
     DocumentBuilderFactory dbf = null;
-    static boolean _isSecureMode = false;
-    static {
-        if (System.getSecurityManager() != null) {
-            _isSecureMode = true;
-            System.out.println("Security Manager is present");
-        } else {
-            System.out.println("Security Manager is NOT present");
-        }
-    }
 
     /*
      * Given XML document has more than 10000 attributes. Exception is expected
      */
-    @Test
     public void testDOMParserElementAttributeLimit() {
         try {
             dbf = DocumentBuilderFactory.newInstance();
@@ -75,7 +75,6 @@
      * Given XML document has more than 10000 attributes. It should report an
      * error.
      */
-    @Test
     public void testDOMNSParserElementAttributeLimit() {
         try {
             dbf = DocumentBuilderFactory.newInstance();
@@ -94,9 +93,8 @@
      * Given XML document has more than 10000 attributes. Parsing this XML
      * document in non-secure mode, should not report any error.
      */
-    @Test
     public void testDOMNSParserElementAttributeLimitWithoutSecureProcessing() {
-        if (_isSecureMode)
+        if (isSecureMode())
             return; // jaxp secure feature can not be turned off when security
                     // manager is present
         try {
@@ -121,16 +119,15 @@
      * test should be the same as
      * testSystemElementAttributeLimitWithSecureProcessing
      */
-    @Test
     public void testSystemElementAttributeLimitWithoutSecureProcessing() {
-        if (_isSecureMode)
+        if (isSecureMode())
             return; // jaxp secure feature can not be turned off when security
                     // manager is present
         try {
             dbf = DocumentBuilderFactory.newInstance();
             dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
             dbf.setNamespaceAware(true);
-            System.setProperty("elementAttributeLimit", "2");
+            setSystemProperty("elementAttributeLimit", "2");
             DocumentBuilder parser = dbf.newDocumentBuilder();
             Document doc = parser.parse(this.getClass().getResourceAsStream("DosTest3.xml"));
 
@@ -147,7 +144,7 @@
                 Assert.fail("Unexpected error: " + e.getMessage());
             }
         } finally {
-            System.clearProperty("elementAttributeLimit");
+            clearSystemProperty("elementAttributeLimit");
         }
     }
 
@@ -155,12 +152,11 @@
      * Given XML document has 3 attributes and System property is set to 2.
      * Parsing this XML document in secure mode, should report an error.
      */
-    @Test
     public void testSystemElementAttributeLimitWithSecureProcessing() {
         try {
             dbf = DocumentBuilderFactory.newInstance();
             dbf.setNamespaceAware(true);
-            System.setProperty("elementAttributeLimit", "2");
+            setSystemProperty("elementAttributeLimit", "2");
             DocumentBuilder parser = dbf.newDocumentBuilder();
             Document doc = parser.parse(this.getClass().getResourceAsStream("DosTest3.xml"));
             Assert.fail("SAXParserException is expected, as given XML document contains more than 2 attributes");
@@ -169,14 +165,13 @@
         } catch (Exception e) {
             Assert.fail("Exception " + e.getMessage());
         } finally {
-            System.setProperty("elementAttributeLimit", "");
+            setSystemProperty("elementAttributeLimit", "");
         }
     }
 
     /*
      * Default value for secure processing feature should be true.
      */
-    @Test
     public void testDOMSecureProcessingDefaultValue() {
         try {
             dbf = DocumentBuilderFactory.newInstance();
@@ -190,7 +185,6 @@
     /*
      * Default value for secure processing feature should be true.
      */
-    @Test
     public void testSAXSecureProcessingDefaultValue() {
         try {
             SAXParserFactory spf = SAXParserFactory.newInstance();
@@ -206,16 +200,15 @@
      * feature is off. Given doument contains more than 2 elements and hence an
      * error should be reported.
      */
-    @Test
     public void testSystemMaxOccurLimitWithoutSecureProcessing() {
-        if (_isSecureMode)
+        if (isSecureMode())
             return; // jaxp secure feature can not be turned off when security
                     // manager is present
         try {
             SAXParserFactory spf = SAXParserFactory.newInstance();
             spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
             spf.setValidating(true);
-            System.setProperty("maxOccurLimit", "2");
+            setSystemProperty("maxOccurLimit", "2");
             // Set the properties for Schema Validation
             String SCHEMA_LANG = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
             String SCHEMA_TYPE = "http://www.w3.org/2001/XMLSchema";
@@ -230,7 +223,7 @@
             MyErrorHandler eh = new MyErrorHandler();
             parser.parse(is, eh);
             Assert.assertFalse(eh.errorOccured, "Not Expected Error");
-            System.setProperty("maxOccurLimit", "");
+            setSystemProperty("maxOccurLimit", "");
         } catch (Exception e) {
             Assert.fail("Exception occured: " + e.getMessage());
         }
@@ -242,9 +235,8 @@
      * maxOccur is '3002'. Since secure processing feature is off, document
      * should be parsed without any errors.
      */
-    @Test
     public void testValidMaxOccurLimitWithOutSecureProcessing() {
-        if (_isSecureMode)
+        if (isSecureMode())
             return; // jaxp secure feature can not be turned off when security
                     // manager is present
         try {
@@ -279,13 +271,12 @@
      * test should be the same as
      * testSystemElementAttributeLimitWithSecureProcessing
      */
-    @Test
     public void testSystemEntityExpansionLimitWithOutSecureProcessing() {
-        if (_isSecureMode)
+        if (isSecureMode())
             return; // jaxp secure feature can not be turned off when security
                     // manager is present
         try {
-            System.setProperty("entityExpansionLimit", "2");
+            setSystemProperty("entityExpansionLimit", "2");
             dbf = DocumentBuilderFactory.newInstance();
             dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
             dbf.setValidating(true);
@@ -304,7 +295,7 @@
                 Assert.fail("Unexpected error: " + e.getMessage());
             }
         } finally {
-            System.clearProperty("entityExpansionLimit");
+            clearSystemProperty("entityExpansionLimit");
         }
     }
 
@@ -312,12 +303,11 @@
      * System property is set to 2. Given XML document has more than 2 entity
      * references. Parsing this document in secure mode, should report an error.
      */
-    @Test
     public void testSystemEntityExpansionLimitWithSecureProcessing() {
         try {
             dbf = DocumentBuilderFactory.newInstance();
             dbf.setValidating(true);
-            System.setProperty("entityExpansionLimit", "2");
+            setSystemProperty("entityExpansionLimit", "2");
             DocumentBuilder parser = dbf.newDocumentBuilder();
             Document doc = parser.parse(this.getClass().getResourceAsStream("entity.xml"));
             Assert.fail("SAXParserException is expected, as given XML document contains more 2 entity references");
@@ -327,7 +317,7 @@
         } catch (Exception e) {
             Assert.fail("Exception " + e.getMessage());
         } finally {
-            System.setProperty("entityExpansionLimit", "");
+            setSystemProperty("entityExpansionLimit", "");
         }
     }
 
@@ -335,7 +325,6 @@
      * Given XML document has more than 64000 entity references. Parsing this
      * document in secure mode, should report an error.
      */
-    @Test
     public void testEntityExpansionLimitWithSecureProcessing() {
         try {
             dbf = DocumentBuilderFactory.newInstance();
@@ -349,7 +338,7 @@
         } catch (Exception e) {
             Assert.fail("Exception " + e.getMessage());
         } finally {
-            System.setProperty("entityExpansionLimit", "");
+            setSystemProperty("entityExpansionLimit", "");
         }
     }
 
@@ -357,9 +346,8 @@
      * Given XML document has more than 64000 entity references. Parsing this
      * document in non-secure mode, should not report any error.
      */
-    @Test
     public void testEntityExpansionLimitWithOutSecureProcessing() {
-        if (_isSecureMode)
+        if (isSecureMode())
             return; // jaxp secure feature can not be turned off when security
                     // manager is present
         try {
@@ -374,7 +362,12 @@
         } catch (Exception e) {
             Assert.fail("Exception " + e.getMessage());
         } finally {
-            System.setProperty("entityExpansionLimit", "");
+            setSystemProperty("entityExpansionLimit", "");
         }
     }
+
+    private boolean isSecureMode() {
+        return System.getSecurityManager() != null;
+    }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,29 +23,38 @@
 
 package parsers;
 
+import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.PrintWriter;
+import java.util.PropertyPermission;
 
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6341770
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6341770
+ * @run testng/othervm parsers.Bug6341770
  * @summary Test external entity linked to non-ASCII base URL.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6341770 {
 
     // naming a file "aux" would fail on windows.
     @Test
     public void testNonAsciiURI() {
         try {
-            File dir = File.createTempFile("sko\u0159ice", null);
+            File dir = new File("sko\u0159ice");
             dir.delete();
             dir.mkdir();
             File main = new File(dir, "main.xml");
@@ -60,11 +69,13 @@
             w.flush();
             w.close();
             System.out.println("Parsing: " + main);
-            SAXParserFactory.newInstance().newSAXParser().parse(main, new DefaultHandler() {
-                public void startElement(String uri, String localname, String qname, Attributes attr) throws SAXException {
-                    System.out.println("encountered <" + qname + ">");
-                }
-            });
+            tryRunWithTmpPermission(
+                    () -> SAXParserFactory.newInstance().newSAXParser().parse(main, new DefaultHandler() {
+                        public void startElement(String uri, String localname, String qname, Attributes attr)
+                                throws SAXException {
+                            System.out.println("encountered <" + qname + ">");
+                        }
+                    }), new PropertyPermission("user.dir", "read"));
         } catch (Exception e) {
             e.printStackTrace();
             Assert.fail("Exception: " + e.getMessage());
@@ -72,3 +83,4 @@
         System.out.println("OK.");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6361283.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6361283.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6361283
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6361283
+ * @run testng/othervm parsers.Bug6361283
  * @summary Test SAXParser returns version as 1.1 for XML 1.1 document.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6361283 {
 
     @Test
@@ -50,3 +56,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6506304Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6506304Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,21 +23,29 @@
 
 package parsers;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.XMLReader;
 
 /*
+ * @test
  * @bug 6506304
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6506304Test
+ * @run testng/othervm parsers.Bug6506304Test
  * @summary Test MalformedURLException: unknown protocol won't be thrown when there is a space within the full path file name.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6506304Test {
     public static boolean isWindows = false;
     static {
-        if (System.getProperty("os.name").indexOf("Windows") > -1) {
+        if (getSystemProperty("os.name").indexOf("Windows") > -1) {
             isWindows = true;
         }
     };
@@ -63,3 +71,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6518733.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6518733.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,15 +29,21 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6518733
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6518733
+ * @run testng/othervm parsers.Bug6518733
  * @summary Test SAX parser handles several attributes that each contain a newline within the attribute value.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6518733 {
 
     @Test
@@ -61,3 +67,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6564400.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6564400.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,7 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -46,9 +47,14 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6564400
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6564400
+ * @run testng/othervm parsers.Bug6564400
  * @summary Test ignorable whitespace handling with schema validation.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6564400 {
     private boolean sawIgnorable = false;
     Schema schema = null;
@@ -174,3 +180,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,12 +29,18 @@
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6573786
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6573786
+ * @run testng/othervm parsers.Bug6573786
  * @summary Test parser error messages are formatted.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6573786 {
     String _cache = "";
 
@@ -67,3 +73,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786ErrorHandler.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786ErrorHandler.java	Mon Aug 08 12:50:00 2016 +0800
@@ -45,3 +45,4 @@
         System.out.println(e.getMessage());
     } // warning ()
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6594813.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6594813.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,14 +34,20 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6594813
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6594813
+ * @run testng/othervm parsers.Bug6594813
  * @summary Test SAXParser output is wellformed with name space.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6594813 {
 
     public Bug6594813(String name) {
@@ -169,3 +175,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6608841.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6608841.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,14 +30,20 @@
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6608841
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6608841
+ * @run testng/othervm parsers.Bug6608841
  * @summary Test SAX parses external parameter entity.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6608841 {
     public Bug6608841(String name) {
     }
@@ -53,3 +59,4 @@
     public class MyHandler extends DefaultHandler {
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6690015.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6690015.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -37,9 +38,14 @@
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 6518733
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6690015
+ * @run testng/othervm parsers.Bug6690015
  * @summary Test SAX parser handles several attributes with newlines.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6690015 {
 
     public Bug6690015() {
@@ -81,3 +87,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6760982.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6760982.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
@@ -39,9 +40,14 @@
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 6518733
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6760982
+ * @run testng/othervm parsers.Bug6760982
  * @summary Test SAX parser handles several attributes with containing "&gt;".
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6760982 {
 
     @Test
@@ -162,3 +168,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6849942Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6849942Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,15 +29,21 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.ProcessingInstruction;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 6849942
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug6849942Test
+ * @run testng/othervm parsers.Bug6849942Test
  * @summary Test parsing an XML that starts with a processing instruction and no prolog.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6849942Test {
 
     @Test
@@ -75,3 +81,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7157608Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7157608Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 
 package parsers;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
 import java.io.File;
 import java.io.IOException;
 
@@ -31,6 +33,7 @@
 
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -39,13 +42,18 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 7157608
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug7157608Test
+ * @run testng/othervm parsers.Bug7157608Test
  * @summary Test feature standard-uri-conformant works.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug7157608Test {
     public static boolean isWindows = false;
     static {
-        if (System.getProperty("os.name").indexOf("Windows") > -1) {
+        if (getSystemProperty("os.name").indexOf("Windows") > -1) {
             isWindows = true;
         }
     };
@@ -53,7 +61,7 @@
     String xml1, xml2;
 
     @BeforeMethod
-    protected void setUp() throws IOException {
+    public void setUp() throws IOException {
         File file1 = new File(getClass().getResource("Bug7157608.xml").getFile());
         xml1 = file1.getPath().replace("\\", "\\\\");
         File file2 = new File(getClass().getResource("Bug7157608_1.xml").getFile());
@@ -210,3 +218,4 @@
         boolean validating = false;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7166896Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7166896Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,14 +30,20 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 7166896
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug7166896Test
+ * @run testng/othervm parsers.Bug7166896Test
  * @summary Test DocumentBuilder.parse(String uri) supports IPv6 format.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug7166896Test {
 
     @Test
@@ -74,3 +80,4 @@
 
     }
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8003147
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @compile Bug8003147TestClass.java
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug8003147Test
+ * @run testng/othervm parsers.Bug8003147Test
+ * @summary Test port fix for BCEL bug 39695.
+ */
+
+package parsers;
+
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
+import java.io.FileOutputStream;
+import java.io.FilePermission;
+
+import jaxp.library.JAXPTestUtilities;
+
+import org.testng.Assert;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+import com.sun.org.apache.bcel.internal.classfile.ClassParser;
+import com.sun.org.apache.bcel.internal.classfile.ConstantClass;
+import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
+import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
+import com.sun.org.apache.bcel.internal.classfile.JavaClass;
+import com.sun.org.apache.bcel.internal.classfile.Method;
+import com.sun.org.apache.bcel.internal.generic.ClassGen;
+import com.sun.org.apache.bcel.internal.generic.MethodGen;
+
+@Listeners({ jaxp.library.FilePolicy.class, jaxp.library.InternalAPIPolicy.class })
+public class Bug8003147Test {
+
+    @Test
+    public void test() throws Exception {
+        // Note: com.sun.org.apache.bcel.internal.classfile.JavaClass doesn't
+        // support InvokeDynamic, so can't use lambda, also can't use string1 +
+        // string2, because javac will generate a dynamic call where invoking
+        // string1.concat(string2), so create a separate Bug8003147TestClass
+        JAXPTestUtilities.tryRunWithTmpPermission(() -> {
+            String classfile = getSystemProperty("test.classes") + "/parsers/Bug8003147TestClass.class";
+            JavaClass jc = new ClassParser(classfile).parse();
+
+            // rename class
+            ConstantPool cp = jc.getConstantPool();
+            int cpIndex = ((ConstantClass) cp.getConstant(jc.getClassNameIndex())).getNameIndex();
+            cp.setConstant(cpIndex, new ConstantUtf8("parsers/Bug8003147TestClassPrime"));
+            ClassGen gen = new ClassGen(jc);
+            Method[] methods = jc.getMethods();
+            int index;
+            for (index = 0; index < methods.length; index++) {
+                if (methods[index].getName().equals("doSomething")) {
+                    break;
+                }
+            }
+            Method m = methods[index];
+            MethodGen mg = new MethodGen(m, gen.getClassName(), gen.getConstantPool());
+            gen.replaceMethod(m, mg.getMethod());
+            String path = classfile.replace("Bug8003147TestClass", "Bug8003147TestClassPrime");
+            gen.getJavaClass().dump(new FileOutputStream(path));
+
+            try {
+                Class.forName("parsers.Bug8003147TestClassPrime");
+            } catch (ClassFormatError cfe) {
+                cfe.printStackTrace();
+                Assert.fail("modified version of class does not pass verification");
+            }
+        }, new FilePermission(getSystemProperty("test.classes") + "/-", "read,write"));
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147TestClass.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package parsers;
+
+import java.util.ArrayList;
+
+/*
+ * Class for Bug8003147Test, includes a method, which has a generic argument
+ */
+public class Bug8003147TestClass {
+    public void doSomething(double d, ArrayList<Integer> list) {
+    }
+}
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8073385.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8073385.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,37 +23,46 @@
 
 package parsers;
 
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+import static org.testng.Assert.assertTrue;
+
 import java.io.StringReader;
 import java.util.Locale;
-import javax.xml.parsers.DocumentBuilderFactory;
+
 import javax.xml.parsers.DocumentBuilder;
-import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
+import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
-import static org.testng.Assert.assertTrue;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 /**
+ * @test
  * @bug 8073385
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.Bug8073385
+ * @run testng/othervm parsers.Bug8073385
  * @summary test that invalid XML character exception string contains
  *     information about character value, element and attribute names
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug8073385 {
 
     private Locale defLoc;
 
     @BeforeClass
-    private void setup() {
+    public void setup() {
         defLoc = Locale.getDefault();
-        Locale.setDefault(Locale.ENGLISH);
+        runWithAllPerm(() -> Locale.setDefault(Locale.ENGLISH));
     }
 
     @AfterClass
-    private void cleanup() {
-        Locale.setDefault(defLoc);
+    public void cleanup() {
+        runWithAllPerm(() -> Locale.setDefault(defLoc));
     }
 
     @DataProvider(name = "illegalCharactersData")
@@ -91,3 +100,4 @@
         assertTrue(exceptionText.contains("Unicode: " + hexString));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,42 +23,44 @@
 
 package parsers;
 
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+
 import java.net.URL;
 import java.net.URLClassLoader;
 
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.FactoryFindTest
+ * @run testng/othervm parsers.FactoryFindTest
  * @summary Test Classloader for SAXParserFactory.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class FactoryFindTest {
 
     boolean myClassLoaderUsed = false;
 
     @Test
     public void testFactoryFind() {
-        try {
-            // System.setProperty("jaxp.debug", "true");
+        SAXParserFactory factory = SAXParserFactory.newInstance();
+        Assert.assertTrue(factory.getClass().getClassLoader() == null);
 
-            SAXParserFactory factory = SAXParserFactory.newInstance();
-            Assert.assertTrue(factory.getClass().getClassLoader() == null);
-
-            Thread.currentThread().setContextClassLoader(null);
-            factory = SAXParserFactory.newInstance();
-            Assert.assertTrue(factory.getClass().getClassLoader() == null);
+        runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
+        factory = SAXParserFactory.newInstance();
+        Assert.assertTrue(factory.getClass().getClassLoader() == null);
 
-            Thread.currentThread().setContextClassLoader(new MyClassLoader());
-            factory = SAXParserFactory.newInstance();
-            if (System.getSecurityManager() == null)
-                Assert.assertTrue(myClassLoaderUsed);
-            else
-                Assert.assertFalse(myClassLoaderUsed);
-        } catch (Exception ex) {
-        }
-
+        runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(new MyClassLoader()));
+        factory = SAXParserFactory.newInstance();
+        if (System.getSecurityManager() == null)
+            Assert.assertTrue(myClassLoaderUsed);
+        else
+            Assert.assertFalse(myClassLoaderUsed);
     }
 
     class MyClassLoader extends URLClassLoader {
@@ -73,3 +75,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/MyDefaultHandler.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/MyDefaultHandler.java	Mon Aug 08 12:50:00 2016 +0800
@@ -45,3 +45,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/MyErrorHandler.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/MyErrorHandler.java	Mon Aug 08 12:50:00 2016 +0800
@@ -53,3 +53,4 @@
         errorOccured = true;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/ParseEmptyStream.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/ParseEmptyStream.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,13 +29,19 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.ParseEmptyStream
+ * @run testng/othervm parsers.ParseEmptyStream
  * @summary Test SAXParser doesn't accept empty stream.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class ParseEmptyStream {
 
     SAXParserFactory factory = null;
@@ -86,3 +92,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/SupplementaryChars.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/SupplementaryChars.java	Mon Aug 08 12:50:00 2016 +0800
@@ -5,18 +5,24 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /**
+ * @test
  * @bug 8072081
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.SupplementaryChars
+ * @run testng/othervm parsers.SupplementaryChars
  * @summary verifies that supplementary characters are supported as character
  * data in xml 1.0, and also names in xml 1.1.
  *
  * Joe Wang (huizhe.wang@oracle.com)
  */
 
+@Listeners({jaxp.library.BasePolicy.class})
 public class SupplementaryChars {
 
     @Test(dataProvider = "supported")
@@ -34,7 +40,7 @@
     }
 
     @DataProvider(name = "supported")
-    private Object[][] supported() {
+    public Object[][] supported() {
 
         return new Object[][] {
             {"<?xml version=\"1.0\"?><tag>\uD840\uDC0B</tag>"},
@@ -47,7 +53,7 @@
     }
 
     @DataProvider(name = "unsupported")
-    private Object[][] unsupported() {
+    public Object[][] unsupported() {
         return new Object[][] {
             {"<?xml version=\"1.0\"?><tag\uD840\uDC0B>in tag name</tag\uD840\uDC0B>"},
             {"<?xml version=\"1.0\"?><tag attr\uD840\uDC0B=\"in attribute\">in attribute name</tag>"}
@@ -65,3 +71,4 @@
         return parser;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/parsers/xinclude/Bug6794483Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/xinclude/Bug6794483Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,15 +37,21 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 
 /*
+ * @test
  * @bug 6794483 8080908
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true parsers.xinclude.Bug6794483Test
+ * @run testng/othervm parsers.xinclude.Bug6794483Test
  * @summary Test JAXP parser can resolve the included content properly if the
  * included xml contains an empty tag that ends with "/>", refer to XERCESJ-1134.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6794483Test {
 
     @Test
@@ -101,3 +107,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/policy/PolicyUtil.java	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package policy;
-
-import java.security.Policy;
-
-public class PolicyUtil {
-
-    public static void changePolicy(String policyFile) {
-        System.setProperty("java.security.policy", policyFile);
-        Policy.getPolicy().refresh();
-    }
-
-}
--- a/jaxp/test/javax/xml/jaxp/unittest/policy/common.policy	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-grant {
-	permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
-	permission java.lang.RuntimePermission "accessDeclaredMembers";
-	
-	permission java.io.FilePermission "${test.classes}/../../-", "read, write, delete";
-	permission java.io.FilePermission ".", "read, write, delete";
-	permission java.util.PropertyPermission "*", "read, write";
-	
-    permission java.lang.RuntimePermission "setSecurityManager";
-    permission java.lang.RuntimePermission "createSecurityManager";
-    permission java.lang.RuntimePermission "createClassLoader";
-    permission java.lang.RuntimePermission "setIO";
-	permission java.lang.RuntimePermission "setContextClassLoader"; 
-	permission java.security.SecurityPermission "getPolicy";
-    
-    permission java.io.FilePermission "${test.src}/-", "read, write, delete";
-    permission java.io.FilePermission "${user.dir}/-", "read, write, delete";
-    permission java.io.FilePermission "${java.io.tmpdir}/-", "read, write, delete";
-    
-    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.org.apache.bcel.internal.classfile";
-    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.org.apache.bcel.internal.generic";
-    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.xml.internal.stream.writers";
-    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.org.apache.xerces.internal.impl";
-    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.org.apache.xalan.internal";
-    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.org.apache.xalan.internal.xsltc.trax";
-	permission java.lang.RuntimePermission "accessClassInPackage.com.sun.org.apache.xalan.internal.xslt";
-};
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/Attributes2ImplTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Attributes2ImplTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,12 +24,18 @@
 package sax;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ext.Attributes2Impl;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.Attributes2ImplTest
+ * @run testng/othervm sax.Attributes2ImplTest
  * @summary Test Attributes2Impl.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Attributes2ImplTest {
 
     @Test
@@ -147,3 +153,4 @@
         Assert.assertTrue(impl1.getQName(2).equals(impl3.getQName(2)));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6889654Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6889654Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,15 +30,21 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6889654
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.Bug6889654Test
+ * @run testng/othervm sax.Bug6889654Test
  * @summary Test SAXException includes whole information.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6889654Test {
 
     final String MSG = "Failed to parse XML";
@@ -81,3 +87,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6925410Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6925410Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,20 @@
 
 import javax.xml.datatype.DatatypeConfigurationException;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 import org.xml.sax.helpers.XMLReaderFactory;
 
 /*
+ * @test
  * @bug 6925410
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.Bug6925410Test
+ * @run testng/othervm sax.Bug6925410Test
  * @summary Test XMLReaderFactory can createXMLReader repeatedly.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6925410Test {
 
     @Test
@@ -54,3 +60,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6949607Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6949607Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,15 +29,21 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6949607
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.Bug6949607Test
+ * @run testng/othervm sax.Bug6949607Test
  * @summary Test Attributes.getValue returns null when parameter uri is empty.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6949607Test {
 
     final String MSG = "Failed to parse XML";
@@ -75,3 +81,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6992561Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6992561Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
@@ -40,9 +41,14 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6992561
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.Bug6992561Test
+ * @run testng/othervm sax.Bug6992561Test
  * @summary Test encoding of SystemId in Locator.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6992561Test {
 
     @Test
@@ -80,3 +86,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug7057778Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug7057778Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,9 @@
 
 package sax;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -33,13 +36,15 @@
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.util.PropertyPermission;
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
-import org.testng.Assert;
 import org.xml.sax.Attributes;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
@@ -48,9 +53,14 @@
 import org.xml.sax.ext.DefaultHandler2;
 
 /*
+ * @test
  * @bug 7057778
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.Bug7057778Test
+ * @run testng/othervm sax.Bug7057778Test
  * @summary Test the file can be deleted after SAXParser.parse(File, DefaultHandler).
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug7057778Test {
 
     static final String xml = "Bug7057778.xml";
@@ -59,20 +69,22 @@
     @Test
     public void testParse() {
         File src = new File(getClass().getResource(xml).getFile());
-        File dst = new File(src.getParent() + File.separator + xml1);
+        File dst = new File(xml1);
         try {
             copyFile(src, dst);
             SAXParserFactory spf = SAXParserFactory.newInstance();
             SAXParser parser = spf.newSAXParser();
             XMLReader xmlReader = parser.getXMLReader();
             xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", new MyHandler1());
-            parser.parse(dst, new MyHandler1());
+            tryRunWithTmpPermission(() -> parser.parse(dst, new MyHandler1()),
+                    new PropertyPermission("user.dir", "read"));
         } catch (SAXException ex) {
             ex.printStackTrace();
         } catch (IOException ex) {
             // shouldn't happen
         } catch (ParserConfigurationException ex) {
             // shouldn't happen
+        } catch (Exception ex) {
         }
         if (dst != null) {
             if (dst.delete()) {
@@ -173,7 +185,7 @@
         // Start a new line
         // and indent the next line appropriately
         private void nl() throws SAXException {
-            String lineEnd = System.getProperty("line.separator");
+            String lineEnd = getSystemProperty("line.separator");
 
             try {
                 out.write(lineEnd);
@@ -187,3 +199,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/DefaultHandler2Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/DefaultHandler2Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 
 import org.testng.Assert;
 import org.testng.AssertJUnit;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
@@ -42,8 +43,13 @@
 import org.xml.sax.helpers.XMLReaderFactory;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.DefaultHandler2Test
+ * @run testng/othervm sax.DefaultHandler2Test
  * @summary Test DefaultHandler2.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DefaultHandler2Test {
 
     @Test
@@ -245,3 +251,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/IssueTracker56Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/IssueTracker56Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import javax.xml.parsers.SAXParserFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.ErrorHandler;
@@ -39,9 +40,14 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6809409
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.IssueTracker56Test
+ * @run testng/othervm sax.IssueTracker56Test
  * @summary Test SAXException has Cause.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class IssueTracker56Test {
 
     @Test
@@ -136,3 +142,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/MyDefaultHandler2.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/MyDefaultHandler2.java	Mon Aug 08 12:50:00 2016 +0800
@@ -198,3 +198,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/NSSupportTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/NSSupportTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 
 import org.testng.Assert;
 import org.testng.AssertJUnit;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.helpers.NamespaceSupport;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.NSSupportTest
+ * @run testng/othervm sax.NSSupportTest
  * @summary Test NamespaceSupport.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class NSSupportTest {
 
     @Test
@@ -226,3 +232,4 @@
         Assert.assertNull(nssupport.getURI(""));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/SAXExceptionExt.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/SAXExceptionExt.java	Mon Aug 08 12:50:00 2016 +0800
@@ -38,3 +38,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/sax/XMLReaderTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/sax/XMLReaderTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,18 +23,27 @@
 
 package sax;
 
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParserFactory;
+
 import org.testng.annotations.AfterClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.XMLReaderAdapter;
 
 /*
+ * @test
  * @bug 8158246
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true sax.XMLReaderTest
+ * @run testng/othervm sax.XMLReaderTest
  * @summary This class contains tests that cover the creation of XMLReader.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class XMLReaderTest {
     private final String SAX_PROPNAME = "org.xml.sax.driver";
 
@@ -43,7 +52,7 @@
      */
     @AfterClass
     public void cleanUp() throws Exception {
-        System.clearProperty(SAX_PROPNAME);
+        clearSystemProperty(SAX_PROPNAME);
     }
 
     /*
@@ -57,7 +66,8 @@
     public void testcreateXMLReader() throws SAXException, ParserConfigurationException {
         String className = SAXParserFactory.newInstance().newSAXParser()
                             .getXMLReader().getClass().getName();
-        System.setProperty(SAX_PROPNAME, className + "nosuch");
+        setSystemProperty(SAX_PROPNAME, className + "nosuch");
         XMLReaderAdapter adapter = new XMLReaderAdapter();
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/AttributeLocalNameTest/AttributeLocalNameTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/AttributeLocalNameTest/AttributeLocalNameTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,11 +30,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.AttributeLocalNameTest.AttributeLocalNameTest
+ * @run testng/othervm stream.AttributeLocalNameTest.AttributeLocalNameTest
  * @summary Test XMLStreamReader.getAttributeLocalName().
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class AttributeLocalNameTest {
 
     static final String XML = "<?xml version=\"1.0\"?>" + "<S:Envelope foo=\"bar\" xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"></S:Envelope>";
@@ -60,3 +66,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6370703.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6370703.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6370703
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.Bug6370703
+ * @run testng/othervm stream.Bug6370703
  * @summary Test StAX parser can parse attribute default value when START_ELEMENT.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6370703 {
 
     private static String INPUT_FILE = "sgml.xml";
@@ -63,3 +69,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6378422.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6378422.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,12 +26,18 @@
 import javax.xml.stream.XMLInputFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6378422
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.Bug6378422
+ * @run testng/othervm stream.Bug6378422
  * @summary Test setting reuse-instance property on StAX factory.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6378422 {
 
     @Test
@@ -45,3 +51,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6380870.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6380870.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6380870
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.Bug6380870
+ * @run testng/othervm stream.Bug6380870
  * @summary Test StAX parser can parse VoiceXML DTD.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6380870 {
 
     private static String INPUT_FILE = "basic-form.vxml";
@@ -52,3 +58,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6489502.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6489502.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,12 +30,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6489502
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.Bug6489502
+ * @run testng/othervm stream.Bug6489502
  * @summary Test XMLInputFactory works correctly in case it repeats to create reader.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6489502 {
 
     public java.io.File input;
@@ -77,3 +83,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6509774.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6509774.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,12 +28,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6509774
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.Bug6509774
+ * @run testng/othervm stream.Bug6509774
  * @summary Test Property javax.xml.stream.supportDTD, DTD events are now returned even if supportDTD=false.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6509774 {
 
     @Test
@@ -168,3 +174,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6688002Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6688002Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,12 +34,18 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6688002
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.Bug6688002Test
+ * @run testng/othervm stream.Bug6688002Test
  * @summary Test single instance of XMLOutputFactory/XMLInputFactory create multiple Writer/Readers in parallel.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6688002Test {
 
     private static final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
@@ -107,3 +113,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6976938Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6976938Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,18 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6976938
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.Bug6976938Test
+ * @run testng/othervm stream.Bug6976938Test
  * @summary Test StAX parser won't throw StackOverflowError while reading valid XML file, in case the text content of an XML element contains many lines like "&lt; ... &gt;".
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6976938Test {
 
     private static final String INPUT_FILE = "Bug6976938.xml";
@@ -94,3 +100,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/CoalesceTest/CoalesceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/CoalesceTest/CoalesceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -32,11 +32,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.CoalesceTest.CoalesceTest
+ * @run testng/othervm stream.CoalesceTest.CoalesceTest
  * @summary Test Coalesce property works.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CoalesceTest {
 
     String countryElementContent = "START India  CS}}}}}} India END";
@@ -104,3 +110,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/EntitiesTest/EntityTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EntitiesTest/EntityTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -37,18 +37,24 @@
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.EntitiesTest.EntityTest
+ * @run testng/othervm stream.EntitiesTest.EntityTest
  * @summary Test StAX parses entity.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class EntityTest {
 
     XMLInputFactory factory = null;
     String output = "";
 
     @BeforeMethod
-    protected void setUp() {
+    public void setUp() {
         try {
             factory = XMLInputFactory.newInstance();
         } catch (Exception ex) {
@@ -57,7 +63,7 @@
     }
 
     @AfterMethod
-    protected void tearDown() {
+    public void tearDown() {
         factory = null;
     }
 
@@ -173,3 +179,4 @@
         return true;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventReaderDelegateTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventReaderDelegateTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 package stream;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 
@@ -39,8 +40,13 @@
 import javax.xml.stream.util.EventReaderDelegate;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.EventReaderDelegateTest
+ * @run testng/othervm stream.EventReaderDelegateTest
  * @summary Test EventReaderDelegate.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class EventReaderDelegateTest {
 
     public EventReaderDelegateTest(String name) {
@@ -225,3 +231,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue41Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue41Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,12 +48,18 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6631268
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.EventsTest.Issue41Test
+ * @run testng/othervm stream.EventsTest.Issue41Test
  * @summary Test XMLEvent.writeAsEncodedUnicode can output the event content.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Issue41Test {
 
     public java.io.File input;
@@ -172,3 +178,4 @@
         System.out.println(sw.toString());
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue48Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue48Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,12 +37,18 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6620632
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.EventsTest.Issue48Test
+ * @run testng/othervm stream.EventsTest.Issue48Test
  * @summary Test XMLEventReader can parse notation and entity information from DTD Event.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Issue48Test {
 
     public java.io.File input;
@@ -109,3 +115,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue53Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue53Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,11 +27,17 @@
 import javax.xml.stream.events.StartDocument;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.EventsTest.Issue53Test
+ * @run testng/othervm stream.EventsTest.Issue53Test
  * @summary Test encodingSet/standaloneSet returns correct result in case encoding/standalone is set when constructing StartDocument.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Issue53Test {
 
     @Test
@@ -65,3 +71,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue58Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue58Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,11 +32,17 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.EventsTest.Issue58Test
+ * @run testng/othervm stream.EventsTest.Issue58Test
  * @summary Test XMLEvent.getLocation() returns a non-volatile Location.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Issue58Test {
 
     public java.io.File input;
@@ -78,3 +84,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/FactoryFindTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/FactoryFindTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,9 @@
 
 package stream;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -36,33 +39,38 @@
 import javax.xml.stream.XMLOutputFactory;
 
 import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.FactoryFindTest
+ * @run testng/othervm stream.FactoryFindTest
  * @summary Test SaTX factory using factory property and using ContextClassLoader.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class FactoryFindTest {
 
     boolean myClassLoaderUsed = false;
 
     final static String FACTORY_KEY = "javax.xml.stream.XMLInputFactory";
 
-    @BeforeClass
-    public void setup(){
-        policy.PolicyUtil.changePolicy(getClass().getResource("FactoryFindTest.policy").getFile());
-    }
+//    @BeforeClass
+//    public void setup(){
+//        policy.PolicyUtil.changePolicy(getClass().getResource("FactoryFindTest.policy").getFile());
+//    }
 
-    @Test
+    @Test(enabled=false) // due to 8156508
     public void testFactoryFindUsingStaxProperties() {
         // If property is defined, will take precendence so this test
         // is ignored :(
-        if (System.getProperty(FACTORY_KEY) != null) {
+        if (getSystemProperty(FACTORY_KEY) != null) {
             return;
         }
 
         Properties props = new Properties();
-        String configFile = System.getProperty("java.home") + File.separator + "lib" + File.separator + "stax.properties";
+        String configFile = getSystemProperty("java.home") + File.separator + "lib" + File.separator + "stax.properties";
 
         File f = new File(configFile);
         if (f.exists()) {
@@ -96,17 +104,18 @@
     @Test
     public void testFactoryFind() {
         try {
-            // System.setProperty("jaxp.debug", "true");
+            // setSystemProperty("jaxp.debug", "true");
 
             XMLInputFactory factory = XMLInputFactory.newInstance();
             Assert.assertTrue(factory.getClass().getClassLoader() == null);
 
-            Thread.currentThread().setContextClassLoader(null);
+            runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
             factory = XMLInputFactory.newInstance();
             Assert.assertTrue(factory.getClass().getClassLoader() == null);
 
-            Thread.currentThread().setContextClassLoader(new MyClassLoader());
+            runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(new MyClassLoader()));
             factory = XMLInputFactory.newInstance();
+            // because it's decided by having sm or not in FactoryFind code
             if (System.getSecurityManager() == null)
                 Assert.assertTrue(myClassLoaderUsed);
             else
@@ -115,11 +124,11 @@
             XMLOutputFactory ofactory = XMLOutputFactory.newInstance();
             Assert.assertTrue(ofactory.getClass().getClassLoader() == null);
 
-            Thread.currentThread().setContextClassLoader(null);
+            runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
             ofactory = XMLOutputFactory.newInstance();
             Assert.assertTrue(ofactory.getClass().getClassLoader() == null);
 
-            Thread.currentThread().setContextClassLoader(new MyClassLoader());
+            runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(new MyClassLoader()));
             ofactory = XMLOutputFactory.newInstance();
             if (System.getSecurityManager() == null)
                 Assert.assertTrue(myClassLoaderUsed);
@@ -142,3 +151,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/IgnoreExternalDTDTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/IgnoreExternalDTDTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,17 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.IgnoreExternalDTDTest
+ * @run testng/othervm stream.IgnoreExternalDTDTest
  * @summary Test feature ignore-external-dtd.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class IgnoreExternalDTDTest {
 
     final static String FACTORY_KEY = "javax.xml.stream.XMLInputFactory";
@@ -71,3 +77,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/ProcessingInstructionTest/ProcessingInstructionTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/ProcessingInstructionTest/ProcessingInstructionTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.ProcessingInstructionTest.ProcessingInstructionTest
+ * @run testng/othervm stream.ProcessingInstructionTest.ProcessingInstructionTest
  * @summary Test XMLStreamReader parses Processing Instruction.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class ProcessingInstructionTest {
 
     @Test
@@ -61,3 +67,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/StreamReaderDelegateTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/StreamReaderDelegateTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,11 +38,17 @@
 import javax.xml.stream.util.StreamReaderDelegate;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.StreamReaderDelegateTest
+ * @run testng/othervm stream.StreamReaderDelegateTest
  * @summary Test StreamReaderDelegate.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class StreamReaderDelegateTest {
 
     /**
@@ -377,3 +383,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventLocationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventLocationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,11 +28,17 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventLocationTest
+ * @run testng/othervm stream.XMLEventLocationTest
  * @summary Test XMLEvent Location.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class XMLEventLocationTest {
 
     @Test
@@ -76,3 +82,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6489890.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6489890.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,12 +29,18 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6489890
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.Bug6489890
+ * @run testng/othervm stream.XMLEventReaderTest.Bug6489890
  * @summary Test XMLEventReader's initial state is an undefined state, and nextEvent() is START_DOCUMENT.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6489890 {
 
     @Test
@@ -71,3 +77,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6555001.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6555001.java	Mon Aug 08 12:50:00 2016 +0800
@@ -22,6 +22,7 @@
  */
 package stream.XMLEventReaderTest;
 
+import java.io.FilePermission;
 import java.io.StringReader;
 
 import javax.xml.stream.XMLEventReader;
@@ -29,76 +30,90 @@
 import javax.xml.stream.events.EntityReference;
 import javax.xml.stream.events.XMLEvent;
 
+import jaxp.library.JAXPTestUtilities;
+
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6555001
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.Bug6555001
+ * @run testng/othervm stream.XMLEventReaderTest.Bug6555001
  * @summary Test StAX parser replaces the entity reference as setting.
  */
+@Listeners({ jaxp.library.BasePolicy.class })
 public class Bug6555001 {
-    private static final String XML = "" + "<!DOCTYPE doc SYSTEM 'file:///tmp/this/does/not/exist/but/that/is/ok' [" + "<!ENTITY def '<para/>'>" + "]>"
-            + "<doc>&def;&undef;</doc>";
+    private static final String XML = ""
+            + "<!DOCTYPE doc SYSTEM 'file:///tmp/this/does/not/exist/but/that/is/ok' ["
+            + "<!ENTITY def '<para/>'>" + "]>" + "<doc>&def;&undef;</doc>";
 
     @Test
     public void testReplacing() throws Exception {
-        XMLInputFactory factory = XMLInputFactory.newInstance();
-        factory.setProperty("javax.xml.stream.isReplacingEntityReferences", true);
+        JAXPTestUtilities.tryRunWithTmpPermission(() -> {
+            XMLInputFactory factory = XMLInputFactory.newInstance();
+            factory.setProperty("javax.xml.stream.isReplacingEntityReferences", true);
 
-        StringReader sr = new StringReader(XML);
-        XMLEventReader reader = factory.createXMLEventReader(sr);
+            StringReader sr = new StringReader(XML);
+            XMLEventReader reader = factory.createXMLEventReader(sr);
 
-        boolean sawUndef = false;
-        boolean sawDef = false;
+            boolean sawUndef = false;
+            boolean sawDef = false;
 
-        while (reader.hasNext()) {
-            XMLEvent event = reader.nextEvent();
-            // System.out.println("Event: " + event);
-            if (event.isEntityReference()) {
-                EntityReference ref = (EntityReference) event;
-                if ("def".equals(ref.getName())) {
-                    sawDef = true;
-                } else if ("undef".equals(ref.getName())) {
-                    sawUndef = true;
-                } else {
-                    throw new IllegalArgumentException("Unexpected entity name");
+            while (reader.hasNext()) {
+                XMLEvent event = reader.nextEvent();
+                // System.out.println("Event: " + event);
+                if (event.isEntityReference()) {
+                    EntityReference ref = (EntityReference) event;
+                    if ("def".equals(ref.getName())) {
+                        sawDef = true;
+                    } else if ("undef".equals(ref.getName())) {
+                        sawUndef = true;
+                    } else {
+                        throw new IllegalArgumentException("Unexpected entity name");
+                    }
                 }
             }
-        }
 
-        Assert.assertEquals(false, sawDef);
-        Assert.assertEquals(true, sawUndef);
-        reader.close();
+            Assert.assertEquals(false, sawDef);
+            Assert.assertEquals(true, sawUndef);
+            reader.close();
+        }, new FilePermission("/tmp/this/does/not/exist/but/that/is/ok", "read"));
     }
 
     @Test
     public void testNotReplacing() throws Exception {
-        XMLInputFactory factory = XMLInputFactory.newInstance();
-        factory.setProperty("javax.xml.stream.isReplacingEntityReferences", false);
+        JAXPTestUtilities.tryRunWithTmpPermission(() -> {
+            XMLInputFactory factory = XMLInputFactory.newInstance();
+            factory.setProperty("javax.xml.stream.isReplacingEntityReferences", false);
 
-        StringReader sr = new StringReader(XML);
-        XMLEventReader reader = factory.createXMLEventReader(sr);
+            StringReader sr = new StringReader(XML);
+            XMLEventReader reader = factory.createXMLEventReader(sr);
 
-        boolean sawUndef = false;
-        boolean sawDef = false;
+            boolean sawUndef = false;
+            boolean sawDef = false;
 
-        while (reader.hasNext()) {
-            XMLEvent event = reader.nextEvent();
-            // System.out.println("Event: " + event);
-            if (event.isEntityReference()) {
-                EntityReference ref = (EntityReference) event;
-                if ("def".equals(ref.getName())) {
-                    sawDef = true;
-                } else if ("undef".equals(ref.getName())) {
-                    sawUndef = true;
-                } else {
-                    throw new IllegalArgumentException("Unexpected entity name");
+            while (reader.hasNext()) {
+                XMLEvent event = reader.nextEvent();
+                // System.out.println("Event: " + event);
+                if (event.isEntityReference()) {
+                    EntityReference ref = (EntityReference) event;
+                    if ("def".equals(ref.getName())) {
+                        sawDef = true;
+                    } else if ("undef".equals(ref.getName())) {
+                        sawUndef = true;
+                    } else {
+                        throw new IllegalArgumentException("Unexpected entity name");
+                    }
                 }
             }
-        }
 
-        Assert.assertEquals(true, sawDef);
-        Assert.assertEquals(true, sawUndef);
-        reader.close();
+            Assert.assertEquals(true, sawDef);
+            Assert.assertEquals(true, sawUndef);
+            reader.close();
+        }, new FilePermission("/tmp/this/does/not/exist/but/that/is/ok", "read"));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6586466Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6586466Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,6 +23,7 @@
 
 package stream.XMLEventReaderTest;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 import java.io.ByteArrayInputStream;
@@ -33,9 +34,14 @@
 import javax.xml.stream.events.XMLEvent;
 
 /*
+ * @test
  * @bug 6586466
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.Bug6586466Test
+ * @run testng/othervm stream.XMLEventReaderTest.Bug6586466Test
  * @summary Test XMLEventReader.nextTag() shall update internal event state.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6586466Test {
 
     @Test
@@ -60,3 +66,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6613059Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6613059Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,6 +23,7 @@
 
 package stream.XMLEventReaderTest;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 import javax.xml.namespace.QName;
@@ -33,9 +34,14 @@
 import javax.xml.stream.events.XMLEvent;
 
 /*
+ * @test
  * @bug 6613059
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.Bug6613059Test
+ * @run testng/othervm stream.XMLEventReaderTest.Bug6613059Test
  * @summary Test XMLEventReader.nextTag() shall update internal event state, same as 6586466.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6613059Test {
 
     @Test
@@ -83,3 +89,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6668115Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6668115Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,12 +30,18 @@
 import javax.xml.stream.XMLOutputFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6668115
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.Bug6668115Test
+ * @run testng/othervm stream.XMLEventReaderTest.Bug6668115Test
  * @summary Test XMLEventReader.getElementText() shall update last event even if no peek.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6668115Test {
 
     public java.io.File input;
@@ -94,3 +100,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6846133Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6846133Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -26,12 +26,18 @@
 import javax.xml.stream.XMLStreamException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6846133
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.Bug6846133Test
+ * @run testng/othervm stream.XMLEventReaderTest.Bug6846133Test
  * @summary Test method getDocumentTypeDeclaration() of DTD Event returns a valid value.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6846133Test {
     private static final String xml = "<!DOCTYPE html PUBLIC \"-//W3C//DTDXHTML 1.0 Transitional//EN\" "
             + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + "<html><body><p>I am some simple html</p></body> </html>";
@@ -77,3 +83,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug8153781.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug8153781.java	Mon Aug 08 12:50:00 2016 +0800
@@ -31,15 +31,21 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
 
 /*
+ * @test
  * @bug 8153781
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.Bug8153781
+ * @run testng/othervm stream.XMLEventReaderTest.Bug8153781
  * @summary Test if method skipDTD of class XMLDTDScannerImpl will correctly skip the DTD section,
  *          even if a call to XMLEntityScanner.scanData for skipping to the closing ']' returns true.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug8153781 {
     public static int DOCTYPE_SECTION_LENGTH = XMLEntityManager.DEFAULT_BUFFER_SIZE * 2;
     public static int DOCUMENT_LENGTH = DOCTYPE_SECTION_LENGTH + 4096;
@@ -88,3 +94,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Issue40Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Issue40Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -32,11 +32,17 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventReaderTest.Issue40Test
+ * @run testng/othervm stream.XMLEventReaderTest.Issue40Test
  * @summary Test XMLEventReader.getElementText() works after calling peek().
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Issue40Test {
 
     public java.io.File input;
@@ -94,3 +100,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/ReaderToWriterTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/ReaderToWriterTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -40,11 +40,17 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventWriterTest.ReaderToWriterTest
+ * @run testng/othervm stream.XMLEventWriterTest.ReaderToWriterTest
  * @summary Test XMLEventWriter.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class ReaderToWriterTest {
 
     private static final XMLEventFactory XML_EVENT_FACTORY = XMLEventFactory.newInstance();
@@ -208,3 +214,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/XMLEventWriterTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/XMLEventWriterTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -36,11 +36,17 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLEventWriterTest.XMLEventWriterTest
+ * @run testng/othervm stream.XMLEventWriterTest.XMLEventWriterTest
  * @summary Test XMLEventWriter.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class XMLEventWriterTest {
 
     /**
@@ -150,3 +156,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6756677Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6756677Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,30 +23,42 @@
 
 package stream.XMLInputFactoryTest;
 
+import static jaxp.library.JAXPTestUtilities.runWithTmpPermission;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
+import java.util.PropertyPermission;
+
 import javax.xml.stream.XMLInputFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6756677
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @compile MyInputFactory.java
+ * @run testng/othervm -DrunSecMngr=true stream.XMLInputFactoryTest.Bug6756677Test
+ * @run testng/othervm stream.XMLInputFactoryTest.Bug6756677Test
  * @summary Test XMLInputFactory.newFactory(String factoryId, ClassLoader classLoader).
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6756677Test {
 
     @Test
     public void testNewInstance() {
         String myFactory = "stream.XMLInputFactoryTest.MyInputFactory";
         try {
-            System.setProperty("MyInputFactory", myFactory);
-            XMLInputFactory xif = XMLInputFactory.newInstance("MyInputFactory", null);
+            setSystemProperty("MyInputFactory", myFactory);
+            XMLInputFactory xif = runWithTmpPermission(() -> XMLInputFactory.newInstance("MyInputFactory", null),
+                    new PropertyPermission("MyInputFactory", "read"));
             System.out.println(xif.getClass().getName());
             Assert.assertTrue(xif.getClass().getName().equals(myFactory));
 
         } catch (UnsupportedOperationException oe) {
             Assert.fail(oe.getMessage());
         }
-
     }
 
     // newFactory was added in StAX 1.2
@@ -55,36 +67,22 @@
         String myFactory = "stream.XMLInputFactoryTest.MyInputFactory";
         ClassLoader cl = null;
         try {
-            System.setProperty("MyInputFactory", myFactory);
-            XMLInputFactory xif = XMLInputFactory.newFactory("MyInputFactory", cl);
+            setSystemProperty("MyInputFactory", myFactory);
+            XMLInputFactory xif = runWithTmpPermission(() -> XMLInputFactory.newFactory("MyInputFactory", cl),
+                    new PropertyPermission("MyInputFactory", "read"));
             System.out.println(xif.getClass().getName());
             Assert.assertTrue(xif.getClass().getName().equals(myFactory));
 
         } catch (UnsupportedOperationException oe) {
             Assert.fail(oe.getMessage());
         }
-
     }
 
-    String Temp_Result = "";
-    boolean PASSED = true;
-    boolean FAILED = false;
 
     String XMLInputFactoryClassName = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
     String XMLInputFactoryID = "javax.xml.stream.XMLInputFactory";
     ClassLoader CL = null;
 
-    // jaxp-test jaxp-product-tests javax.xml.jaxp14.ptests.FactoryTest
-    @Test
-    public void test() {
-        if (!test29()) {
-            Assert.fail(Temp_Result);
-        }
-        if (!test31()) {
-            Assert.fail(Temp_Result);
-        }
-    }
-
     /*
      * test for XMLInputFactory.newInstance(java.lang.String factoryClassName,
      * java.lang.ClassLoader classLoader) classloader is null and
@@ -93,27 +91,10 @@
      * XMLInputFactory
      */
     @Test
-    public boolean test29() {
-        try {
-            System.setProperty(XMLInputFactoryID, XMLInputFactoryClassName);
-            XMLInputFactory xif = XMLInputFactory.newInstance(XMLInputFactoryID, CL);
-            if (xif instanceof XMLInputFactory) {
-                System.out.println(" test29() passed");
-                return PASSED;
-            } else {
-                System.out.println(" test29() failed");
-                Temp_Result = "test29() failed: xif not an instance of XMLInputFactory ";
-                return FAILED;
-            }
-        } catch (javax.xml.stream.FactoryConfigurationError fce) {
-            System.out.println("Failed : FactoryConfigurationError in test29 " + fce);
-            Temp_Result = "test29() failed ";
-            return FAILED;
-        } catch (Exception e) {
-            System.out.println("Failed : Exception in test29 " + e);
-            Temp_Result = "test29() failed ";
-            return FAILED;
-        }
+    public void test29() throws Exception {
+        setSystemProperty(XMLInputFactoryID, XMLInputFactoryClassName);
+        XMLInputFactory xif = XMLInputFactory.newInstance(XMLInputFactoryID, CL);
+        Assert.assertTrue(xif instanceof XMLInputFactory, "xif should be an instance of XMLInputFactory");
     }
 
     /*
@@ -124,28 +105,12 @@
      * newInstance of XMLInputFactory
      */
     @Test
-    public boolean test31() {
-        try {
-            Bug6756677Test test3 = new Bug6756677Test();
-            ClassLoader cl = (test3.getClass()).getClassLoader();
-            System.setProperty(XMLInputFactoryID, XMLInputFactoryClassName);
-            XMLInputFactory xif = XMLInputFactory.newInstance(XMLInputFactoryID, cl);
-            if (xif instanceof XMLInputFactory) {
-                System.out.println(" test31() passed");
-                return PASSED;
-            } else {
-                System.out.println(" test31() failed");
-                Temp_Result = "test31() failed: xif not an instance of XMLInputFactory ";
-                return FAILED;
-            }
-        } catch (javax.xml.stream.FactoryConfigurationError fce) {
-            System.out.println("Failed : FactoryConfigurationError in test31 " + fce);
-            Temp_Result = "test31() failed ";
-            return FAILED;
-        } catch (Exception e) {
-            System.out.println("Failed : Exception in test31 " + e);
-            Temp_Result = "test31() failed ";
-            return FAILED;
-        }
+    public void test31() throws Exception {
+        Bug6756677Test test3 = new Bug6756677Test();
+        ClassLoader cl = (test3.getClass()).getClassLoader();
+        setSystemProperty(XMLInputFactoryID, XMLInputFactoryClassName);
+        XMLInputFactory xif = XMLInputFactory.newInstance(XMLInputFactoryID, cl);
+        Assert.assertTrue(xif instanceof XMLInputFactory, "xif should be an instance of XMLInputFactory");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6909759Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6909759Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,12 +29,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6909759
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLInputFactoryTest.Bug6909759Test
+ * @run testng/othervm stream.XMLInputFactoryTest.Bug6909759Test
  * @summary Test createXMLStreamReader with StreamSource.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6909759Test {
 
 
@@ -60,3 +66,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/IssueTracker38.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/IssueTracker38.java	Mon Aug 08 12:50:00 2016 +0800
@@ -31,11 +31,17 @@
 import javax.xml.transform.sax.SAXSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLInputFactoryTest.IssueTracker38
+ * @run testng/othervm stream.XMLInputFactoryTest.IssueTracker38
  * @summary Test createXMLEventReader from DOM or SAX source is unsupported.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class IssueTracker38 {
 
     @Test
@@ -86,3 +92,4 @@
 
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/MyInputFactory.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/MyInputFactory.java	Mon Aug 08 12:50:00 2016 +0800
@@ -158,3 +158,4 @@
         throw new UnsupportedOperationException("Not supported yet.");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/Bug6846132Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/Bug6846132Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,13 +29,19 @@
 import javax.xml.transform.sax.SAXResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6846132
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLOutputFactoryTest.Bug6846132Test
+ * @run testng/othervm stream.XMLOutputFactoryTest.Bug6846132Test
  * @summary Test createXMLStreamWriter with SAXResult won't throw a NullPointerException.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6846132Test {
 
     @Test
@@ -83,3 +89,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/DuplicateNSDeclarationTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/DuplicateNSDeclarationTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -31,11 +31,17 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLOutputFactoryTest.DuplicateNSDeclarationTest
+ * @run testng/othervm stream.XMLOutputFactoryTest.DuplicateNSDeclarationTest
  * @summary Test the writing of duplicate namespace declarations when IS_REPAIRING_NAMESPACES is ture.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class DuplicateNSDeclarationTest {
 
     @Test
@@ -77,3 +83,4 @@
         Assert.assertEquals(EXPECTED_OUTPUT, buffer.toString());
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/StreamResultTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/StreamResultTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,6 +23,8 @@
 
 package stream.XMLOutputFactoryTest;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
 import java.io.ByteArrayOutputStream;
 
 import javax.xml.stream.XMLEventFactory;
@@ -33,11 +35,17 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLOutputFactoryTest.StreamResultTest
+ * @run testng/othervm stream.XMLOutputFactoryTest.StreamResultTest
  * @summary Test create XMLWriter with variant Result.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class StreamResultTest {
 
     @Test
@@ -85,7 +93,7 @@
     @Test
     public void testEventWriterWithStAXResultNStreamWriter() {
         String encoding = "";
-        if (System.getProperty("file.encoding").equals("UTF-8")) {
+        if (getSystemProperty("file.encoding").equals("UTF-8")) {
             encoding = " encoding=\"UTF-8\"";
         }
         final String EXPECTED_OUTPUT = "<?xml version=\"1.0\"" + encoding + "?><root></root>";
@@ -114,7 +122,7 @@
     @Test
     public void testEventWriterWithStAXResultNEventWriter() {
         String encoding = "";
-        if (System.getProperty("file.encoding").equals("UTF-8")) {
+        if (getSystemProperty("file.encoding").equals("UTF-8")) {
             encoding = " encoding=\"UTF-8\"";
         }
         final String EXPECTED_OUTPUT = "<?xml version=\"1.0\"" + encoding + "?><root></root>";
@@ -154,3 +162,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLResolverTest/XMLResolverTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLResolverTest/XMLResolverTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -34,11 +34,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLResolverTest.XMLResolverTest
+ * @run testng/othervm stream.XMLResolverTest.XMLResolverTest
  * @summary Test XMLResolver.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class XMLResolverTest {
 
     @Test
@@ -90,3 +96,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -28,11 +28,17 @@
 import javax.xml.stream.XMLStreamException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamExceptionTest.ExceptionTest
+ * @run testng/othervm stream.XMLStreamExceptionTest.ExceptionTest
  * @summary Test XMLStreamException contains the message of the wrapped exception.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class ExceptionTest {
 
     @Test
@@ -47,3 +53,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481615.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481615.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,12 +30,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6481615
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamFilterTest.Bug6481615
+ * @run testng/othervm stream.XMLStreamFilterTest.Bug6481615
  * @summary Test Filtered XMLStreamReader can return the event type if current state is START_ELEMENT.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6481615 {
 
     static final String XML = "<?xml version=\"1.0\"?>" + "<S:Envelope foo=\"bar\" xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"></S:Envelope>";
@@ -62,3 +68,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481678.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481678.java	Mon Aug 08 12:50:00 2016 +0800
@@ -35,12 +35,18 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6481678
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamFilterTest.Bug6481678
+ * @run testng/othervm stream.XMLStreamFilterTest.Bug6481678
  * @summary Test Filtered XMLStreamReader parses namespace correctly.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6481678 {
 
     String rootElement = "fruits";
@@ -219,3 +225,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,11 +30,17 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamFilterTest.HasNextTest
+ * @run testng/othervm stream.XMLStreamFilterTest.HasNextTest
  * @summary Test Filtered XMLStreamReader hasNext() always return the correct value if repeat to call it.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class HasNextTest {
 
     private static String INPUT_FILE = "HasNextTest.xml";
@@ -139,3 +145,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTypeFilter.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTypeFilter.java	Mon Aug 08 12:50:00 2016 +0800
@@ -47,3 +47,4 @@
         return types[r.getEventType()];
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BOMTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BOMTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -27,12 +27,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6218794
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.BOMTest
+ * @run testng/othervm stream.XMLStreamReaderTest.BOMTest
  * @summary Test XMLStreamReader parses BOM UTF-8 and BOM UTF-16 big endian stream.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class BOMTest {
     // UTF-8 BOM test file
     private static final String INPUT_FILE1 = "UTF8-BOM.xml.data";
@@ -61,3 +67,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6388460.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6388460.java	Mon Aug 08 12:50:00 2016 +0800
@@ -35,13 +35,19 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 6388460
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.Bug6388460
+ * @run testng/othervm stream.XMLStreamReaderTest.Bug6388460
  * @summary Test StAX parser can parse UTF-16 wsdl.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6388460 {
 
     @Test
@@ -70,3 +76,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6472982Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6472982Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,12 +30,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6472982
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.Bug6472982Test
+ * @run testng/othervm stream.XMLStreamReaderTest.Bug6472982Test
  * @summary Test XMLStreamReader.getNamespaceContext().getPrefix("") won't throw IllegalArgumentException.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6472982Test {
     String namespaceURI = "foobar.com";
     String rootElement = "foo";
@@ -73,3 +79,4 @@
         return sbuffer.toString();
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6767322Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6767322Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,12 +29,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6767322
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.Bug6767322Test
+ * @run testng/othervm stream.XMLStreamReaderTest.Bug6767322Test
  * @summary Test XMLStreamReader.getVersion() returns null if a version isn't declared.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6767322Test {
     private static final String INPUT_FILE = "Bug6767322.xml";
 
@@ -70,3 +76,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6847819Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6847819Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,6 +23,7 @@
 
 package stream.XMLStreamReaderTest;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 import java.io.StringReader;
@@ -31,9 +32,14 @@
 import javax.xml.stream.XMLStreamException;
 
 /*
+ * @test
  * @bug 6847819
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.Bug6847819Test
+ * @run testng/othervm stream.XMLStreamReaderTest.Bug6847819Test
  * @summary Test StAX parser shall throw XMLStreamException for illegal xml declaration.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6847819Test {
 
     @Test
@@ -63,3 +69,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,11 +30,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.BugTest
+ * @run testng/othervm stream.XMLStreamReaderTest.BugTest
  * @summary Test StAX parser can parse xml without declaration.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class BugTest {
 
     @Test
@@ -45,3 +51,4 @@
         Assert.assertEquals(XMLStreamConstants.START_DOCUMENT, r.getEventType());
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DefaultAttributeTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DefaultAttributeTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -34,11 +34,17 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.DefaultAttributeTest
+ * @run testng/othervm stream.XMLStreamReaderTest.DefaultAttributeTest
  * @summary Test StAX parses namespace and attribute.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DefaultAttributeTest {
 
     private static final String INPUT_FILE = "ExternalDTD.xml";
@@ -102,3 +108,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DoubleXmlnsTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DoubleXmlnsTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,11 +30,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.DoubleXmlnsTest
+ * @run testng/othervm stream.XMLStreamReaderTest.DoubleXmlnsTest
  * @summary Test double namespaces and nested namespaces.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class DoubleXmlnsTest {
 
     @Test
@@ -112,3 +118,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IsValidatingTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IsValidatingTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -28,12 +28,18 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6440324
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.IsValidatingTest
+ * @run testng/othervm stream.XMLStreamReaderTest.IsValidatingTest
  * @summary Test StAX can accept non-existent DTD if IS_VALIDATING if false.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class IsValidatingTest {
 
     /**
@@ -159,3 +165,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue44Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue44Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -27,12 +27,18 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6631262
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.Issue44Test
+ * @run testng/othervm stream.XMLStreamReaderTest.Issue44Test
  * @summary Test XMLStreamReader.getName() shall throw IllegalStateException if current event is not start/end element.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Issue44Test {
 
     @Test
@@ -53,3 +59,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue47Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue47Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,12 +30,18 @@
 
 import org.testng.Assert;
 import org.testng.AssertJUnit;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6631265
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.Issue47Test
+ * @run testng/othervm stream.XMLStreamReaderTest.Issue47Test
  * @summary Test XMLStreamReader.standaloneSet() presents if input document has a value for "standalone" attribute in xml declaration.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Issue47Test {
 
     @Test
@@ -83,3 +89,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker24.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker24.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,11 +29,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.IssueTracker24
+ * @run testng/othervm stream.XMLStreamReaderTest.IssueTracker24
  * @summary Test no prefix is represented by "", not null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class IssueTracker24 {
 
     @Test
@@ -55,3 +61,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker35.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker35.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,11 +30,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.IssueTracker35
+ * @run testng/othervm stream.XMLStreamReaderTest.IssueTracker35
  * @summary Test StAX parse xsd document including external DTD.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class IssueTracker35 {
 
     @Test
@@ -53,3 +59,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker70.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker70.java	Mon Aug 08 12:50:00 2016 +0800
@@ -31,11 +31,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.IssueTracker70
+ * @run testng/othervm stream.XMLStreamReaderTest.IssueTracker70
  * @summary Test it can retrieve attribute with null or empty name space.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class IssueTracker70 {
 
     static private final File testFile = new File(IssueTracker70.class.getResource("IssueTracker70.xml").getFile());
@@ -70,3 +76,4 @@
         Assert.assertNotNull(value, "should have attribute value");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req5Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req5Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -28,11 +28,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.Jsr173MR1Req5Test
+ * @run testng/othervm stream.XMLStreamReaderTest.Jsr173MR1Req5Test
  * @summary Test XMLStreamReader parses namespace declaration within element when NamespaceAware turns off and on.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Jsr173MR1Req5Test {
 
     private static final String INPUT_FILE1 = "Jsr173MR1Req5.xml";
@@ -85,3 +91,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req8Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req8Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -28,11 +28,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.Jsr173MR1Req8Test
+ * @run testng/othervm stream.XMLStreamReaderTest.Jsr173MR1Req8Test
  * @summary Test XMLStreamReader parses attribute with namespace aware.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Jsr173MR1Req8Test {
 
     private static final String INPUT_FILE1 = "Jsr173MR1Req8.xml";
@@ -63,3 +69,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/NamespaceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/NamespaceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -32,11 +32,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.NamespaceTest
+ * @run testng/othervm stream.XMLStreamReaderTest.NamespaceTest
  * @summary Test StAX parser processes namespace.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class NamespaceTest {
 
     String namespaceURI = "foobar.com";
@@ -147,3 +153,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/StreamReaderTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/StreamReaderTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -28,11 +28,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.StreamReaderTest
+ * @run testng/othervm stream.XMLStreamReaderTest.StreamReaderTest
  * @summary Test XMLStreamReader.hasName() returns false for ENTITY_REFERENCE.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class StreamReaderTest {
 
     /**
@@ -56,3 +62,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/SupportDTDTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/SupportDTDTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -38,9 +38,14 @@
 import javax.xml.stream.events.XMLEvent;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.SupportDTDTest
+ * @run testng/othervm stream.XMLStreamReaderTest.SupportDTDTest
  * @summary Test SUPPORT_DTD and IS_REPLACING_ENTITY_REFERENCES.
  */
 
@@ -72,6 +77,7 @@
 *       The current jaxp implementation actually throws a nullpointexception. A better error message could be used.
 *
 */
+@Listeners({jaxp.library.FilePolicy.class})
 public class SupportDTDTest {
     final boolean DEBUG = false;
     final String _file = "ExternalDTD.xml";
@@ -282,3 +288,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/VoiceXMLDTDTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/VoiceXMLDTDTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -27,11 +27,17 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.VoiceXMLDTDTest
+ * @run testng/othervm stream.XMLStreamReaderTest.VoiceXMLDTDTest
  * @summary Test parsing Voice XML DTD.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class VoiceXMLDTDTest {
 
     private static final String INPUT_FILE1 = "voicexml.xml";
@@ -52,3 +58,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/XML11Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/XML11Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -27,11 +27,17 @@
 import javax.xml.stream.XMLInputFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.XML11Test
+ * @run testng/othervm stream.XMLStreamReaderTest.XML11Test
  * @summary Test parsing xml 1.1.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class XML11Test {
 
     @Test
@@ -48,3 +54,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/AttributeEscapeTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/AttributeEscapeTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -34,13 +34,19 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.AttributeEscapeTest
+ * @run testng/othervm stream.XMLStreamWriterTest.AttributeEscapeTest
  * @summary Test XMLStreamWriter shall escape the illegal characters.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class AttributeEscapeTest {
 
     /**
@@ -97,3 +103,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6452107.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6452107.java	Mon Aug 08 12:50:00 2016 +0800
@@ -31,12 +31,18 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6452107
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.Bug6452107
+ * @run testng/othervm stream.XMLStreamWriterTest.Bug6452107
  * @summary Test StAX can write ISO-8859-1 encoding XML.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6452107 {
 
     /**
@@ -58,3 +64,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6600882Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6600882Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,12 +29,18 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6600882
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.Bug6600882Test
+ * @run testng/othervm stream.XMLStreamWriterTest.Bug6600882Test
  * @summary Test toString(), hashCode() of XMLStreamWriter .
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6600882Test {
 
 
@@ -53,3 +59,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6675332Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6675332Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,14 +30,20 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 import util.BaseStAXUT;
 
 /*
+ * @test
  * @bug 6675332
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.Bug6675332Test
+ * @run testng/othervm stream.XMLStreamWriterTest.Bug6675332Test
  * @summary Test XMLStreamWriter writeAttribute when IS_REPAIRING_NAMESPACES is true.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6675332Test extends BaseStAXUT {
 
     private static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance();
@@ -158,3 +164,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug7037352Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug7037352Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,12 +30,18 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 7037352
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.Bug7037352Test
+ * @run testng/othervm stream.XMLStreamWriterTest.Bug7037352Test
  * @summary Test XMLStreamWriter.getNamespaceContext().getPrefix with XML_NS_URI and XMLNS_ATTRIBUTE_NS_URI.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug7037352Test {
 
     @Test
@@ -59,3 +65,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DOMUtil.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DOMUtil.java	Mon Aug 08 12:50:00 2016 +0800
@@ -221,3 +221,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DomUtilTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DomUtilTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -41,18 +41,23 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.DomUtilTest
+ * @run testng/othervm stream.XMLStreamWriterTest.DomUtilTest
  * @summary Test XMLStreamWriter writes a soap message.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DomUtilTest {
 
     private XMLOutputFactory staxOut;
-    final File folder = new File(System.getProperty("tempdir") + "/classes/soapmessages");
     private static final String INPUT_FILE1 = "message_12.xml";
 
     public void setup() {
@@ -119,3 +124,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EmptyElementTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EmptyElementTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,11 +29,17 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.EmptyElementTest
+ * @run testng/othervm stream.XMLStreamWriterTest.EmptyElementTest
  * @summary Test XMLStreamWriter writes namespace and attribute after writeEmptyElement.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class EmptyElementTest {
 
     // expected output
@@ -79,3 +85,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EncodingTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EncodingTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,11 +29,17 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.EncodingTest
+ * @run testng/othervm stream.XMLStreamWriterTest.EncodingTest
  * @summary Test XMLStreamWriter writes a document with encoding setting.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class EncodingTest {
 
     private static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance();
@@ -104,3 +110,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NamespaceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NamespaceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,11 +32,17 @@
 
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.NamespaceTest
+ * @run testng/othervm stream.XMLStreamWriterTest.NamespaceTest
  * @summary Test the writing of Namespaces.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class NamespaceTest {
 
     /** debug output? */
@@ -1428,3 +1434,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NullUriDetectionTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NullUriDetectionTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -28,12 +28,18 @@
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6391922
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.NullUriDetectionTest
+ * @run testng/othervm stream.XMLStreamWriterTest.NullUriDetectionTest
  * @summary Test XMLStreamWriter can writeDefaultNamespace(null).
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class NullUriDetectionTest {
     @Test
     public void test1() throws Exception {
@@ -48,3 +54,4 @@
         w.writeCharacters("---");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SqeLinuxTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SqeLinuxTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,11 +29,17 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.SqeLinuxTest
+ * @run testng/othervm stream.XMLStreamWriterTest.SqeLinuxTest
  * @summary Test XMLStreamWriter can output multiple declarations if IS_REPAIRING_NAMESPACES is false.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class SqeLinuxTest {
 
     // note that expected output will have multiple declarations,
@@ -82,3 +88,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SurrogatesTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SurrogatesTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -38,6 +38,7 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.annotations.DataProvider;
 
@@ -45,10 +46,15 @@
  * @test
  * @bug 8145974
  * @modules javax.xml
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.SurrogatesTest
+ * @run testng/othervm stream.XMLStreamWriterTest.SurrogatesTest
  * @summary Check that XMLStreamWriter generates valid xml with surrogate pair
  *  used within element text
  */
 
+@Listeners({jaxp.library.BasePolicy.class})
 public class SurrogatesTest {
 
     // Test that valid surrogate characters can be written/readen by xml stream
@@ -152,7 +158,7 @@
     }
 
     @DataProvider(name = "validData")
-    Object[][] getValidData() {
+    public Object[][] getValidData() {
         return new Object[][] {
             {"Don't Worry Be \uD83D\uDE0A"},
             {"BMP characters \uE000\uFFFD"},
@@ -161,7 +167,7 @@
     }
 
     @DataProvider(name = "invalidData")
-    Object[][] getInvalidData() {
+    public Object[][] getInvalidData() {
         return new Object[][] {
             {"Unbalanced surrogate \uD83D"},
             {"Unbalanced surrogate \uD83Dis here"},
@@ -169,3 +175,4 @@
         };
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/UnprefixedNameTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/UnprefixedNameTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -28,12 +28,18 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6394074
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.UnprefixedNameTest
+ * @run testng/othervm stream.XMLStreamWriterTest.UnprefixedNameTest
  * @summary Test XMLStreamWriter namespace prefix with writeDefaultNamespace.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class UnprefixedNameTest {
 
     @Test
@@ -119,3 +125,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/WriterTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/WriterTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -40,11 +40,17 @@
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.WriterTest
+ * @run testng/othervm stream.XMLStreamWriterTest.WriterTest
  * @summary Test XMLStreamWriter functionality.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class WriterTest {
 
     final String ENCODING = "UTF-8";
@@ -57,7 +63,7 @@
     String output = "";
 
     @BeforeMethod
-    protected void setUp() {
+    public void setUp() {
         try {
             outputFactory = XMLOutputFactory.newInstance();
             inputFactory = XMLInputFactory.newInstance();
@@ -67,7 +73,7 @@
     }
 
     @AfterMethod
-    protected void tearDown() {
+    public void tearDown() {
         outputFactory = null;
         inputFactory = null;
     }
@@ -778,3 +784,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,24 +29,20 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6347190
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.XMLStreamWriterTest
+ * @run testng/othervm stream.XMLStreamWriterTest.XMLStreamWriterTest
  * @summary Test StAX Writer won't insert comment into element inside.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class XMLStreamWriterTest {
 
-    @BeforeMethod
-    protected void setUp() throws Exception {
-    }
-
-    @AfterMethod
-    protected void tearDown() throws Exception {
-    }
-
     /**
      * Test of main method, of class TestXMLStreamWriter.
      */
@@ -77,3 +73,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4693341Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4693341Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -37,14 +37,20 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4693341
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug4693341Test
+ * @run testng/othervm transform.Bug4693341Test
  * @summary Test transform with external dtd.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4693341Test {
     // save dtd file to current working directory to avoid writing into source repository
     public void copyDTDtoWorkDir() throws IOException {
@@ -88,3 +94,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4892774.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4892774.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 import transform.util.DOMUtil;
@@ -44,10 +45,15 @@
 import transform.util.StreamUtil;
 
 /*
+ * @test
  * @bug 4892774
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug4892774
+ * @run testng/othervm transform.Bug4892774
  * @summary Test identity transformer with all possible types of Source and Result combinations for doucment version and encoding information.
  */
 
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4892774 {
 
     private final String XML_FILE = "catalog.xml";
@@ -62,7 +68,7 @@
     private static StAXUtil staxUtil = null;
 
     @BeforeMethod
-    protected void setUp() {
+    public void setUp() {
         File tmpFile = new File(TEMP_FILE);
         if (tmpFile.exists())
             tmpFile.delete();
@@ -81,7 +87,7 @@
     }
 
     @AfterMethod
-    protected void tearDown() {
+    public void tearDown() {
         File tmpFile = new File(TEMP_FILE);
         if (tmpFile.exists())
             tmpFile.delete();
@@ -371,3 +377,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug5073477.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug5073477.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,19 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.dom.DOMResult;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
 /*
+ * @test
  * @bug 5073477
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug5073477
+ * @run testng/othervm transform.Bug5073477
  * @summary Test DOMResult.setNextSibling works correctly.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug5073477 {
 
     @Test
@@ -49,3 +55,4 @@
         r.setNextSibling(r.getNode().getFirstChild());
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6175602.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6175602.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,12 +29,18 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamSource;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6175602
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6175602
+ * @run testng/othervm transform.Bug6175602
  * @summary Test compilation of MsWordXMLImport.xsl.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6175602 {
 
     public Bug6175602() {
@@ -48,3 +54,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6206491.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6206491.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,15 +39,21 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 6206491
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6206491
+ * @run testng/othervm transform.Bug6206491
  * @summary Test key searches over more than one document.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6206491 {
 
     private String getResource(String s) {
@@ -128,3 +134,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6216226Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6216226Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,11 @@
 
 package transform;
 
+import static jaxp.library.JAXPTestUtilities.runWithTmpPermission;
+
 import java.io.File;
 import java.io.StringReader;
+import java.util.PropertyPermission;
 
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
@@ -32,12 +35,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6216226
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6216226Test
+ * @run testng/othervm transform.Bug6216226Test
  * @summary Test StreamResult(File) is closed after transform().
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6216226Test {
 
     @Test
@@ -48,7 +57,7 @@
             Transformer xformer = tf.newTransformer();
             StringReader st = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?><doc></doc>");
             StreamSource s = new StreamSource(st);
-            StreamResult r = new StreamResult(test);
+            StreamResult r = runWithTmpPermission(() -> new StreamResult(test), new PropertyPermission("user.dir", "read"));
             xformer.transform(s, r);
             if (!test.delete()) {
                 Assert.fail("cannot delete file: " + test.getPath());
@@ -60,3 +69,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6311448.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6311448.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,14 +33,20 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /*
+ * @test
  * @bug 6311448
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6311448
+ * @run testng/othervm transform.Bug6311448
  * @summary Test XML transformer can output Unicode surrorate pair.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6311448 {
 
     @Test
@@ -79,3 +85,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6384805.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6384805.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,12 +35,18 @@
 import javax.xml.xpath.XPathFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6384805
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6384805
+ * @run testng/othervm transform.Bug6384805
  * @summary Test XSLTC can parse XML namespace when nodeset is created within a template.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6384805 {
 
     @Test
@@ -88,3 +94,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6465722.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6465722.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,13 +34,19 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
 /*
+ * @test
  * @bug 6465722
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6465722
+ * @run testng/othervm transform.Bug6465722
  * @summary Test Transformer can transform the node attribute prefixed with a namespace.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6465722 {
 
     public Bug6465722(String name) {
@@ -66,3 +72,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6467808.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6467808.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,12 +33,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6467808
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6467808
+ * @run testng/othervm transform.Bug6467808
  * @summary Test Transformer can parse re-declare prefixed namespace mappings.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6467808 {
 
     private static final String TESTXML = "<?xml version='1.0' ?>\n"
@@ -70,3 +76,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490380.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490380.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,12 +32,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6490380
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6490380
+ * @run testng/othervm transform.Bug6490380
  * @summary Test only a single DOCTYPE declaration is generated through transforming.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6490380 {
 
     @Test
@@ -55,3 +61,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490921.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490921.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 
 package transform;
 
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
+
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
@@ -37,15 +39,21 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.XMLFilterImpl;
 
 /*
+ * @test
  * @bug 6490921
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6490921
+ * @run testng/othervm transform.Bug6490921
  * @summary Test property org.xml.sax.driver is always applied in transformer API.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6490921 {
 
     public static class ReaderStub extends XMLFilterImpl {
@@ -71,7 +79,7 @@
     public void test01() {
         String xml = "<?xml version='1.0'?><root/>";
         ReaderStub.used = false;
-        System.setProperty("org.xml.sax.driver", "");
+        setSystemProperty("org.xml.sax.driver", "");
 
         // Don't set 'org.xml.sax.driver' here, just use default
         try {
@@ -91,7 +99,7 @@
     public void test02() {
         String xml = "<?xml version='1.0'?><root/>";
         ReaderStub.used = false;
-        System.setProperty("org.xml.sax.driver", ReaderStub.class.getName());
+        setSystemProperty("org.xml.sax.driver", ReaderStub.class.getName());
         try {
             TransformerFactory transFactory = TransformerFactory.newInstance();
             Transformer transformer = transFactory.newTransformer();
@@ -111,7 +119,7 @@
                 + "   <xsl:template match='/'>Hello World!</xsl:template>\n" + "</xsl:stylesheet>\n";
 
         ReaderStub.used = false;
-        System.setProperty("org.xml.sax.driver", ReaderStub.class.getName());
+        setSystemProperty("org.xml.sax.driver", ReaderStub.class.getName());
         try {
             TransformerFactory transFactory = TransformerFactory.newInstance();
             if (transFactory.getFeature(SAXTransformerFactory.FEATURE) == false) {
@@ -137,3 +145,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6513892.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6513892.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,13 +34,19 @@
 
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
 /*
+ * @test
  * @bug 6513892
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6513892
+ * @run testng/othervm transform.Bug6513892
  * @summary Test the output encoding of the transform is the same as that of the redirect extension.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6513892 {
     @BeforeClass
     public void setup(){
@@ -71,3 +77,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6537167.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6537167.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,12 +32,18 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6537167
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6537167
+ * @run testng/othervm transform.Bug6537167
  * @summary Test transforming for particular xsl files.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6537167 {
 
     @Test
@@ -79,3 +85,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6540545.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6540545.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6540545
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6540545
+ * @run testng/othervm transform.Bug6540545
  * @summary Test XSLT as expected.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6540545 {
 
     @Test
@@ -58,3 +64,4 @@
     }
 
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6551616.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6551616
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6551616
+ * @run testng/othervm transform.Bug6551616
+ * @summary Test SAX2StAXEventWriter.
+ */
+
+package transform;
+
+import java.io.InputStream;
+import java.io.StringBufferInputStream;
+
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+import com.sun.org.apache.xalan.internal.xsltc.trax.SAX2StAXEventWriter;
+
+@Listeners({jaxp.library.InternalAPIPolicy.class})
+public class Bug6551616 {
+    String _cache = "";
+
+
+    @Test
+    public void test() throws Exception {
+        final String XML = "" + "<?xml version='1.0'?>" + "<doc xmlns:foo='http://example.com/foo/' xml:lang='us-en'><p>Test</p></doc>";
+
+        javax.xml.parsers.SAXParserFactory saxFactory = javax.xml.parsers.SAXParserFactory.newInstance();
+
+        javax.xml.parsers.SAXParser parser = saxFactory.newSAXParser();
+
+        XMLOutputFactory outFactory = XMLOutputFactory.newInstance();
+        XMLEventWriter writer = outFactory.createXMLEventWriter(System.out);
+
+        SAX2StAXEventWriter handler = new SAX2StAXEventWriter(writer);
+
+        InputStream is = new StringBufferInputStream(XML);
+
+        parser.parse(is, handler);
+
+        // if it doesn't blow up, it succeeded.
+    }
+}
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6559595.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6559595.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,12 +35,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6559595
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6559595
+ * @run testng/othervm transform.Bug6559595
  * @summary Test ampersand in href attribute is not handled specially even if output is set to HTML.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6559595 {
 
     @Test
@@ -64,3 +70,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6565260.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6565260.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6565260
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6565260
+ * @run testng/othervm transform.Bug6565260
  * @summary Test use-attribute-sets attribute is not used for the root node.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6565260 {
 
     @Test
@@ -58,3 +64,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6940416.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6940416.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,12 +39,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6940416
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Bug6940416
+ * @run testng/othervm transform.Bug6940416
  * @summary Test transforming correctly.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6940416 {
 
     @Test
@@ -109,3 +115,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/BugDB12665704Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/BugDB12665704Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,12 +43,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6935697
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.BugDB12665704Test
+ * @run testng/othervm transform.BugDB12665704Test
  * @summary Test Transformer can compile large xsl file.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class BugDB12665704Test {
 
     @Test
@@ -151,3 +157,4 @@
         return sb.toString();
     }
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CLITest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CLITest
+ * @run testng/othervm transform.CLITest
+ * @summary Test internal transform CLI.
+ */
+
+package transform;
+
+import java.util.PropertyPermission;
+
+import jaxp.library.JAXPTestUtilities;
+
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+@Listeners({ jaxp.library.FilePolicy.class })
+public class CLITest {
+
+    @Test
+    public void testCLI() throws Exception {
+        JAXPTestUtilities.tryRunWithTmpPermission(() -> {
+            String[] args = new String[] { "-XSLTC", "-XSL", getClass().getResource("tigertest.xsl").toString(),
+                "-IN", getClass().getResource("tigertest-in.xml").toString(), };
+            ProcessXSLT.main(args);
+        }, new PropertyPermission("*", "read,write"));
+    }
+}
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6401137Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6401137Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,12 +37,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6401137
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6401137Test
+ * @run testng/othervm transform.CR6401137Test
  * @summary Test transform certain xsl.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6401137Test {
 
     @Test
@@ -88,3 +94,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600.policy	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-grant {
-	permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
-	permission java.lang.RuntimePermission "accessDeclaredMembers";
-	
-	permission java.io.FilePermission "${test.classes}/../../-", "read, write, delete";
-	permission java.io.FilePermission ".", "read, write, delete";
-	permission java.util.PropertyPermission "*", "read, write";
-	
-    permission java.lang.RuntimePermission "setSecurityManager";
-    permission java.lang.RuntimePermission "createSecurityManager";
-    permission java.lang.RuntimePermission "createClassLoader";
-    permission java.lang.RuntimePermission "setIO";
-	permission java.lang.RuntimePermission "setContextClassLoader"; 
-	permission java.security.SecurityPermission "getPolicy";
-    
-    permission java.io.FilePermission "${test.src}/-", "read, write, delete";
-    permission java.io.FilePermission "${user.dir}/-", "read, write, delete";
-    permission java.io.FilePermission "${java.io.tmpdir}/-", "read, write, delete";
-    
-    permission java.io.FilePermission "//localhost/C$/xslt_unc_test.xml", "read, write, delete";
-    
-};
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,10 @@
 
 package transform;
 
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
 import java.io.File;
+import java.io.FilePermission;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -32,57 +35,63 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import jaxp.library.JAXPTestUtilities;
+
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /*
+ * @test
  * @bug 6551600
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6551600Test
+ * @run testng/othervm transform.CR6551600Test
  * @summary Test using UNC path as StreamResult.
  */
+@Listeners({ jaxp.library.BasePolicy.class })
 public class CR6551600Test {
 
     @Test
     public final void testUNCPath() {
-        String hostName = "";
-        try {
-            hostName = java.net.InetAddress.getLocalHost().getHostName();
-        } catch (java.net.UnknownHostException e) {
-            // falls through
-        }
+        boolean isWindows = getSystemProperty("os.name").contains("Windows");
+        JAXPTestUtilities.runWithTmpPermission(() -> {
+            String hostName = "";
+            try {
+                hostName = java.net.InetAddress.getLocalHost().getHostName();
+            } catch (java.net.UnknownHostException e) {
+                // falls through
+            }
 
-        String path = "\\\\" + hostName + "\\C$\\xslt_unc_test.xml";
-        String os = System.getProperty("os.name");
-        if (os.indexOf("Windows") < 0) {
-            path = "///tmp/test.xml";
-        }
-        else {
-                policy.PolicyUtil.changePolicy(getClass().getResource("CR6551600.policy").getFile());
-        }
+            String path = isWindows ? "\\\\" + hostName + "\\C$\\xslt_unc_test.xml" : "///tmp/test.xml";
 
-        try {
-            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-            DocumentBuilder builder = factory.newDocumentBuilder();
-            Document doc = builder.newDocument();
-            Element root = doc.createElement("test");
-            doc.appendChild(root);
-            // create an identity transform
-            Transformer t = TransformerFactory.newInstance().newTransformer();
-            File f = new File(path);
-            StreamResult result = new StreamResult(f);
-            DOMSource source = new DOMSource(doc);
-            System.out.println("Writing to " + f);
-            t.transform(source, result);
-        } catch (Exception e) {
-            // unexpected failure
-            e.printStackTrace();
-            Assert.fail(e.toString());
-        }
+            try {
+                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+                DocumentBuilder builder = factory.newDocumentBuilder();
+                Document doc = builder.newDocument();
+                Element root = doc.createElement("test");
+                doc.appendChild(root);
+                // create an identity transform
+                Transformer t = TransformerFactory.newInstance().newTransformer();
+                File f = new File(path);
+                StreamResult result = new StreamResult(f);
+                DOMSource source = new DOMSource(doc);
+                System.out.println("Writing to " + f);
+                t.transform(source, result);
+            } catch (Exception e) {
+                // unexpected failure
+                e.printStackTrace();
+                Assert.fail(e.toString());
+            }
 
-        File file = new File(path);
-        if (file.exists()) {
-            file.deleteOnExit();
-        }
+            File file = new File(path);
+            if (file.exists()) {
+                file.deleteOnExit();
+            }
+        }, isWindows ? new FilePermission("//localhost/C$/xslt_unc_test.xml", "read,write,delete")
+                : new FilePermission("///tmp/test.xml", "read,write,delete"));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6577667Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6577667Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,12 +30,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6577667
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6577667Test
+ * @run testng/othervm transform.CR6577667Test
  * @summary Test XSLT can parse statement "not(preceding-sibling::* or following-sibling::*)" in stylesheet file.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6577667Test {
 
     @Test
@@ -53,3 +59,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6652519Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6652519Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,13 +33,19 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
 /*
+ * @test
  * @bug 6652519
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6652519Test
+ * @run testng/othervm transform.CR6652519Test
  * @summary Test transfoming from StreamSource to DOMResult.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6652519Test {
 
     @Test
@@ -73,3 +79,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6689809Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6689809Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,12 +30,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6689809
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6689809Test
+ * @run testng/othervm transform.CR6689809Test
  * @summary Test Transformer can handle XPath predicates in xsl:key elements.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6689809Test {
 
     @Test
@@ -58,3 +64,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6905829Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6905829Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,12 +32,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6905829
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6905829Test
+ * @run testng/othervm transform.CR6905829Test
  * @summary Test XSLT can parse certain xsl.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6905829Test {
 
     @Test
@@ -59,3 +65,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6935697Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6935697Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,12 +34,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6935697
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6935697Test
+ * @run testng/othervm transform.CR6935697Test
  * @summary Test XSLT can parse the certain xsl.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6935697Test {
 
     @Test
@@ -71,3 +77,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6941869Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6941869Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,12 +32,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6941869
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6941869Test
+ * @run testng/othervm transform.CR6941869Test
  * @summary Test XSLT evaluate "count(.|key('props', d/e)[1])" correctly.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6941869Test {
 
     @Test
@@ -70,3 +76,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6957215Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6957215Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,12 +39,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6957215
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR6957215Test
+ * @run testng/othervm transform.CR6957215Test
  * @summary Test XSLT generates the element content using xsl:attribute instructions.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6957215Test {
 
     @Test
@@ -93,3 +99,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR7098746Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR7098746Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,12 +34,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 7098746
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.CR7098746Test
+ * @run testng/othervm transform.CR7098746Test
  * @summary Test transforming as expected.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR7098746Test {
 
     @Test
@@ -84,3 +90,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/DOMResultTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/DOMResultTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 package transform;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 
@@ -46,8 +47,13 @@
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.DOMResultTest
+ * @run testng/othervm transform.DOMResultTest
  * @summary Test DOMResult.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class DOMResultTest {
 
     @Test
@@ -209,3 +215,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/DocumentExtFunc.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/DocumentExtFunc.java	Mon Aug 08 12:50:00 2016 +0800
@@ -33,3 +33,4 @@
         return "["+node.getNodeName() + ":" + node.getTextContent()+"]";
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/FactoryFindTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/FactoryFindTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,43 +23,44 @@
 
 package transform;
 
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+
 import java.net.URL;
 import java.net.URLClassLoader;
 
 import javax.xml.transform.TransformerFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.FactoryFindTest
+ * @run testng/othervm transform.FactoryFindTest
  * @summary Test creating TransformerFactory with ContextClassLoader.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class FactoryFindTest {
 
     boolean myClassLoaderUsed = false;
 
     @Test
-    public void testFactoryFind() {
-        try {
-            // System.setProperty("jaxp.debug", "true");
-
-            TransformerFactory factory = TransformerFactory.newInstance();
-            Assert.assertTrue(factory.getClass().getClassLoader() == null);
-
-            Thread.currentThread().setContextClassLoader(null);
-            factory = TransformerFactory.newInstance();
-            Assert.assertTrue(factory.getClass().getClassLoader() == null);
+    public void testFactoryFind() throws Exception {
+        TransformerFactory factory = TransformerFactory.newInstance();
+        Assert.assertTrue(factory.getClass().getClassLoader() == null);
 
-            Thread.currentThread().setContextClassLoader(new MyClassLoader());
-            factory = TransformerFactory.newInstance();
-            if (System.getSecurityManager() == null)
-                Assert.assertTrue(myClassLoaderUsed);
-            else
-                Assert.assertFalse(myClassLoaderUsed);
-        } catch (Exception ex) {
-            Assert.fail(ex.toString());
-        }
+        runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
+        factory = TransformerFactory.newInstance();
+        Assert.assertTrue(factory.getClass().getClassLoader() == null);
 
+        runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(new MyClassLoader()));
+        factory = TransformerFactory.newInstance();
+        if (System.getSecurityManager() == null)
+            Assert.assertTrue(myClassLoaderUsed);
+        else
+            Assert.assertFalse(myClassLoaderUsed);
     }
 
     class MyClassLoader extends URLClassLoader {
@@ -74,3 +75,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2204Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2204Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,18 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6905829
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Issue2204Test
+ * @run testng/othervm transform.Issue2204Test
  * @summary Test XSLT can work against the certain xsl.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Issue2204Test {
 
     @Test
@@ -61,3 +67,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2290Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2290Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,11 +41,17 @@
 import org.w3c.dom.DocumentFragment;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.Issue2290Test
+ * @run testng/othervm transform.Issue2290Test
  * @summary Test XSL extension for RTF works, for https://issues.apache.org/jira/i#browse/XALANJ-2290.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Issue2290Test {
 
     @Test
@@ -90,3 +96,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/OpenJDK100017Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/OpenJDK100017Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,13 +32,19 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6883209
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.OpenJDK100017Test
+ * @run testng/othervm transform.OpenJDK100017Test
  * @summary Test XSLT won't cause StackOverflow when it handle many characters.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class OpenJDK100017Test {
 
     @Test
@@ -60,3 +66,4 @@
         }
     }
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/ProcessXSLT.java	Mon Aug 08 12:50:00 2016 +0800
@@ -0,0 +1,917 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id: Process.java,v 1.2.4.2 2005/09/15 18:21:57 jeffsuttor Exp $
+ */
+
+// This file is a copied and modified version of
+// com/sun/org/apache/xalan/internal/xslt/Process.java
+// which has been modified to only use public exported APIs.
+// The only adherence is with
+// com.sun.org.apache.xml.internal.utils.DefaultErrorHandler
+// which we try to instantiate using reflection, as that class
+// can do a better job at reporting error location.
+// We however don't have a hard dependency on it. We will use
+// our own ErrorHandler if the default one is not accessible.
+//
+
+package transform;
+
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.SourceLocator;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * The main() method handles the Xalan command-line interface.
+ */
+public class ProcessXSLT
+{
+
+    /**
+     * Prints argument options.
+     *
+     */
+    protected static void printArgOptions() {
+        System.out.println("xslproc options: ");
+        System.out.println("\n\t\t\t" + "-Common Options-" + "\n");
+        System.out.println("   [-XSLTC (use XSLTC for transformation)]");  //"    [-XSLTC (use XSLTC for transformation)]
+        System.out.println("   [-IN inputXMLURL]");  //"    [-IN inputXMLURL]");
+        System.out.println("   [-XSL XSLTransformationURL]");  //"   [-XSL XSLTransformationURL]");
+        System.out.println("   [-OUT outputFileName]");  //"   [-OUT outputFileName]");
+
+        System.out.println("   [-E (Do not expand entity refs)]");  //"   [-V (Version info)]");
+
+        System.out.println("   [-EDUMP {optional filename} (Do stackdump on error.)]");  //"   [-EDUMP {optional filename} (Do stackdump on error.)]");
+        System.out.println("   [-XML (Use XML formatter and add XML header.)]");  //"   [-XML (Use XML formatter and add XML header.)]");
+        System.out.println("   [-TEXT (Use simple Text formatter.)]");  //"   [-TEXT (Use simple Text formatter.)]");
+        System.out.println("   [-HTML (Use HTML formatter.)]");  //"   [-HTML (Use HTML formatter.)]");
+        System.out.println( "   [-PARAM name expression (Set a stylesheet parameter)]");  //"   [-PARAM name expression (Set a stylesheet parameter)]");
+
+        System.out.println("   [-MEDIA mediaType (use media attribute to find stylesheet associated with a document.)]");
+        System.out.println("   [-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform.)] ");
+        System.out.println("   [-DIAG (Print overall milliseconds transform took.)]");
+        System.out.println("   [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]");  //"   [-URIRESOLVER full class name (URIResolver to be used to resolve URIs)]");
+        System.out.println("   [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]");  //"   [-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)]");
+        waitForReturnKey();
+        System.out.println("   [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]");  //"   [-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)]");
+        System.out.println("   [-SECURE (set the secure processing feature to true.)]"); //"   [-SECURE (set the secure processing feature to true)]");
+
+
+        System.out.println("\n\t\t\t"+  "-Options for XSLTC-" + "\n");
+        System.out.println("   [-XO [transletName] (assign the name to the generated translet)]");
+        waitForReturnKey();
+        System.out.println("   [-XD destinationDirectory (specify a destination directory for translet)]");
+        System.out.println("   [-XJ jarfile (packages translet classes into a jar file of name <jarfile>)]");
+        System.out.println("   [-XP package (specifies a package name prefix for all generated translet classes)]");
+        System.out.println("   [-XN (enables template inlining)]");
+        System.out.println("   [-XX (turns on additional debugging message output)]");
+        System.out.println("   [-XT (use translet to transform if possible)]");
+    }
+
+  /**
+   * Command line interface to transform an XML document according to
+   * the instructions found in an XSL stylesheet.
+   * <p>The Process class provides basic functionality for
+   * performing transformations from the command line.  To see a
+   * list of arguments supported, call with zero arguments.</p>
+   * <p>To set stylesheet parameters from the command line, use
+   * <code>-PARAM name expression</code>. If you want to set the
+   * parameter to a string value, simply pass the string value
+   * as-is, and it will be interpreted as a string.  (Note: if
+   * the value has spaces in it, you may need to quote it depending
+   * on your shell environment).</p>
+   *
+   * @param argv Input parameters from command line
+   */
+    public static void main(String argv[]) {
+
+        // Runtime.getRuntime().traceMethodCalls(false); // turns Java tracing off
+        boolean doStackDumpOnError = false;
+        boolean doDiag = false;
+        boolean setQuietMode = false;
+        String msg = null;
+        boolean isSecureProcessing = false;
+
+        // Runtime.getRuntime().traceMethodCalls(false);
+        // Runtime.getRuntime().traceInstructions(false);
+        /**
+         * The default diagnostic writer...
+         */
+        java.io.PrintWriter diagnosticsWriter = new PrintWriter(System.err, true);
+        java.io.PrintWriter dumpWriter = diagnosticsWriter;
+        String flavor = "s2s";
+
+        if (argv.length < 1) {
+            printArgOptions();
+        } else {
+             // J2SE does not support Xalan interpretive
+            // false -> true
+            boolean useXSLTC = true;
+            for (int i = 0; i < argv.length; i++) {
+                if ("-XSLTC".equalsIgnoreCase(argv[i])) {
+                    useXSLTC = true;
+                }
+            }
+
+            TransformerFactory tfactory;
+            if (useXSLTC) {
+                String key = "javax.xml.transform.TransformerFactory";
+                String value = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
+                Properties props = System.getProperties();
+                props.put(key, value);
+                System.setProperties(props);
+            }
+
+            try {
+                tfactory = TransformerFactory.newInstance();
+                tfactory.setErrorListener(createDefaultErrorListener());
+            } catch (TransformerFactoryConfigurationError pfe) {
+                pfe.printStackTrace(dumpWriter);
+                //      "XSL Process was not successful.");
+                msg = "XSL Process was not successful.";
+                diagnosticsWriter.println(msg);
+
+                tfactory = null;  // shut up compiler
+
+                doExit(msg);
+            }
+
+            boolean formatOutput = false;
+            boolean useSourceLocation = false;
+            String inFileName = null;
+            String outFileName = null;
+            String dumpFileName = null;
+            String xslFileName = null;
+            String treedumpFileName = null;
+            String outputType = null;
+            String media = null;
+            List<String> params = new ArrayList<>();
+            boolean quietConflictWarnings = false;
+            URIResolver uriResolver = null;
+            EntityResolver entityResolver = null;
+            ContentHandler contentHandler = null;
+            int recursionLimit = -1;
+
+            for (int i = 0; i < argv.length; i++) {
+                if ("-XSLTC".equalsIgnoreCase(argv[i])) {
+                    // The -XSLTC option has been processed.
+                } // J2SE does not support Xalan interpretive
+                else if ("-INDENT".equalsIgnoreCase(argv[i])) {
+                    int indentAmount;
+
+                    if (((i + 1) < argv.length) && (argv[i + 1].charAt(0) != '-')) {
+                        indentAmount = Integer.parseInt(argv[++i]);
+                    } else {
+                        indentAmount = 0;
+                    }
+
+                } else if ("-IN".equalsIgnoreCase(argv[i])) {
+                    if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                        inFileName = argv[++i];
+                    } else {
+                        System.err.println("Missing argument for -IN");
+                    }
+                } else if ("-MEDIA".equalsIgnoreCase(argv[i])) {
+                    if (i + 1 < argv.length) {
+                        media = argv[++i];
+                    } else {
+                        System.err.println("Missing argument for -MEDIA");  //"Missing argument for);
+                    }
+                } else if ("-OUT".equalsIgnoreCase(argv[i])) {
+                    if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                        outFileName = argv[++i];
+                    } else {
+                        System.err.println("Missing argument for -OUT");  //"Missing argument for);
+                    }
+                } else if ("-XSL".equalsIgnoreCase(argv[i])) {
+                    if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                        xslFileName = argv[++i];
+                    } else {
+                        System.err.println("Missing argument for -XSL");  //"Missing argument for);
+                    }
+                } else if ("-FLAVOR".equalsIgnoreCase(argv[i])) {
+                    if (i + 1 < argv.length) {
+                        flavor = argv[++i];
+                    } else {
+                        System.err.println("Missing argument for -FLAVOR");  //"Missing argument for);
+                    }
+                } else if ("-PARAM".equalsIgnoreCase(argv[i])) {
+                    if (i + 2 < argv.length) {
+                        String name = argv[++i];
+
+                        params.add(name);
+
+                        String expression = argv[++i];
+
+                        params.add(expression);
+                    } else {
+                        System.err.println("Missing argument for -PARAM");  //"Missing argument for);
+                    }
+                } else if ("-E".equalsIgnoreCase(argv[i])) {
+
+                } else if ("-V".equalsIgnoreCase(argv[i])) {
+                    diagnosticsWriter.println(">>>>>>> Java Version "
+                            + getSystemProperty("java.version") + ", "
+                            + /* xmlProcessorLiaison.getParserDescription()+ */ "<<<<<<<");
+                } // J2SE does not support Xalan interpretive
+                /*
+                 else if ("-QC".equalsIgnoreCase(argv[i]))
+                 {
+                 if (!useXSLTC)
+                 quietConflictWarnings = true;
+                 else
+                 printInvalidXSLTCOption("-QC");
+                 }
+                 */ else if ("-Q".equalsIgnoreCase(argv[i])) {
+                    setQuietMode = true;
+                } else if ("-DIAG".equalsIgnoreCase(argv[i])) {
+                    doDiag = true;
+                } else if ("-XML".equalsIgnoreCase(argv[i])) {
+                    outputType = "xml";
+                } else if ("-TEXT".equalsIgnoreCase(argv[i])) {
+                    outputType = "text";
+                } else if ("-HTML".equalsIgnoreCase(argv[i])) {
+                    outputType = "html";
+                } else if ("-EDUMP".equalsIgnoreCase(argv[i])) {
+                    doStackDumpOnError = true;
+
+                    if (((i + 1) < argv.length) && (argv[i + 1].charAt(0) != '-')) {
+                        dumpFileName = argv[++i];
+                    }
+                } else if ("-URIRESOLVER".equalsIgnoreCase(argv[i])) {
+                    if (i + 1 < argv.length) {
+                        try {
+                            Class<?> uriResolverClass = Class.forName(argv[++i]);
+                            Constructor<?> ctor = uriResolverClass.getConstructor();
+                            ctor.setAccessible(true);
+                            uriResolver = (URIResolver) ctor.newInstance();
+
+                            tfactory.setURIResolver(uriResolver);
+                        } catch (Throwable cnfe) {
+                            msg = "Class not found for option -URIResolver";
+                            System.err.println(msg);
+                            doExit(msg);
+                        }
+                    } else {
+                        msg = "Missing argument for -URIResolver";
+                        System.err.println(msg);  //"Missing argument for);
+                        doExit(msg);
+                    }
+                } else if ("-ENTITYRESOLVER".equalsIgnoreCase(argv[i])) {
+                    if (i + 1 < argv.length) {
+                        try {
+                            Class<?> entityResolverClass = Class.forName(argv[++i]);
+                            Constructor<?> ctor = entityResolverClass.getConstructor();
+                            ctor.setAccessible(true);
+                            entityResolver = (EntityResolver) ctor.newInstance();
+                        } catch (Throwable cnfe) {
+                            msg = "Class not found for option -EntityResolver";
+                            System.err.println(msg);
+                            doExit(msg);
+                        }
+                    } else {
+                        //            "Missing argument for);
+                        msg = "Missing argument for -EntityResolver";
+                        System.err.println(msg);
+                        doExit(msg);
+                    }
+                } else if ("-CONTENTHANDLER".equalsIgnoreCase(argv[i])) {
+                    if (i + 1 < argv.length) {
+                        try {
+                            Class<?> contentHandlerClass = Class.forName(argv[++i]);
+                            Constructor<?> ctor = contentHandlerClass.getConstructor();
+                            ctor.setAccessible(true);
+                            contentHandler = (ContentHandler) ctor.newInstance();
+                        } catch (Throwable cnfe) {
+                            msg = "Class not found for option -ContentHandler";
+                            System.err.println(msg);
+                            doExit(msg);
+                        }
+                    } else {
+                        //            "Missing argument for);
+                        msg = "Missing argument for -ContentHandler";
+                        System.err.println(msg);
+                        doExit(msg);
+                    }
+                } else if ("-XO".equalsIgnoreCase(argv[i])) {
+                    if (useXSLTC) {
+                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                            tfactory.setAttribute("generate-translet", "true");
+                            tfactory.setAttribute("translet-name", argv[++i]);
+                        } else {
+                            tfactory.setAttribute("generate-translet", "true");
+                        }
+                    } else {
+                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                            i++;
+                        }
+                        printInvalidXalanOption("-XO");
+                    }
+                } // Specify the destination directory for the translet classes.
+                else if ("-XD".equalsIgnoreCase(argv[i])) {
+                    if (useXSLTC) {
+                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                            tfactory.setAttribute("destination-directory", argv[++i]);
+                        } else {
+                            System.err.println("Missing argument for -XD");  //"Missing argument for);
+                        }
+                    } else {
+                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                            i++;
+                        }
+
+                        printInvalidXalanOption("-XD");
+                    }
+                } // Specify the jar file name which the translet classes are packaged into.
+                else if ("-XJ".equalsIgnoreCase(argv[i])) {
+                    if (useXSLTC) {
+                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                            tfactory.setAttribute("generate-translet", "true");
+                            tfactory.setAttribute("jar-name", argv[++i]);
+                        } else {
+                            System.err.println("Missing argument for -XJ");  //"Missing argument for);
+                        }
+                    } else {
+                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                            i++;
+                        }
+
+                        printInvalidXalanOption("-XJ");
+                    }
+
+                } // Specify the package name prefix for the generated translet classes.
+                else if ("-XP".equalsIgnoreCase(argv[i])) {
+                    if (useXSLTC) {
+                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                            tfactory.setAttribute("package-name", argv[++i]);
+                        } else {
+                            System.err.println("Missing argument for -XP");  //"Missing argument for);
+                        }
+                    } else {
+                        if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') {
+                            i++;
+                        }
+
+                        printInvalidXalanOption("-XP");
+                    }
+
+                } // Enable template inlining.
+                else if ("-XN".equalsIgnoreCase(argv[i])) {
+                    if (useXSLTC) {
+                        tfactory.setAttribute("enable-inlining", "true");
+                    } else {
+                        printInvalidXalanOption("-XN");
+                    }
+                } // Turns on additional debugging message output
+                else if ("-XX".equalsIgnoreCase(argv[i])) {
+                    if (useXSLTC) {
+                        tfactory.setAttribute("debug", "true");
+                    } else {
+                        printInvalidXalanOption("-XX");
+                    }
+                } // Create the Transformer from the translet if the translet class is newer
+                // than the stylesheet.
+                else if ("-XT".equalsIgnoreCase(argv[i])) {
+                    if (useXSLTC) {
+                        tfactory.setAttribute("auto-translet", "true");
+                    } else {
+                        printInvalidXalanOption("-XT");
+                    }
+                } else if ("-SECURE".equalsIgnoreCase(argv[i])) {
+                    isSecureProcessing = true;
+                    try {
+                        tfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+                    } catch (TransformerConfigurationException e) {
+                    }
+                } else {
+                    System.err.println("Invalid argument: " + argv[i]);  //"Invalid argument:);
+                }
+            }
+
+            // Print usage instructions if no xml and xsl file is specified in the command line
+            if (inFileName == null && xslFileName == null) {
+                msg = "Error: No stylesheet or input xml is specified. Run this command without any option for usage instructions.";
+                System.err.println(msg);
+                doExit(msg);
+            }
+
+      // Note that there are usage cases for calling us without a -IN arg
+            // The main XSL transformation occurs here!
+            try {
+                long start = System.currentTimeMillis();
+
+                if (null != dumpFileName) {
+                    dumpWriter = new PrintWriter(new FileWriter(dumpFileName));
+                }
+
+                Templates stylesheet = null;
+
+                if (null != xslFileName) {
+                    if (flavor.equals("d2d")) {
+
+                        // Parse in the xml data into a DOM
+                        DocumentBuilderFactory dfactory
+                                = DocumentBuilderFactory.newInstance();
+
+                        dfactory.setNamespaceAware(true);
+
+                        if (isSecureProcessing) {
+                            try {
+                                dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+                            } catch (ParserConfigurationException pce) {
+                            }
+                        }
+
+                        DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
+                        Node xslDOM = docBuilder.parse(new InputSource(xslFileName));
+
+                        stylesheet = tfactory.newTemplates(new DOMSource(xslDOM,
+                                xslFileName));
+                    } else {
+                        // System.out.println("Calling newTemplates: "+xslFileName);
+                        stylesheet = tfactory.newTemplates(new StreamSource(xslFileName));
+                        // System.out.println("Done calling newTemplates: "+xslFileName);
+                    }
+                }
+
+                PrintWriter resultWriter;
+                StreamResult strResult;
+
+                if (null != outFileName) {
+                    strResult = new StreamResult(new FileOutputStream(outFileName));
+                    // One possible improvement might be to ensure this is
+                    //  a valid URI before setting the systemId, but that
+                    //  might have subtle changes that pre-existing users
+                    //  might notice; we can think about that later -sc r1.46
+                    strResult.setSystemId(outFileName);
+                } else {
+                    strResult = new StreamResult(System.out);
+                    // We used to default to incremental mode in this case.
+                    // We've since decided that since the -INCREMENTAL switch is
+                    // available, that default is probably not necessary nor
+                    // necessarily a good idea.
+                }
+
+                SAXTransformerFactory stf = (SAXTransformerFactory) tfactory;
+
+                // Did they pass in a stylesheet, or should we get it from the
+                // document?
+                if (null == stylesheet) {
+                    Source source
+                            = stf.getAssociatedStylesheet(new StreamSource(inFileName), media,
+                                    null, null);
+
+                    if (null != source) {
+                        stylesheet = tfactory.newTemplates(source);
+                    } else {
+                        if (null != media) {
+                            throw new TransformerException("No stylesheet found in:  "
+                                    + inFileName + ", media=" + media); //"No stylesheet found in: "
+                        } // + inFileName + ", media="
+                        // + media);
+                        else {
+                            throw new TransformerException("No xml-stylesheet PI found in: " + inFileName); //"No xml-stylesheet PI found in: "
+                        }                                             //+ inFileName);
+                    }
+                }
+
+                if (null != stylesheet) {
+                    Transformer transformer = flavor.equals("th") ? null : stylesheet.newTransformer();
+                    transformer.setErrorListener(createDefaultErrorListener());
+
+                    // Override the output format?
+                    if (null != outputType) {
+                        transformer.setOutputProperty(OutputKeys.METHOD, outputType);
+                    }
+
+                    int nParams = params.size();
+
+                    for (int i = 0; i < nParams; i += 2) {
+                        transformer.setParameter((String) params.get(i),
+                                (String) params.get(i + 1));
+                    }
+
+                    if (uriResolver != null) {
+                        transformer.setURIResolver(uriResolver);
+                    }
+
+                    if (null != inFileName) {
+                        if (flavor.equals("d2d")) {
+
+                            // Parse in the xml data into a DOM
+                            DocumentBuilderFactory dfactory
+                                    = DocumentBuilderFactory.newInstance();
+
+                            dfactory.setCoalescing(true);
+                            dfactory.setNamespaceAware(true);
+
+                            if (isSecureProcessing) {
+                                try {
+                                    dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+                                } catch (ParserConfigurationException pce) {
+                                }
+                            }
+
+                            DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
+
+                            if (entityResolver != null) {
+                                docBuilder.setEntityResolver(entityResolver);
+                            }
+
+                            Node xmlDoc = docBuilder.parse(new InputSource(inFileName));
+                            Document doc = docBuilder.newDocument();
+                            org.w3c.dom.DocumentFragment outNode
+                                    = doc.createDocumentFragment();
+
+                            transformer.transform(new DOMSource(xmlDoc, inFileName),
+                                    new DOMResult(outNode));
+
+                            // Now serialize output to disk with identity transformer
+                            Transformer serializer = stf.newTransformer();
+                            serializer.setErrorListener(createDefaultErrorListener());
+
+                            Properties serializationProps
+                                    = stylesheet.getOutputProperties();
+
+                            serializer.setOutputProperties(serializationProps);
+
+                            if (contentHandler != null) {
+                                SAXResult result = new SAXResult(contentHandler);
+
+                                serializer.transform(new DOMSource(outNode), result);
+                            } else {
+                                serializer.transform(new DOMSource(outNode), strResult);
+                            }
+                        } else if (flavor.equals("th")) {
+                            for (int i = 0; i < 1; i++) // Loop for diagnosing bugs with inconsistent behavior
+                            {
+                                // System.out.println("Testing the TransformerHandler...");
+
+                                XMLReader reader = null;
+
+                                // Use JAXP1.1 ( if possible )
+                                try {
+                                    javax.xml.parsers.SAXParserFactory factory
+                                            = javax.xml.parsers.SAXParserFactory.newInstance();
+
+                                    factory.setNamespaceAware(true);
+
+                                    if (isSecureProcessing) {
+                                        try {
+                                            factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+                                        } catch (org.xml.sax.SAXException se) {
+                                        }
+                                    }
+
+                                    javax.xml.parsers.SAXParser jaxpParser
+                                            = factory.newSAXParser();
+
+                                    reader = jaxpParser.getXMLReader();
+                                } catch (javax.xml.parsers.ParserConfigurationException ex) {
+                                    throw new org.xml.sax.SAXException(ex);
+                                } catch (javax.xml.parsers.FactoryConfigurationError ex1) {
+                                    throw new org.xml.sax.SAXException(ex1.toString());
+                                } catch (NoSuchMethodError ex2) {
+                                } catch (AbstractMethodError ame) {
+                                }
+
+                                if (null == reader) {
+                                    reader = XMLReaderFactory.createXMLReader();
+                                }
+
+                                TransformerHandler th = stf.newTransformerHandler(stylesheet);
+
+                                reader.setContentHandler(th);
+                                reader.setDTDHandler(th);
+
+                                if (th instanceof org.xml.sax.ErrorHandler) {
+                                    reader.setErrorHandler((org.xml.sax.ErrorHandler) th);
+                                }
+
+                                try {
+                                    reader.setProperty(
+                                            "http://xml.org/sax/properties/lexical-handler", th);
+                                } catch (org.xml.sax.SAXNotRecognizedException e) {
+                                } catch (org.xml.sax.SAXNotSupportedException e) {
+                                }
+                                try {
+                                    reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
+                                            true);
+                                } catch (org.xml.sax.SAXException se) {
+                                }
+
+                                th.setResult(strResult);
+
+                                reader.parse(new InputSource(inFileName));
+                            }
+                        } else {
+                            if (entityResolver != null) {
+                                XMLReader reader = null;
+
+                                // Use JAXP1.1 ( if possible )
+                                try {
+                                    javax.xml.parsers.SAXParserFactory factory
+                                            = javax.xml.parsers.SAXParserFactory.newInstance();
+
+                                    factory.setNamespaceAware(true);
+
+                                    if (isSecureProcessing) {
+                                        try {
+                                            factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+                                        } catch (org.xml.sax.SAXException se) {
+                                        }
+                                    }
+
+                                    javax.xml.parsers.SAXParser jaxpParser
+                                            = factory.newSAXParser();
+
+                                    reader = jaxpParser.getXMLReader();
+                                } catch (javax.xml.parsers.ParserConfigurationException ex) {
+                                    throw new org.xml.sax.SAXException(ex);
+                                } catch (javax.xml.parsers.FactoryConfigurationError ex1) {
+                                    throw new org.xml.sax.SAXException(ex1.toString());
+                                } catch (NoSuchMethodError ex2) {
+                                } catch (AbstractMethodError ame) {
+                                }
+
+                                if (null == reader) {
+                                    reader = XMLReaderFactory.createXMLReader();
+                                }
+
+                                reader.setEntityResolver(entityResolver);
+
+                                if (contentHandler != null) {
+                                    SAXResult result = new SAXResult(contentHandler);
+
+                                    transformer.transform(
+                                            new SAXSource(reader, new InputSource(inFileName)),
+                                            result);
+                                } else {
+                                    transformer.transform(
+                                            new SAXSource(reader, new InputSource(inFileName)),
+                                            strResult);
+                                }
+                            } else if (contentHandler != null) {
+                                SAXResult result = new SAXResult(contentHandler);
+
+                                transformer.transform(new StreamSource(inFileName), result);
+                            } else {
+                                // System.out.println("Starting transform");
+                                transformer.transform(new StreamSource(inFileName),
+                                        strResult);
+                                // System.out.println("Done with transform");
+                            }
+                        }
+                    } else {
+                        StringReader reader
+                                = new StringReader("<?xml version=\"1.0\"?> <doc/>");
+
+                        transformer.transform(new StreamSource(reader), strResult);
+                    }
+                } else {
+                    //          "XSL Process was not successful.");
+                    msg = "XSL Process was not successful.";
+                    diagnosticsWriter.println(msg);
+                    doExit(msg);
+                }
+
+                // close output streams
+                if (null != outFileName && strResult != null) {
+                    java.io.OutputStream out = strResult.getOutputStream();
+                    java.io.Writer writer = strResult.getWriter();
+                    try {
+                        if (out != null) {
+                            out.close();
+                        }
+                        if (writer != null) {
+                            writer.close();
+                        }
+                    } catch (java.io.IOException ie) {
+                    }
+                }
+
+                long stop = System.currentTimeMillis();
+                long millisecondsDuration = stop - start;
+
+                if (doDiag) {
+                    msg = " --------- Transform of " + inFileName + " via "
+                            + xslFileName + " took " + millisecondsDuration + " ms";
+                    diagnosticsWriter.println('\n');
+                    diagnosticsWriter.println(msg);
+                }
+
+            } catch (Throwable throwable) {
+                doStackDumpOnError = true;
+
+                diagnosticsWriter.println();
+
+                if (doStackDumpOnError) {
+                    throwable.printStackTrace(dumpWriter);
+                } else {
+                    printLocation(diagnosticsWriter, throwable);
+                    diagnosticsWriter.println("Unexpected exception: " + throwable);
+                }
+
+                // diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL, null)); //"XSL Process was not successful.");
+                if (null != dumpFileName) {
+                    dumpWriter.close();
+                }
+
+                doExit(throwable.getMessage());
+            }
+
+            if (null != dumpFileName) {
+                dumpWriter.close();
+            }
+
+            if (null != diagnosticsWriter) {
+
+                // diagnosticsWriter.close();
+            }
+
+            // if(!setQuietMode)
+            //  diagnosticsWriter.println(resbundle.getString("xsldone")); //"Xalan: done");
+            // else
+            // diagnosticsWriter.println("");  //"Xalan: done");
+        }
+    }
+
+    /**
+     * It is _much_ easier to debug under VJ++ if I can set a single breakpoint
+     * before this blows itself out of the water... (I keep checking this in, it
+     * keeps vanishing. Grr!)
+     *
+     */
+    static void doExit(String msg) {
+        throw new RuntimeException(msg);
+    }
+
+    /**
+     * Wait for a return key to continue
+     *
+     * @param resbundle The resource bundle
+     */
+    private static void waitForReturnKey() {
+        System.out.println("(press <return> to continue)");
+        try {
+            while (System.in.read() != '\n');
+        } catch (java.io.IOException e) {
+        }
+    }
+
+    /**
+     * Print a message if an option cannot be used with -XSLTC.
+     *
+     * @param option The option String
+     */
+    private static void printInvalidXSLTCOption(String option) {
+        System.err.println("The option " + option + " is not supported in XSLTC mode.");
+    }
+
+    /**
+     * Print a message if an option can only be used with -XSLTC.
+     *
+     * @param option The option String
+     */
+    private static void printInvalidXalanOption(String option) {
+        System.err.println("The option " + option + " can only be used with -XSLTC.");
+    }
+
+    static class DummyErrorListenerHandler implements ErrorHandler, ErrorListener {
+        @Override
+        public void warning(SAXParseException exception) throws SAXException {
+            System.err.println("WARNING: " + exception);
+        }
+        @Override
+        public void error(SAXParseException exception) throws SAXException {
+            throw exception;
+        }
+        @Override
+        public void fatalError(SAXParseException exception) throws SAXException {
+            throw exception;
+        }
+        @Override
+        public void warning(TransformerException exception) throws TransformerException {
+            System.err.println("WARNING: " + exception);
+        }
+        @Override
+        public void error(TransformerException exception) throws TransformerException {
+            throw exception;
+        }
+        @Override
+        public void fatalError(TransformerException exception) throws TransformerException {
+            throw exception;
+        }
+    }
+
+    static ErrorListener createDefaultErrorListener() {
+        try {
+            Class<?> errorHandler =
+                    Class.forName("com.sun.org.apache.xml.internal.utils.DefaultErrorHandler");
+            Constructor<?> ctor = errorHandler.getConstructor();
+            return (ErrorListener) ctor.newInstance();
+        } catch (Throwable r) {
+            return new DummyErrorListenerHandler();
+        }
+    }
+
+    private static void printLocation(PrintWriter diagnosticsWriter, Throwable throwable) {
+        try {
+            Class<?> errorHandler =
+                    Class.forName("com.sun.org.apache.xml.internal.utils.DefaultErrorHandler");
+            Method m = errorHandler.getMethod("printLocation", PrintWriter.class, Throwable.class);
+            m.invoke(null, diagnosticsWriter, throwable);
+        } catch (Throwable t) {
+            SourceLocator locator = null;
+            Throwable cause = throwable;
+
+            // Try to find the locator closest to the cause.
+            do {
+                if (cause instanceof TransformerException) {
+                    SourceLocator causeLocator = ((TransformerException) cause).getLocator();
+                    if (null != causeLocator) {
+                        locator = causeLocator;
+                    }
+                    cause = ((TransformerException) cause).getCause();
+                } else if (cause instanceof SAXException) {
+                    cause = ((SAXException) cause).getException();
+                } else {
+                    cause = cause.getCause();
+                }
+            } while (null != cause);
+
+            if (null != locator) {
+                // m_pw.println("Parser fatal error: "+exception.getMessage());
+                String id = (null != locator.getPublicId())
+                        ? locator.getPublicId()
+                        : (null != locator.getSystemId())
+                                ? locator.getSystemId() : "SystemId Unknown"; //"SystemId Unknown";
+
+                diagnosticsWriter.print(id + "; " + "line: " + locator.getLineNumber()
+                        + "; column: " + locator.getColumnNumber() + "; ");
+            }
+            diagnosticsWriter.print("(" + throwable + ": unknown location)");
+        }
+    }
+
+}
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/SAX2DOMTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/SAX2DOMTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stream.StreamSource;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -45,8 +46,13 @@
 import org.xml.sax.helpers.XMLFilterImpl;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.SAX2DOMTest
+ * @run testng/othervm transform.SAX2DOMTest
  * @summary Test Transforming from SAX to DOM.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class SAX2DOMTest {
 
     @Test
@@ -192,3 +198,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,10 @@
 
 package transform;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
 
 import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
@@ -39,29 +35,19 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
-import org.testng.annotations.Test;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
+import org.testng.annotations.Listeners;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.SecureProcessingTest
+ * @run testng/othervm transform.SecureProcessingTest
  * @summary Test XSLT shall report TransformerException for unsafe xsl when FEATURE_SECURE_PROCESSING is true.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class SecureProcessingTest {
-    static boolean _isSecureMode = false;
-    static {
-        if (System.getSecurityManager() != null) {
-            _isSecureMode = true;
-            System.out.println("Security Manager is present");
-        } else {
-            System.out.println("Security Manager is NOT present");
-        }
-    }
-
-
-
-    @Test
-    public final void testSecureProcessing() {
-
+    public void testSecureProcessing() {
+        boolean _isSecureMode = System.getSecurityManager() != null;
         // SECURE_PROCESSING == false
 
         // the style sheet
@@ -149,3 +135,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/SourceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/SourceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,11 +35,17 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.SourceTest
+ * @run testng/othervm transform.SourceTest
  * @summary Test Sources.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class SourceTest {
 
     @Test
@@ -142,3 +148,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,11 +40,17 @@
 import javax.xml.transform.stax.StAXSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.StAXSourceTest
+ * @run testng/othervm transform.StAXSourceTest
  * @summary Test parsing from StAXSource.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class StAXSourceTest {
 
     @Test
@@ -123,3 +129,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/TemplatesTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TemplatesTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,11 +29,17 @@
 import javax.xml.transform.*;
 import javax.xml.transform.stream.StreamSource;
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.TemplatesTest
+ * @run testng/othervm transform.TemplatesTest
  * @summary This class contains tests for Templates.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class TemplatesTest {
 
     /**
@@ -60,7 +66,7 @@
      * DataProvider: Templates
      */
     @DataProvider(name = "templates")
-    Object[][] getTemplates() throws Exception {
+    public Object[][] getTemplates() throws Exception {
         return new Object[][]{{TransformerFactory.newInstance().
                 newTemplates(new StreamSource(new StringReader(XSL)))}};
     }
@@ -77,3 +83,4 @@
             + "      contains($validAffectsRelClasses, @Class)]/@OBID)\"/>"
             + "</xsl:stylesheet>";
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerFactoryTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerFactoryTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,13 +42,19 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.TransformerFactoryTest
+ * @run testng/othervm transform.TransformerFactoryTest
  * @summary Test TransformerFactory.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class TransformerFactoryTest {
 
     private static URIResolver resolver = new URIResolver() {
@@ -147,3 +153,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,8 +23,7 @@
 
 package transform;
 
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -45,6 +44,7 @@
 
 import org.testng.Assert;
 import org.testng.AssertJUnit;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -60,10 +60,18 @@
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.AttributesImpl;
 
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.TransformerTest
+ * @run testng/othervm transform.TransformerTest
  * @summary Transformer Tests
  * @bug 6272879 6305029 6505031 8150704 8162598
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class TransformerTest {
     private Transformer createTransformer() throws TransformerException {
         return TransformerFactory.newInstance().newTransformer();
@@ -245,7 +253,7 @@
      */
     @Test
     public final void testBug6272879() throws IOException, TransformerException {
-        final String LINE_SEPARATOR = System.getProperty("line.separator");
+        final String LINE_SEPARATOR = getSystemProperty("line.separator");
 
         final String xsl =
                 "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + LINE_SEPARATOR +
@@ -380,7 +388,7 @@
      */
     @Test
     public final void testBug8162598() throws IOException, TransformerException {
-        final String LINE_SEPARATOR = System.getProperty("line.separator");
+        final String LINE_SEPARATOR = getSystemProperty("line.separator");
 
         final String xsl =
             "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + LINE_SEPARATOR +
@@ -431,3 +439,4 @@
         Assert.assertNull(document.getElementsByTagName("test6").item(0).getNamespaceURI(), "unexpected namespace for test6");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerUtilFactory.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerUtilFactory.java	Mon Aug 08 12:50:00 2016 +0800
@@ -56,3 +56,4 @@
             return null;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/VersionDefaultHandler.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/VersionDefaultHandler.java	Mon Aug 08 12:50:00 2016 +0800
@@ -62,3 +62,4 @@
         return encoding;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/VersionEventWriter.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/VersionEventWriter.java	Mon Aug 08 12:50:00 2016 +0800
@@ -82,3 +82,4 @@
         return encoding;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -35,14 +35,21 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 import static org.testng.Assert.assertEquals;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @compile DocumentExtFunc.java
+ * @run testng/othervm -DrunSecMngr=true transform.XSLTFunctionsTest
+ * @run testng/othervm transform.XSLTFunctionsTest
  * @summary This class contains tests for XSLT functions.
  */
 
+//@Listeners({jaxp.library.BasePolicy.class}) //uncomment this line after 8161454 is resolved
 public class XSLTFunctionsTest {
 
     /**
@@ -65,6 +72,7 @@
 
         // Create factory and transformer
         TransformerFactory tf = TransformerFactory.newInstance();
+        tf.setFeature("http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions", true);
         Transformer t = tf.newTransformer( xslsrc );
         t.setErrorListener(tf.getErrorListener());
 
@@ -126,3 +134,4 @@
     static final String documentTesteExpectedResult = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                                                     + "<root>[Test:Doc][Test:External Doc]</root>";
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/sax/Bug6451633.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/sax/Bug6451633.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,14 +29,20 @@
 import javax.xml.transform.sax.TransformerHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.helpers.AttributesImpl;
 
 /*
+ * @test
  * @bug 6451633
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true transform.sax.Bug6451633
+ * @run testng/othervm transform.sax.Bug6451633
  * @summary Test TransformerHandler ignores empty text node.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6451633 {
 
     @Test
@@ -56,3 +62,4 @@
         Assert.assertEquals(0, ((Document) result.getNode()).getDocumentElement().getChildNodes().getLength());
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/util/DOMUtil.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/util/DOMUtil.java	Mon Aug 08 12:50:00 2016 +0800
@@ -68,3 +68,4 @@
         Assert.assertTrue(version.equals(resultVersion), "Expected XML Version is 1.1, but actual version " + resultVersion);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/util/SAXUtil.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/util/SAXUtil.java	Mon Aug 08 12:50:00 2016 +0800
@@ -70,3 +70,4 @@
         Assert.assertTrue(encoding.equals(resultEncoding), "Expected XML Version is " + encoding + " , but actual  encoding " + resultEncoding);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/util/StAXUtil.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/util/StAXUtil.java	Mon Aug 08 12:50:00 2016 +0800
@@ -92,3 +92,4 @@
         ((StreamUtil) TransformerUtilFactory.getUtil(TransformerUtilFactory.STREAM)).checkStream(new FileInputStream(TEMP_FILE), version);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/util/StreamUtil.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/util/StreamUtil.java	Mon Aug 08 12:50:00 2016 +0800
@@ -23,10 +23,14 @@
 
 package transform.util;
 
+import static jaxp.library.JAXPTestUtilities.runWithTmpPermission;
+import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.util.PropertyPermission;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.SAXParser;
@@ -65,7 +69,7 @@
 
     public Result prepareResult() throws Exception {
         FileOutputStream fos = new FileOutputStream(TEMP_FILE);
-        return new StreamResult(fos);
+        return runWithTmpPermission(() -> new StreamResult(fos), new PropertyPermission("user.dir", "read"));
     }
 
     public void checkResult(Result result, String inputVersion) throws Exception {
@@ -85,8 +89,9 @@
         // use sax parser, as encoding info cannot be set on DOM document
         SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
         VersionDefaultHandler dh = new VersionDefaultHandler();
-        parser.parse(new File(TEMP_FILE), dh);
+        tryRunWithTmpPermission(() -> parser.parse(new File(TEMP_FILE), dh), new PropertyPermission("user.dir", "read"));
         Assert.assertTrue(dh.getVersion().equals(version), "Expected version is " + version + " actual version " + dh.getVersion());
         Assert.assertTrue(dh.getEncoding().equals(encoding), "Expected version is " + encoding + " actual version " + dh.getEncoding());
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/util/BOMInputStream.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/util/BOMInputStream.java	Mon Aug 08 12:50:00 2016 +0800
@@ -78,3 +78,4 @@
         }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/util/BaseStAXUT.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/util/BaseStAXUT.java	Mon Aug 08 12:50:00 2016 +0800
@@ -557,3 +557,4 @@
         System.err.println("Skipping " + clsName + "#" + method + ": entity expansion does not seem to be functioning properly" + msg + ".");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/6773084.policy	Thu Aug 04 17:47:31 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-grant {
-	permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
-	permission java.lang.RuntimePermission "accessDeclaredMembers";
-	
-	permission java.io.FilePermission "${test.classes}/../../-", "read, write, delete";
-	permission java.io.FilePermission ".", "read, write, delete";
-	permission java.util.PropertyPermission "*", "read, write";
-	
-    permission java.lang.RuntimePermission "setSecurityManager";
-    permission java.lang.RuntimePermission "createSecurityManager";
-    permission java.lang.RuntimePermission "createClassLoader";
-    permission java.lang.RuntimePermission "setIO";
-	permission java.lang.RuntimePermission "setContextClassLoader"; 
-	permission java.security.SecurityPermission "getPolicy";
-    
-    permission java.io.FilePermission "${test.src}/-", "read, write, delete";
-    permission java.io.FilePermission "${user.dir}/-", "read, write, delete";
-    permission java.io.FilePermission "${java.io.tmpdir}/-", "read, write, delete";
-    
-    
-    permission java.lang.RuntimePermission "modifyThread";
-
-};
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/AnyElementTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/AnyElementTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,11 @@
 package validation;
 
 /*
+ * @test
  * @bug 8080907
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.AnyElementTest
+ * @run testng/othervm validation.AnyElementTest
  * @summary Test processContents attribute of any element
  */
 import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
@@ -35,10 +39,12 @@
 import javax.xml.validation.Validator;
 
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
+@Listeners({jaxp.library.FilePolicy.class})
 public class AnyElementTest {
     @BeforeClass
     public void setup() throws URISyntaxException, SAXException {
@@ -79,3 +85,4 @@
 
     private Validator validator;
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966232.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966232.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,14 +30,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 4966232
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4966232
+ * @run testng/othervm validation.Bug4966232
  * @summary Test SchemaFactory.newSchema(Source) returns a Schema instance for DOMSource & SAXSource.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4966232 {
 
     // test for W3C XML Schema 1.0 - newSchema(Source schema)
@@ -69,3 +75,4 @@
         Assert.assertNotNull(s);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966254.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966254.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,15 +29,21 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 import util.DraconianErrorHandler;
 
 /*
+ * @test
  * @bug 4966254
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4966254
+ * @run testng/othervm validation.Bug4966254
  * @summary Test validate(StreamSource) & validate(StreamSource,null) works instead of throws IOException.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4966254 {
 
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
@@ -72,3 +78,4 @@
         return s;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969042.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969042.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -41,10 +42,15 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4969042
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4969042
+ * @run testng/othervm validation.Bug4969042
  * @summary Test ValidationHandler shall invoke ignorableWhitespace() of the
  * user-defined ContentHandler once the validator detects any ignorable whitespaces.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4969042 {
 
     public static final String XSD = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n" + "        xmlns:test='jaxp13_test'\n"
@@ -105,3 +111,4 @@
         Assert.assertTrue(invoked[1], "Method characters() was not invoked.");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969089.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969089.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,16 +30,22 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4969089
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4969089
+ * @run testng/othervm validation.Bug4969089
  * @summary Test when an ErrorHandler is set for a SchemaFactory, SchemaFactory.newSchema(Source[])
  * method throws an exception that is not equal to the exception thrown from the ErrorHandler.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4969089 {
 
     @Test
@@ -70,3 +76,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969110.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969110.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,15 +27,21 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
 
 /*
+ * @test
  * @bug 4969110
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4969110
+ * @run testng/othervm validation.Bug4969110
  * @summary Test ValidationHandler.set/getProperty() throws a correct exception
  * instead of a sun internal exception in case the "property name" parameter is invalid.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4969110 {
 
     SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
@@ -73,3 +79,4 @@
         validatorHandler.setProperty(name, "123");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969689.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969689.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,16 +26,22 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
 
 
 /*
+ * @test
  * @bug 4969689
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4969689
+ * @run testng/othervm validation.Bug4969689
  * @summary Test SchemaFactory.get/setFeature() throw NullPointerException
  * instead of SAXNotRecognizedException in case the "feature name" parameter is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4969689 {
 
     SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
@@ -60,3 +66,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969692.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969692.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,14 +27,20 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 4969692
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4969692
+ * @run testng/othervm validation.Bug4969692
  * @summary Test Validator.get/setFeature() throw NullPointerException
  * instead of SAXNotRecognizedException in case the "feature name" parameter is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4969692 {
 
     SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
@@ -61,3 +67,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969693.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969693.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,14 +27,20 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 4969693
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4969693
+ * @run testng/othervm validation.Bug4969693
  * @summary Test Validator.get/setProperty() throw NullPointerException
  * instead of SAXNotRecognizedException in case the "property name" parameter is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4969693 {
 
     SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
@@ -61,3 +67,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969695.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969695.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,15 +26,21 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXNotRecognizedException;
 import org.xml.sax.SAXNotSupportedException;
 
 /*
+ * @test
  * @bug 4969695
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4969695
+ * @run testng/othervm validation.Bug4969695
  * @summary Test SchemaFactory.get/setProperty() throw NullPointerException
  * instead of SAXNotRecognizedException in case the "property name" parameter is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4969695 {
 
     SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
@@ -59,3 +65,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969732.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969732.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -40,10 +41,15 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4969732
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4969732
+ * @run testng/othervm validation.Bug4969732
  * @summary Test TypeInfoProvider.getElementTypeInfo() throws IllegalStateException
  * in case the method is not called from method startElement() or endElement().
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4969732 {
 
     public static final String XSD = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n" + "        xmlns:test='jaxp13_test'\n"
@@ -106,3 +112,4 @@
         parse(xmlReader, XML);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970380.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970380.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,19 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXNotRecognizedException;
 
 /*
+ * @test
  * @bug 4970380
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4970380
+ * @run testng/othervm validation.Bug4970380
  * @summary Test validatorHandler.getFeature(...) with unknown name and "http://xml.org/sax/features/namespace-prefixes".
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4970380 {
 
     @Test
@@ -56,3 +62,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970383.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970383.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4970383
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4970383
+ * @run testng/othervm validation.Bug4970383
  * @summary Test validatorHandler.setFeature throws NullPointerException if name parameter is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4970383 {
 
     @Test
@@ -47,3 +53,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970400.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970400.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,12 +26,18 @@
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.ValidatorHandler;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4970400
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4970400
+ * @run testng/othervm validation.Bug4970400
  * @summary Test ValidatorHandler recognizes namespace-prefixes feature.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4970400 {
 
     @Test
@@ -42,3 +48,4 @@
         validatorHandler.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970402.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970402.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
@@ -43,9 +44,14 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4970402
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4970402
+ * @run testng/othervm validation.Bug4970402
  * @summary Test TypeInfoProvider's attribute accessing methods throw IndexOutOfBoundsException when index parameter is invalid.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4970402 {
 
     public static final String XSD = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n" + "        xmlns:test='jaxp13_test'\n"
@@ -117,3 +123,4 @@
         parse(xmlReader, XML);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970951.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970951.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
@@ -43,9 +44,14 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4970951
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4970951
+ * @run testng/othervm validation.Bug4970951
  * @summary Test TypeInfoProvider.isSpecified(...) return true if the attribute was originally present.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4970951 {
 
     public static final String XSD = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n" + "        xmlns:test='jaxp13_test'\n"
@@ -120,3 +126,4 @@
         parse(xmlReader, XML);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971605.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971605.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,14 +33,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 4971605
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4971605
+ * @run testng/othervm validation.Bug4971605
  * @summary Test SchemaFactory.newSchema(Source) returns a Schema instance for DOMSource.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4971605 {
 
     @Test
@@ -60,3 +66,4 @@
         Assert.assertNotNull(schema, "Failed: newSchema returned null.");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971607.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971607.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4971607
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4971607
+ * @run testng/othervm validation.Bug4971607
  * @summary Test ValidatorHandler.getFeature(...) throws NullPointerException when name parameter is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4971607 {
 
     @Test
@@ -50,3 +56,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4972882.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4972882.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,15 +28,21 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 import util.DraconianErrorHandler;
 
 /*
+ * @test
  * @bug 4972882
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4972882
+ * @run testng/othervm validation.Bug4972882
  * @summary Test Validator throws Exception when two identity-constraints are defined with the same {name} and {target namespace}.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4972882 {
 
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
@@ -61,3 +67,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4986844.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4986844.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 4986844
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4986844
+ * @run testng/othervm validation.Bug4986844
  * @summary Test SchemaFactory can detect particle restriction.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4986844 {
 
     @Test
@@ -50,3 +56,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4987574.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4987574.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,24 +23,33 @@
 
 package validation;
 
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.PrintWriter;
+import java.nio.file.Paths;
 
 import javax.xml.validation.SchemaFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4987574
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4987574
+ * @run testng/othervm validation.Bug4987574
  * @summary Test schemaFactory.newSchema doesn't throw NullPointerExceptio for empty schema.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4987574 {
 
     @Test
     public void test1() throws Exception {
         SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
-        File tmpFile = File.createTempFile("jaxpri", "bug");
+        File tmpFile = File.createTempFile("jaxpri", "bug", Paths.get(USER_DIR).toFile());
         tmpFile.deleteOnExit();
         {
             PrintWriter pw = new PrintWriter(new FileWriter(tmpFile));
@@ -51,3 +60,4 @@
         schemaFactory.newSchema(tmpFile);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988267.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988267.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 4988267
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4988267
+ * @run testng/othervm validation.Bug4988267
  * @summary Test SchemaFactory can detect particle restriction.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4988267 {
 
     @Test
@@ -50,3 +56,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988268.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988268.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,18 @@
 
 import javax.xml.validation.SchemaFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4988268
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4988268
+ * @run testng/othervm validation.Bug4988268
  * @summary Test the schema is valid.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4988268 {
 
     @Test
@@ -40,3 +46,4 @@
         schemaFactory.newSchema(Bug4988268.class.getResource("Bug4988268.xsd"));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988387.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988387.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 4988387
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4988387
+ * @run testng/othervm validation.Bug4988387
  * @summary Test SchemaFactory can detect invalid XPath expressions.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4988387 {
 
     @Test
@@ -47,3 +53,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4996446.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4996446.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,26 +30,32 @@
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 4996446
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4996446
+ * @run testng/othervm validation.Bug4996446
  * @summary Test SchemaFactory can detect violations of the "Schema Component Constraint: Element Declarations Consistent".
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug4996446 {
 
     SchemaFactory schemaFactory = null;
 
     @BeforeMethod
-    protected void setUp() {
+    public void setUp() {
         schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
     }
 
     @AfterMethod
-    protected void tearDown() {
+    public void tearDown() {
         schemaFactory = null;
     }
 
@@ -84,3 +90,4 @@
         errorCounter++;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4997818.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4997818.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,15 +30,21 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.ls.LSInput;
 import org.w3c.dom.ls.LSResourceResolver;
 
 /*
+ * @test
  * @bug 4997818
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug4997818
+ * @run testng/othervm validation.Bug4997818
  * @summary Test SchemaFactory.newSchema(...) throws an exception, which is thrown from LSResourceResolver.
  */
 
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4997818 {
 
     @Test
@@ -75,3 +81,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5011500.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5011500.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,15 +34,21 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 5011500
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug5011500
+ * @run testng/othervm validation.Bug5011500
  * @summary Test ValidatorHanlder and Validator can work for the xml document.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug5011500 {
 
     public static final String XSD = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n" + "        xmlns:test='jaxp13_test'\n"
@@ -102,3 +108,4 @@
         validator.validate(xmlSource);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5072946.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5072946.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -45,9 +46,14 @@
 import org.xml.sax.helpers.XMLReaderFactory;
 
 /*
+ * @test
  * @bug 5072946
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug5072946
+ * @run testng/othervm validation.Bug5072946
  * @summary Test Validator.validate(DOMSource,DOMResult) outputs to the result.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug5072946 {
 
     @Test
@@ -119,3 +125,4 @@
         Assert.assertSame(r.getNode(), n);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6378043.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6378043.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6378043
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6378043
+ * @run testng/othervm validation.Bug6378043
  * @summary Test XPath expression "child::" can be parsed.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6378043 {
 
     static String SCHEMA_LANG = "http://www.w3.org/2001/XMLSchema";
@@ -47,3 +53,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6449797.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6449797.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,19 @@
 import javax.xml.XMLConstants;
 import javax.xml.validation.SchemaFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6449797
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6449797
+ * @run testng/othervm validation.Bug6449797
  * @summary Test SchemaFactory can parse the specified attribute value with a specified namespace.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6449797 {
 
     @Test
@@ -40,3 +46,4 @@
         SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(getClass().getResource("Bug6449797.xsd"));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,15 @@
 
 package validation;
 
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.StringReader;
+import java.nio.file.Paths;
 
 import javax.xml.XMLConstants;
 import javax.xml.transform.stream.StreamSource;
@@ -36,13 +39,18 @@
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
-import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6457662
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6457662
+ * @run testng/othervm validation.Bug6457662
  * @summary Test a Validator checks sequence maxOccurs correctly when it validates document repeatedly.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6457662 {
 
     public static final String xml = "<ACL xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" + "<Tokens access=\"full\">" + "<Token>CheetahTech</Token>"
@@ -59,21 +67,17 @@
     private static final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
 
     @Test
-    public void test() {
-        try {
-            final Schema sc = factory.newSchema(writeSchema());
-            final Validator validator = sc.newValidator();
-            validator.validate(new StreamSource(new StringReader(xml)));
-            validator.validate(new StreamSource(new StringReader(xml)));
-            validator.validate(new StreamSource(new StringReader(xml)));
-            validator.validate(new StreamSource(new StringReader(xml)));
-        } catch (Throwable ex) {
-            Assert.fail("Exception: " + ex.getMessage());
-        }
+    public void test() throws Exception {
+        final Schema sc = factory.newSchema(writeSchema());
+        final Validator validator = sc.newValidator();
+        validator.validate(new StreamSource(new StringReader(xml)));
+        validator.validate(new StreamSource(new StringReader(xml)));
+        validator.validate(new StreamSource(new StringReader(xml)));
+        validator.validate(new StreamSource(new StringReader(xml)));
     }
 
     private File writeSchema() throws IOException {
-        final File rtn = File.createTempFile("scheam", "xsd");
+        final File rtn = File.createTempFile("scheam", "xsd", Paths.get(USER_DIR).toFile());
         final OutputStream out = new FileOutputStream(rtn);
         final OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
         writer.write(schema);
@@ -82,3 +86,4 @@
         return rtn;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6467424Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6467424Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,14 +43,20 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6467424
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6467424Test
+ * @run testng/othervm validation.Bug6467424Test
  * @summary Test Validator augments the default delement value if feature element-default is on.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6467424Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -199,3 +205,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6483188.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6483188.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,29 +31,25 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 6483188
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6483188
+ * @run testng/othervm validation.Bug6483188
  * @summary Test Schema Validator can handle element with having large maxOccurs, but doesn't accept sequence with having large maxOccurs in FEATURE_SECURE_PROCESSING mode.
  */
+@Test(singleThreaded = true)
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6483188 {
-    static boolean _isSecureMode = false;
-    static {
-        if (System.getSecurityManager() != null) {
-            _isSecureMode = true;
-            System.out.println("Security Manager is present");
-        } else {
-            System.out.println("Security Manager is NOT present");
-        }
-    }
-
     SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
 
-    @Test
     public void testLargeElementNoSecurity() {
-        if (_isSecureMode)
+        if (System.getSecurityManager() != null)
             return; // jaxp secure feature can not be turned off when security
                     // manager is present
         try {
@@ -66,7 +62,6 @@
         }
     }
 
-    @Test
     public void testLargeElementWithSecurity() {
         try {
             sf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
@@ -78,7 +73,6 @@
         }
     }
 
-    @Test
     public void testLargeSequenceWithSecurity() {
         try {
             sf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
@@ -94,3 +88,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6493687.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6493687.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,13 +23,19 @@
 
 package validation;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
 /*
+ * @test
  * @bug 6493687
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6493687
+ * @run testng/othervm validation.Bug6493687
  * @summary Test validator.validate(new DOMSource(node)) without any exception.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6493687 {
 
     @Test
@@ -42,3 +48,4 @@
         System.out.println("Got here3");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6509668.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6509668.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 import javax.xml.validation.ValidatorHandler;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.TypeInfo;
 import org.xml.sax.Attributes;
@@ -45,9 +46,14 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6509668
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6509668
+ * @run testng/othervm validation.Bug6509668
  * @summary Test TypeInfoProvider.getElementTypeInfo() for union type when startElement and endElement.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6509668 {
 
     public static final String XSD = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n"
@@ -135,3 +141,4 @@
         parse(xmlReader, XML);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6526547.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6526547.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,14 +34,20 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6526547
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6526547
+ * @run testng/othervm validation.Bug6526547
  * @summary Test document parsed without setting NamespaceAware can be validated with a Schema.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6526547 {
 
     @Test
@@ -76,3 +82,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6531160.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6531160.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,14 +33,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 6531160
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6531160
+ * @run testng/othervm validation.Bug6531160
  * @summary Test document generated by newDocument() can be validated with a Schema.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6531160 {
 
     private static final String XSD = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + "  <xs:element name='root' type='xs:string'/>\n"
@@ -64,3 +70,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6695843Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6695843Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,14 +35,20 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6695843
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6695843Test
+ * @run testng/othervm validation.Bug6695843Test
  * @summary Test Validator should report accurate element type if there is a violation on a complexType with simpleContent that extends a base complexType.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6695843Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -76,3 +82,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 
 package validation;
 
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
@@ -43,7 +45,7 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.ErrorHandler;
@@ -51,9 +53,14 @@
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 6773084
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6773084Test
+ * @run testng/othervm validation.Bug6773084Test
  * @summary Test Schema object is thread safe.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6773084Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -68,11 +75,6 @@
 
     private static Schema schema;
 
-    @BeforeClass
-    public void setup(){
-        policy.PolicyUtil.changePolicy(getClass().getResource("6773084.policy").getFile());
-    }
-
     @Test
     public void test() throws Exception {
         SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -94,7 +96,7 @@
         for (int i = 0; i < files.length; i++) {
             EXEC.execute(new XMLValiddator(files[i], i));
         }
-        EXEC.shutdown();
+        runWithAllPerm(() -> EXEC.shutdown());
 
     }
 
@@ -164,3 +166,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6859210.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6859210.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,15 +32,21 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 6859210
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6859210
+ * @run testng/othervm validation.Bug6859210
  * @summary Test Schema Validator can parse xml when maxOccurs is large.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6859210 {
 
     boolean errorFound;
@@ -94,3 +100,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6925531Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6925531Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,7 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -47,9 +48,14 @@
 import org.xml.sax.SAXNotSupportedException;
 
 /*
+ * @test
  * @bug 6925531
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6925531Test
+ * @run testng/othervm validation.Bug6925531Test
  * @summary Test Validator can validate SAXSource when SecurityManager is set or FEATURE_SECURE_PROCESSING is on.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug6925531Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -204,3 +210,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6946312Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6946312Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -44,9 +45,14 @@
 import org.xml.sax.XMLReader;
 
 /*
+ * @test
  * @bug 6946312
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6946312Test
+ * @run testng/othervm validation.Bug6946312Test
  * @summary Test XML parser shall callback to ContentHandler when receiving characters data.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6946312Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -122,3 +128,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6954738_Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6954738_Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,21 @@
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 6954738
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Bug6954738_Test
+ * @run testng/othervm validation.Bug6954738_Test
  * @summary Test Validator can process a XML document containing an element with 8000 characters.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6954738_Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -77,3 +83,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/CR6708840Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/CR6708840Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,12 +38,18 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6708840
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.CR6708840Test
+ * @run testng/othervm validation.CR6708840Test
  * @summary Test Validator can process StAXSource.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6708840Test {
 
     @Test
@@ -134,3 +140,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/CR6740048.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/CR6740048.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 import org.w3c.dom.Document;
@@ -38,9 +39,14 @@
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
  * @bug 6740048
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.CR6740048
+ * @run testng/othervm validation.CR6740048
  * @summary Test DocumentBuilder can be reused when the DocumentBuilderFactory sets schema.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class CR6740048 {
     private static final String TAG_INFO = "containerInfo";
     private static final String SCHEMA_LANGUAGE_URL = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
@@ -51,9 +57,6 @@
     public final void testReusingDocumentBuilder() {
 
         try {
-            //ClassLoader loader = CR6740048.class.getClassLoader();
-
-            // Object xsd = loader.getResourceAsStream("CR6740048.xsd");
             InputStream xsd = this.getClass().getResourceAsStream("CR6740048.xsd");
             // create document builder
             DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
@@ -128,3 +131,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/ErrorHandlerImpl.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ErrorHandlerImpl.java	Mon Aug 08 12:50:00 2016 +0800
@@ -45,3 +45,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Issue682Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Issue682Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.testng.Assert;
 import org.xml.sax.InputSource;
@@ -39,8 +40,13 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.Issue682Test
+ * @run testng/othervm validation.Issue682Test
  * @summary Test comination of fields in <xsd:unique>, for https://issues.apache.org/jira/browse/XERCESJ-682.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Issue682Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -72,3 +78,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/IssueTracker30.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/IssueTracker30.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.IssueTracker30
+ * @run testng/othervm validation.IssueTracker30
  * @summary Test maxOccurs validation.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class IssueTracker30 {
 
     boolean errorFound;
@@ -126,3 +132,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue43Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue43Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,15 +38,21 @@
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
 /*
+ * @test
  * @bug 6631318
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.JaxpIssue43Test
+ * @run testng/othervm validation.JaxpIssue43Test
  * @summary Test creating schema from a DOM fragment with namespace.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class JaxpIssue43Test {
 
     @Test
@@ -78,3 +84,4 @@
         return list.toArray(new Source[list.size()]);
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue49.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue49.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,13 +38,19 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Node;
 
 /*
+ * @test
  * @bug 6684227
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.JaxpIssue49
+ * @run testng/othervm validation.JaxpIssue49
  * @summary Test property current-element-node works.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class JaxpIssue49 {
 
     private Schema schema;
@@ -88,3 +94,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/LargeMaxOccursTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/LargeMaxOccursTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,11 +31,17 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.LargeMaxOccursTest
+ * @run testng/othervm validation.LargeMaxOccursTest
  * @summary Test Validator shall report error for maxOccurs > 5000 when FEATURE_SECURE_PROCESSING is on, except the schema can be applied for constant-space algorithm.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class LargeMaxOccursTest {
 
     @Test
@@ -103,3 +109,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.MultiOccursTest
+ * @run testng/othervm validation.MultiOccursTest
  * @summary Test Schema Validator can parse multiple or unbounded occurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class MultiOccursTest {
 
     boolean errorFound;
@@ -141,3 +147,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursUnboundedTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursUnboundedTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.MultiOccursUnboundedTest
+ * @run testng/othervm validation.MultiOccursUnboundedTest
  * @summary Test Schema Validator can parse multiple or unbounded occurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class MultiOccursUnboundedTest {
 
     boolean errorFound;
@@ -109,3 +115,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.OccursTest
+ * @run testng/othervm validation.OccursTest
  * @summary Test Schema Validator can parse multiple or unbounded occurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class OccursTest {
 
     boolean errorFound;
@@ -141,3 +147,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursUnboundedTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursUnboundedTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.OccursUnboundedTest
+ * @run testng/othervm validation.OccursUnboundedTest
  * @summary Test Schema Validator can parse multiple or unbounded occurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class OccursUnboundedTest {
 
     boolean errorFound;
@@ -109,3 +115,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.OccursWildcardTest
+ * @run testng/othervm validation.OccursWildcardTest
  * @summary Test Schema Validator can parse multiple or unbounded occurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class OccursWildcardTest {
 
     boolean errorFound;
@@ -141,3 +147,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardUnbounded.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardUnbounded.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.OccursWildcardUnbounded
+ * @run testng/othervm validation.OccursWildcardUnbounded
  * @summary Test Schema Validator can parse multiple or unbounded occurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class OccursWildcardUnbounded {
 
     boolean errorFound;
@@ -109,3 +115,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesId005Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesId005Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.ParticlesId005Test
+ * @run testng/othervm validation.ParticlesId005Test
  * @summary Test Schema Validator can parse multiple or unbounded occurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class ParticlesId005Test {
 
     boolean errorFound;
@@ -93,3 +99,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesIg004Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesIg004Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,11 +31,17 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.ParticlesIg004Test
+ * @run testng/othervm validation.ParticlesIg004Test
  * @summary Test particlesIg004.xsd.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class ParticlesIg004Test {
 
     @Test
@@ -51,3 +57,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesQ013Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesQ013Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,20 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.ParticlesQ013Test
+ * @run testng/othervm validation.ParticlesQ013Test
  * @summary Test Schema Validator can parse multiple or unbounded occurs.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class ParticlesQ013Test {
 
     boolean errorFound;
@@ -92,3 +98,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/SchemaTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/SchemaTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -28,12 +28,18 @@
 import javax.xml.XMLConstants;
 import javax.xml.validation.SchemaFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.SchemaTest
+ * @run testng/othervm validation.SchemaTest
  * @summary Test Schema creation
  * @bug 8149915
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class SchemaTest {
 
     /*
@@ -48,3 +54,4 @@
         factory.newSchema(new File(getClass().getResource("Bug8149915.xsd").getFile()));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/TCKGroupA008Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/TCKGroupA008Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,12 +30,18 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.TCKGroupA008Test
+ * @run testng/othervm validation.TCKGroupA008Test
  * @summary Test groupA008.xsd.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class TCKGroupA008Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -54,3 +60,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/ValidatorTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ValidatorTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,12 @@
 
 package validation;
 
+import static jaxp.library.JAXPTestUtilities.runWithTmpPermission;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileWriter;
+import java.util.PropertyPermission;
 
 import javax.xml.XMLConstants;
 import javax.xml.stream.XMLEventReader;
@@ -39,12 +42,18 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.ValidatorTest
+ * @run testng/othervm validation.ValidatorTest
  * @summary Test Validator.validate(Source, Result).
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class ValidatorTest {
 
     @Test
@@ -83,10 +92,11 @@
             if (resultFile.exists()) {
                 resultFile.delete();
             }
-
             // Validate this instance document against the
             // Instance document supplied
-            Result xmlResult = new javax.xml.transform.stream.StreamResult(resultFile);
+            File resultAlias = resultFile;
+            Result xmlResult = runWithTmpPermission(() -> new javax.xml.transform.stream.StreamResult(
+                    resultAlias), new PropertyPermission("user.dir", "read"));
             Source xmlSource = new javax.xml.transform.stream.StreamSource(new File(ValidatorTest.class.getResource("toys.xml").toURI()));
 
             validate("toys.xsd", xmlSource, xmlResult);
@@ -114,7 +124,9 @@
 
             // Validate this instance document against the
             // Instance document supplied
-            Result xmlResult = new javax.xml.transform.stream.StreamResult(resultFile);
+            File resultAlias = resultFile;
+            Result xmlResult = runWithTmpPermission(() -> new javax.xml.transform.stream.StreamResult(
+                    resultAlias), new PropertyPermission("user.dir", "read"));
             Source xmlSource = new javax.xml.transform.stream.StreamSource(new File(ValidatorTest.class.getResource("gMonths.xml").toURI()));
 
             validate("gMonths.xsd", xmlSource, xmlResult);
@@ -196,3 +208,4 @@
         return xmlr;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/XMLDocBuilder.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/XMLDocBuilder.java	Mon Aug 08 12:50:00 2016 +0800
@@ -141,3 +141,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/XMLSchemaValidator.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/XMLSchemaValidator.java	Mon Aug 08 12:50:00 2016 +0800
@@ -59,3 +59,4 @@
         validator.validate(new DOMSource(node));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6943252Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6943252Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -31,13 +31,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6943252
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6943252Test
+ * @run testng/othervm validation.tck.Bug6943252Test
  * @summary Test Schema doesn't allow to use value more than allowed by base type.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6943252Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -63,3 +69,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963124Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963124Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,13 +29,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6963124
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6963124Test
+ * @run testng/othervm validation.tck.Bug6963124Test
  * @summary Test Schema doesn't allow maxOccurs > 1 for reference to all model group.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6963124Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -55,3 +61,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963468Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963468Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -36,6 +36,7 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
@@ -45,9 +46,14 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6963468
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6963468Test
+ * @run testng/othervm validation.tck.Bug6963468Test
  * @summary Test Validation allows element a is a union type and element b specifies a as its substitution group and b type is or is derived from one of the member types of the union.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6963468Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -142,3 +148,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6964720Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6964720Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,13 +29,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6964720
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6964720Test
+ * @run testng/othervm validation.tck.Bug6964720Test
  * @summary Test Schema doesn't allow the inexpressible union of two attribute wildcards.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6964720Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -52,3 +58,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6967214Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6967214Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -31,13 +31,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6967214
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6967214Test
+ * @run testng/othervm validation.tck.Bug6967214Test
  * @summary Test Schema doesn't allow unpaired parenthesises in regex.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6967214Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -64,3 +70,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6970890Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6970890Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,13 +29,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6970890
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6970890Test
+ * @run testng/othervm validation.tck.Bug6970890Test
  * @summary Test Schema allows [-] in regex.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6970890Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -66,3 +72,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6971190Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6971190Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -32,13 +32,19 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6971190
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6971190Test
+ * @run testng/othervm validation.tck.Bug6971190Test
  * @summary Test Validation accepts UTF lexical presentation.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6971190Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -96,3 +102,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6974551Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6974551Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -34,15 +34,21 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6974551
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6974551Test
+ * @run testng/othervm validation.tck.Bug6974551Test
  * @summary Test Validation for SAXParser can expose whitespace facet for xs:anySimpleType.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6974551Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -116,3 +122,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6975265Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6975265Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -31,13 +31,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 6975265
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6975265Test
+ * @run testng/othervm validation.tck.Bug6975265Test
  * @summary Test Schema doesn't allow some Element Information Items contain other element information item.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6975265Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -65,3 +71,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6977201Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6977201Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -30,12 +30,18 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6977201
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6977201Test
+ * @run testng/othervm validation.tck.Bug6977201Test
  * @summary Test Validator interprets regex "" correctly.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6977201Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -65,3 +71,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6989956Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6989956Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -36,6 +36,7 @@
 import javax.xml.validation.Validator;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
@@ -45,9 +46,14 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
+ * @test
  * @bug 6989956
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug6989956Test
+ * @run testng/othervm validation.tck.Bug6989956Test
  * @summary Test Validation can process correctly that maxOccurs in Choice less than maxOccurs in Elements contained in the Choice.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug6989956Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -142,3 +148,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug7014246Test.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug7014246Test.java	Mon Aug 08 12:50:00 2016 +0800
@@ -29,13 +29,19 @@
 import javax.xml.validation.SchemaFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 7014246
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.Bug7014246Test
+ * @run testng/othervm validation.tck.Bug7014246Test
  * @summary Test Schema doesn't allow maxInclusive of derived time type greater than the base.
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class Bug7014246Test {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -53,3 +59,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/ParticleTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/ParticleTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,16 +28,22 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 
 /*
+ * @test
  * @bug 8142463
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.ParticleTest
+ * @run testng/othervm validation.tck.ParticleTest
  * @summary Tests that verify bug fixes for Particles (http://www.w3.org/TR/xmlschema11-1/#cParticles)
 
  * @author Joe Wang (huizhe.wang@oracle.com)
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class ParticleTest {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -57,3 +63,4 @@
         validator.validate(new StreamSource(ParticleTest.class.getResourceAsStream("upa01.xml")));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/RegexWord.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/RegexWord.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,15 +28,21 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
  * @bug 8142900
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true validation.tck.RegexWord
+ * @run testng/othervm validation.tck.RegexWord
  * @summary Verifies that all characters except the set of "punctuation",
  * "separator" and "other" characters are accepted by \w [#x0000-#x10FFFF]-[\p{P}\p{Z}\p{C}]
  * @author Joe Wang
  */
+@Listeners({jaxp.library.FilePolicy.class})
 public class RegexWord {
     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
@@ -57,3 +63,4 @@
         validator.validate(new StreamSource(RegexWord.class.getResourceAsStream("reZ003vExc23082309.xml")));
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991857.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991857.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,14 +29,20 @@
 import javax.xml.xpath.XPathFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 
 
 /*
+ * @test
  * @bug 4991857
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.Bug4991857
+ * @run testng/othervm xpath.Bug4991857
  * @summary XPath.evaluate(...) throws XPathExpressionException when context is null and expression refers to the context.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4991857 {
 
     Document d = null;
@@ -86,3 +92,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991939.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991939.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,12 +29,18 @@
 import javax.xml.xpath.XPathFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 4991939
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.Bug4991939
+ * @run testng/othervm xpath.Bug4991939
  * @summary XPath.evaluate(...) throws IllegalArgumentException if returnType is not one of the types defined in XPathConstants.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4991939 {
 
     @Test
@@ -55,3 +61,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992788.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992788.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,13 +31,19 @@
 import javax.xml.xpath.XPathFactoryConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 4992788
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.Bug4992788
+ * @run testng/othervm xpath.Bug4992788
  * @summary Test XPath.evaluate(expression,source,returnType) throws NPE if source is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4992788 {
 
     private static String expression = "/widgets/widget[@name='a']/@quantity";
@@ -76,3 +82,4 @@
         return xpath;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992793.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992793.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,13 +33,19 @@
 import javax.xml.xpath.XPathFactoryConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 4992793
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.Bug4992793
+ * @run testng/othervm xpath.Bug4992793
  * @summary Test XPath.evaluate(expression,source,returnType) throws NPE if expression is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4992793 {
 
 
@@ -77,3 +83,4 @@
         return xpath;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992805.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992805.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,13 +32,19 @@
 import javax.xml.xpath.XPathFactoryConfigurationException;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.xml.sax.InputSource;
 
 /*
+ * @test
  * @bug 4992805
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.Bug4992805
+ * @run testng/othervm xpath.Bug4992805
  * @summary Test XPath.evaluate(expression,source,returnType) throws NPE if returnType is null.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class Bug4992805 {
 
     private static String expression = "/widgets/widget[@name='a']/@quantity";
@@ -64,3 +70,4 @@
         return xpath;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/ClassLoaderTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/ClassLoaderTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,21 +23,29 @@
 
 package xpath;
 
+import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
+
 import javax.xml.xpath.XPathFactory;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6354969
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.ClassLoaderTest
+ * @run testng/othervm xpath.ClassLoaderTest
  * @summary Test XPathFactory newInstance() with ContextClassLoader.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class ClassLoaderTest {
 
     @Test
     public void testClassLoader() {
-        MyClassLoader cl = new MyClassLoader();
-        Thread.currentThread().setContextClassLoader(cl);
+        MyClassLoader cl = runWithAllPerm(() -> new MyClassLoader());
+        runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(cl));
         XPathFactory xPathFactory = XPathFactory.newInstance();
 
         if (!cl.isCalled()) {
@@ -46,3 +54,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/MyClassLoader.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/MyClassLoader.java	Mon Aug 08 12:50:00 2016 +0800
@@ -47,3 +47,4 @@
         return isCalled;
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,26 +43,23 @@
 import javax.xml.xpath.XPathFunctionResolver;
 
 import org.testng.Assert;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
 /*
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.SecureProcessingTest
+ * @run testng/othervm xpath.SecureProcessingTest
  * @summary Test when FEATURE_SECURE_PROCESSING is true, calling an external function will cause XPathFunctionException.
  */
+@Test
+@Listeners({jaxp.library.FilePolicy.class})
 public class SecureProcessingTest {
-    static boolean _isSecureMode = false;
-    static {
-        if (System.getSecurityManager() != null) {
-            _isSecureMode = true;
-            System.out.println("Security Manager is present");
-        } else {
-            System.out.println("Security Manager is NOT present");
-        }
-    }
-
-    @Test
     public final void testSecureProcessing() {
+        boolean _isSecureMode = System.getSecurityManager() != null;
 
         final String XPATH_EXPRESSION = "ext:helloWorld()";
 
@@ -150,7 +147,7 @@
         }
     }
 
-    public class MyXPathFunctionResolver implements XPathFunctionResolver {
+    private class MyXPathFunctionResolver implements XPathFunctionResolver {
 
         public XPathFunction resolveFunction(QName functionName, int arity) {
 
@@ -159,7 +156,7 @@
         }
     }
 
-    public class MyXPathFunction implements XPathFunction {
+    private class MyXPathFunction implements XPathFunction {
 
         public Object evaluate(List list) throws XPathFunctionException {
 
@@ -167,7 +164,7 @@
         }
     }
 
-    public class MyNamespaceContext implements NamespaceContext {
+    private class MyNamespaceContext implements NamespaceContext {
 
         public String getNamespaceURI(String prefix) {
             if (prefix == null) {
@@ -199,3 +196,4 @@
         }
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathAnyTypeTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathAnyTypeTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,15 +32,21 @@
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
 /*
+ * @test
  * @bug 8054196
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.XPathAnyTypeTest
+ * @run testng/othervm xpath.XPathAnyTypeTest
  * @summary Test for the project XPath: support any type. This test covers the new
  * evaluateExpression methods of XPath, as well as XPathNodes and XPathEvaluationResult.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class XPathAnyTypeTest extends XPathTestBase {
     /*
      Test for resolveFunction(QName functionName,int arity); evaluate throws
@@ -194,3 +200,4 @@
         verifyResult(result, "Customer");
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathExpAnyTypeTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathExpAnyTypeTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,15 +34,21 @@
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
 /*
+ * @test
  * @bug 8054196
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.XPathExpAnyTypeTest
+ * @run testng/othervm xpath.XPathExpAnyTypeTest
  * @summary Test for the project XPath: support any type. This test covers the new
  * evaluateExpression methods of XPathExpression.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class XPathExpAnyTypeTest extends XPathTestBase {
 
     /*
@@ -181,3 +187,4 @@
     }
 
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathTest.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathTest.java	Mon Aug 08 12:50:00 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,18 @@
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathFactory;
 
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 /*
+ * @test
  * @bug 6376058
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true xpath.XPathTest
+ * @run testng/othervm xpath.XPathTest
  * @summary Test XPath.getNamespaceContext() is supported.
  */
+@Listeners({jaxp.library.BasePolicy.class})
 public class XPathTest {
 
     @Test
@@ -45,3 +51,4 @@
 
     }
 }
+
--- a/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathTestBase.java	Thu Aug 04 17:47:31 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathTestBase.java	Mon Aug 08 12:50:00 2016 +0800
@@ -115,7 +115,7 @@
      * DataProvider: XPath object
      */
     @DataProvider(name = "xpath")
-    Object[][] getXPath() {
+    public Object[][] getXPath() {
         return new Object[][]{{XPathFactory.newInstance().newXPath()}};
     }
 
@@ -123,7 +123,7 @@
      * DataProvider: Numeric types not supported
      */
     @DataProvider(name = "invalidNumericTypes")
-    Object[][] getInvalidNumericTypes() {
+    public Object[][] getInvalidNumericTypes() {
         XPath xpath = XPathFactory.newInstance().newXPath();
         return new Object[][]{{xpath, AtomicInteger.class},
             {xpath, AtomicInteger.class},
@@ -140,7 +140,7 @@
      * DataProvider: XPath and Document objects
      */
     @DataProvider(name = "document")
-    Object[][] getDocument() throws Exception {
+    public Object[][] getDocument() throws Exception {
         DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
         dBF.setValidating(false);
         dBF.setNamespaceAware(true);