< prev index next >

test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 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. --- 1,7 ---- /* ! * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 21,61 **** * questions. */ package javax.xml.transform.ptests; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMSource; - import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; import 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.Test; import org.xml.sax.InputSource; /** * Unit test for SAXSource sourceToInputSource API. */ ! public class SAXSourceTest extends JAXPFileReadOnlyBaseTest { /** * Test style-sheet file name */ private final String TEST_FILE = XML_DIR + "cities.xsl"; /** * Test obtaining a SAX InputSource object from a Source object. * * @throws IOException reading file error. */ ! @Test(groups = {"readLocalFiles"}) public void source2inputsource01() throws IOException { try (FileInputStream fis = new FileInputStream(TEST_FILE)) { StreamSource streamSource = new StreamSource(fis); assertNotNull(SAXSource.sourceToInputSource(streamSource)); } --- 21,65 ---- * questions. */ 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 javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; ! ! import org.testng.annotations.Listeners; import org.testng.annotations.Test; import org.xml.sax.InputSource; /** * Unit test for SAXSource sourceToInputSource API. */ ! @Listeners({jaxp.library.FilePolicy.class}) ! public class SAXSourceTest { /** * Test style-sheet file name */ private final String TEST_FILE = XML_DIR + "cities.xsl"; /** * Test obtaining a SAX InputSource object from a Source object. * * @throws IOException reading file error. */ ! @Test public void source2inputsource01() throws IOException { try (FileInputStream fis = new FileInputStream(TEST_FILE)) { StreamSource streamSource = new StreamSource(fis); assertNotNull(SAXSource.sourceToInputSource(streamSource)); }
*** 66,76 **** * sourceToInputSource method. It is not possible and hence null is * expected. This is a negative test case, * * @throws Exception If any errors occur. */ ! @Test(groups = {"readLocalFiles"}) public void source2inputsource02() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.newDocumentBuilder().parse(new File(TEST_FILE)); assertNull(SAXSource.sourceToInputSource(new DOMSource(null))); --- 70,80 ---- * sourceToInputSource method. It is not possible and hence null is * expected. This is a negative test case, * * @throws Exception If any errors occur. */ ! @Test public void source2inputsource02() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.newDocumentBuilder().parse(new File(TEST_FILE)); assertNull(SAXSource.sourceToInputSource(new DOMSource(null)));
*** 81,91 **** * sourceToInputSource method. This will also check if the systemId * remained the same. This is a positive test case. * * @throws IOException reading file error. */ ! @Test(groups = {"readLocalFiles"}) public void source2inputsource03() throws IOException { String SYSTEM_ID = "file:///" + XML_DIR; try (FileInputStream fis = new FileInputStream(TEST_FILE)) { SAXSource saxSource = new SAXSource(new InputSource(fis)); --- 85,95 ---- * sourceToInputSource method. This will also check if the systemId * remained the same. This is a positive test case. * * @throws IOException reading file error. */ ! @Test public void source2inputsource03() throws IOException { String SYSTEM_ID = "file:///" + XML_DIR; try (FileInputStream fis = new FileInputStream(TEST_FILE)) { SAXSource saxSource = new SAXSource(new InputSource(fis));
< prev index next >