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.XMLEventReaderTest; 25 26 import java.io.File; 27 28 import javax.xml.stream.XMLEventReader; 29 import javax.xml.stream.XMLInputFactory; 30 import javax.xml.stream.XMLOutputFactory; 31 import javax.xml.stream.XMLStreamConstants; 32 import javax.xml.stream.events.XMLEvent; 33 34 import org.testng.Assert; 35 import org.testng.annotations.Test; 36 37 /* 38 * @summary Test XMLEventReader.getElementText() works after calling peek(). 39 */ 40 public class Issue40Test { 41 42 public java.io.File input; 43 public final String filesDir = "./"; 44 protected XMLInputFactory inputFactory; 45 protected XMLOutputFactory outputFactory; 46 47 /** 48 * test without peek 49 */ 50 @Test 51 public void testWOPeek() { 52 try { 53 XMLEventReader er = getReader(); 54 XMLEvent e = er.nextEvent(); 55 Assert.assertEquals(e.getEventType(), XMLStreamConstants.START_DOCUMENT); 56 // we have two start elements in this file 57 Assert.assertEquals(er.nextEvent().getEventType(), XMLStreamConstants.START_ELEMENT); 58 Assert.assertEquals(er.nextEvent().getEventType(), XMLStreamConstants.START_ELEMENT); 59 System.out.println(er.getElementText()); | 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.XMLEventReaderTest; 25 26 import java.io.File; 27 28 import javax.xml.stream.XMLEventReader; 29 import javax.xml.stream.XMLInputFactory; 30 import javax.xml.stream.XMLOutputFactory; 31 import javax.xml.stream.XMLStreamConstants; 32 import javax.xml.stream.events.XMLEvent; 33 34 import org.testng.Assert; 35 import org.testng.annotations.Listeners; 36 import org.testng.annotations.Test; 37 38 /* 39 * @summary Test XMLEventReader.getElementText() works after calling peek(). 40 */ 41 @Listeners({jaxp.library.FilePolicy.class}) 42 public class Issue40Test { 43 44 public java.io.File input; 45 public final String filesDir = "./"; 46 protected XMLInputFactory inputFactory; 47 protected XMLOutputFactory outputFactory; 48 49 /** 50 * test without peek 51 */ 52 @Test 53 public void testWOPeek() { 54 try { 55 XMLEventReader er = getReader(); 56 XMLEvent e = er.nextEvent(); 57 Assert.assertEquals(e.getEventType(), XMLStreamConstants.START_DOCUMENT); 58 // we have two start elements in this file 59 Assert.assertEquals(er.nextEvent().getEventType(), XMLStreamConstants.START_ELEMENT); 60 Assert.assertEquals(er.nextEvent().getEventType(), XMLStreamConstants.START_ELEMENT); 61 System.out.println(er.getElementText()); |