IssueTracker24.java revision 997:540334ae53fe
1139735Simp/* 2129198Scognet * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3129198Scognet * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4129198Scognet * 5129198Scognet * This code is free software; you can redistribute it and/or modify it 6129198Scognet * under the terms of the GNU General Public License version 2 only, as 7129198Scognet * published by the Free Software Foundation. 8129198Scognet * 9129198Scognet * This code is distributed in the hope that it will be useful, but WITHOUT 10129198Scognet * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11129198Scognet * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12129198Scognet * version 2 for more details (a copy is included in the LICENSE file that 13129198Scognet * accompanied this code). 14129198Scognet * 15129198Scognet * You should have received a copy of the GNU General Public License version 16129198Scognet * 2 along with this work; if not, write to the Free Software Foundation, 17129198Scognet * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18129198Scognet * 19129198Scognet * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20129198Scognet * or visit www.oracle.com if you need additional information or have any 21129198Scognet * questions. 22129198Scognet */ 23129198Scognet 24129198Scognetpackage stream.XMLStreamReaderTest; 25129198Scognet 26129198Scognetimport java.io.StringReader; 27129198Scognet 28129198Scognetimport javax.xml.stream.XMLInputFactory; 29129198Scognetimport javax.xml.stream.XMLStreamReader; 30129198Scognet 31129198Scognetimport org.testng.Assert; 32129198Scognetimport org.testng.annotations.Listeners; 33129198Scognetimport org.testng.annotations.Test; 34129198Scognet 35129198Scognet/* 36129198Scognet * @test 37129198Scognet * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest 38129198Scognet * @run testng/othervm -DrunSecMngr=true stream.XMLStreamReaderTest.IssueTracker24 39129198Scognet * @run testng/othervm stream.XMLStreamReaderTest.IssueTracker24 40143857Scognet * @summary Test no prefix is represented by "", not null. 41143857Scognet */ 42143857Scognet@Listeners({jaxp.library.BasePolicy.class}) 43143857Scognetpublic class IssueTracker24 { 44143857Scognet 45143857Scognet @Test 46129198Scognet public void testInconsistentGetPrefixBehaviorWhenNoPrefix() throws Exception { 47143857Scognet String xml = "<root><child xmlns='foo'/><anotherchild/></root>"; 48132383Sdas 49143857Scognet XMLInputFactory factory = XMLInputFactory.newInstance(); 50129198Scognet XMLStreamReader r = factory.createXMLStreamReader(new StringReader(xml)); 51129198Scognet r.require(XMLStreamReader.START_DOCUMENT, null, null); 52129198Scognet r.next(); 53129198Scognet r.require(XMLStreamReader.START_ELEMENT, null, "root"); 54129198Scognet Assert.assertEquals(r.getPrefix(), "", "prefix should be empty string"); 55129198Scognet r.next(); 56129198Scognet r.require(XMLStreamReader.START_ELEMENT, null, "child"); 57129198Scognet r.next(); 58129198Scognet r.next(); 59129198Scognet r.require(XMLStreamReader.START_ELEMENT, null, "anotherchild"); 60129198Scognet Assert.assertEquals(r.getPrefix(), "", "prefix should be empty string"); 61129198Scognet } 62129198Scognet 63129198Scognet} 64129198Scognet