< prev index next >

test/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package test.astro;
  24 
  25 import static jaxp.library.JAXPTestUtilities.filenameToURL;
  26 import static org.testng.Assert.assertEquals;
  27 import static org.testng.Assert.assertNotNull;
  28 import static org.testng.Assert.assertNull;
  29 import static org.testng.Assert.assertTrue;
  30 import static org.w3c.dom.ls.DOMImplementationLS.MODE_SYNCHRONOUS;
  31 import static test.astro.AstroConstants.ASTROCAT;
  32 
  33 import java.io.FileInputStream;
  34 import java.io.FileOutputStream;
  35 import java.io.InputStream;
  36 import java.io.OutputStream;
  37 import java.io.Writer;
  38 
  39 import javax.xml.parsers.DocumentBuilder;
  40 import javax.xml.parsers.DocumentBuilderFactory;
  41 import javax.xml.parsers.ParserConfigurationException;
  42 
  43 import jaxp.library.JAXPFileBaseTest;
  44 
  45 import org.testng.annotations.Test;
  46 import org.w3c.dom.Document;
  47 import org.w3c.dom.Element;
  48 import org.w3c.dom.ls.DOMImplementationLS;
  49 import org.w3c.dom.ls.LSInput;
  50 import org.w3c.dom.ls.LSOutput;
  51 import org.w3c.dom.ls.LSParser;
  52 import org.w3c.dom.ls.LSSerializer;
  53 
  54 /*
  55  * @summary org.w3c.dom.ls tests
  56  */
  57 public class DocumentLSTest extends JAXPFileBaseTest {

  58     /*
  59      * Test creating an empty Document
  60      */
  61     @Test
  62     public void testNewDocument() throws ParserConfigurationException {
  63         Document doc = getDocumentBuilder().newDocument();
  64         assertNull(doc.getDocumentElement());
  65     }
  66 
  67     /*
  68      * Test creating an LSInput instance, and parsing ByteStream
  69      */
  70     @Test
  71     public void testLSInputParsingByteStream() throws Exception {
  72         DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
  73         LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
  74         LSInput src = impl.createLSInput();
  75 
  76         try (InputStream is = new FileInputStream(ASTROCAT)) {
  77             src.setByteStream(is);


   1 /*
   2  * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package test.astro;
  24 
  25 import static jaxp.library.JAXPTestUtilities.filenameToURL;
  26 import static org.testng.Assert.assertEquals;
  27 import static org.testng.Assert.assertNotNull;
  28 import static org.testng.Assert.assertNull;
  29 import static org.testng.Assert.assertTrue;
  30 import static org.w3c.dom.ls.DOMImplementationLS.MODE_SYNCHRONOUS;
  31 import static test.astro.AstroConstants.ASTROCAT;
  32 
  33 import java.io.FileInputStream;
  34 import java.io.FileOutputStream;
  35 import java.io.InputStream;
  36 import java.io.OutputStream;
  37 import java.io.Writer;
  38 
  39 import javax.xml.parsers.DocumentBuilder;
  40 import javax.xml.parsers.DocumentBuilderFactory;
  41 import javax.xml.parsers.ParserConfigurationException;
  42 
  43 import org.testng.annotations.Listeners;

  44 import org.testng.annotations.Test;
  45 import org.w3c.dom.Document;
  46 import org.w3c.dom.Element;
  47 import org.w3c.dom.ls.DOMImplementationLS;
  48 import org.w3c.dom.ls.LSInput;
  49 import org.w3c.dom.ls.LSOutput;
  50 import org.w3c.dom.ls.LSParser;
  51 import org.w3c.dom.ls.LSSerializer;
  52 
  53 /*
  54  * @summary org.w3c.dom.ls tests
  55  */
  56 @Listeners({jaxp.library.FilePolicy.class})
  57 public class DocumentLSTest {
  58     /*
  59      * Test creating an empty Document
  60      */
  61     @Test
  62     public void testNewDocument() throws ParserConfigurationException {
  63         Document doc = getDocumentBuilder().newDocument();
  64         assertNull(doc.getDocumentElement());
  65     }
  66 
  67     /*
  68      * Test creating an LSInput instance, and parsing ByteStream
  69      */
  70     @Test
  71     public void testLSInputParsingByteStream() throws Exception {
  72         DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
  73         LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
  74         LSInput src = impl.createLSInput();
  75 
  76         try (InputStream is = new FileInputStream(ASTROCAT)) {
  77             src.setByteStream(is);


< prev index next >