< prev index next >
test/jaxp/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/StreamReaderTest.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* 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.
@@ -18,13 +18,14 @@
*
* 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 stream.XMLStreamReaderTest;
+import java.io.StringReader;
+import java.util.NoSuchElementException;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
import org.testng.Assert;
@@ -32,18 +33,32 @@
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/*
* @test
- * @bug 8167340
+ * @bug 8167340 8204329
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
* @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.StreamReaderTest
* @run testng/othervm stream.XMLStreamReaderTest.StreamReaderTest
* @summary Verifies patches for StreamReader bugs
*/
@Listeners({jaxp.library.FilePolicy.class})
public class StreamReaderTest {
+ @Test(expectedExceptions = NoSuchElementException.class)
+ public void testNext() throws Exception {
+ XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
+ XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(
+ new StringReader("<?xml version='1.0'?><foo/>"));
+
+ while (xmlStreamReader.hasNext()) {
+ int event = xmlStreamReader.next();
+ }
+ // no more event
+ xmlStreamReader.next();
+ }
+
+
/**
* Verifies that after switching to a different XML Version (1.1), the parser
* is initialized properly (the listener was not registered in this case).
*
* @param path the path to XML source
< prev index next >