< prev index next >

test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker35.java

Print this page




  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 
  24 package stream.XMLStreamReaderTest;
  25 
  26 import java.io.InputStream;
  27 
  28 import javax.xml.stream.XMLInputFactory;
  29 import javax.xml.stream.XMLStreamConstants;
  30 import javax.xml.stream.XMLStreamReader;
  31 
  32 import org.testng.Assert;

  33 import org.testng.annotations.Test;
  34 
  35 /*
  36  * @summary Test StAX parse xsd document including external DTD.
  37  */

  38 public class IssueTracker35 {
  39 
  40     @Test
  41     public void testSkippingExternalDTD() throws Exception {
  42         XMLInputFactory xif = XMLInputFactory.newInstance();
  43         try(
  44                 InputStream is= getClass().getResourceAsStream("XMLSchema.xsd");
  45         ) {
  46                 XMLStreamReader reader = xif.createXMLStreamReader(getClass().getResource("XMLSchema.xsd").getFile(), is);
  47                 int e;
  48                 while ((e = reader.next()) == XMLStreamConstants.COMMENT);
  49 
  50                 Assert.assertEquals(e, XMLStreamConstants.DTD, "should be DTD");
  51                 reader.nextTag();
  52                 Assert.assertEquals(reader.getLocalName(), "schema", "next tag should be schema");
  53         }
  54     }
  55 }


  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 
  24 package stream.XMLStreamReaderTest;
  25 
  26 import java.io.InputStream;
  27 
  28 import javax.xml.stream.XMLInputFactory;
  29 import javax.xml.stream.XMLStreamConstants;
  30 import javax.xml.stream.XMLStreamReader;
  31 
  32 import org.testng.Assert;
  33 import org.testng.annotations.Listeners;
  34 import org.testng.annotations.Test;
  35 
  36 /*
  37  * @summary Test StAX parse xsd document including external DTD.
  38  */
  39 @Listeners({jaxp.library.FilePolicy.class})
  40 public class IssueTracker35 {
  41 
  42     @Test
  43     public void testSkippingExternalDTD() throws Exception {
  44         XMLInputFactory xif = XMLInputFactory.newInstance();
  45         try(
  46                 InputStream is= getClass().getResourceAsStream("XMLSchema.xsd");
  47         ) {
  48                 XMLStreamReader reader = xif.createXMLStreamReader(getClass().getResource("XMLSchema.xsd").getFile(), is);
  49                 int e;
  50                 while ((e = reader.next()) == XMLStreamConstants.COMMENT);
  51 
  52                 Assert.assertEquals(e, XMLStreamConstants.DTD, "should be DTD");
  53                 reader.nextTag();
  54                 Assert.assertEquals(reader.getLocalName(), "schema", "next tag should be schema");
  55         }
  56     }
  57 }
< prev index next >