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 stream.CoalesceTest; 24 25 import java.io.File; 26 import java.io.FileInputStream; 27 import java.io.InputStream; 28 29 import javax.xml.stream.XMLInputFactory; 30 import javax.xml.stream.XMLStreamConstants; 31 import javax.xml.stream.XMLStreamException; 32 import javax.xml.stream.XMLStreamReader; 33 34 import org.testng.Assert; 35 import org.testng.annotations.Test; 36 37 /* 38 * @summary Test Coalesce property works. 39 */ 40 public class CoalesceTest { 41 42 String countryElementContent = "START India CS}}}}}} India END"; 43 String descriptionElementContent = "a&b"; 44 String fooElementContent = "&< cdatastart<><>>><>><<<<cdataend entitystart insert entityend"; 45 46 @Test 47 public void testCoalesceProperty() { 48 try { 49 XMLInputFactory xifactory = XMLInputFactory.newInstance(); 50 xifactory.setProperty(XMLInputFactory.IS_COALESCING, new Boolean(true)); 51 InputStream xml = this.getClass().getResourceAsStream("coalesce.xml"); 52 XMLStreamReader streamReader = xifactory.createXMLStreamReader(xml); 53 while (streamReader.hasNext()) { 54 int eventType = streamReader.next(); 55 if (eventType == XMLStreamConstants.START_ELEMENT && streamReader.getLocalName().equals("country")) { 56 eventType = streamReader.next(); 57 if (eventType == XMLStreamConstants.CHARACTERS) { 58 String text = streamReader.getText(); 59 if (!text.equals(countryElementContent)) { | 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 stream.CoalesceTest; 24 25 import java.io.File; 26 import java.io.FileInputStream; 27 import java.io.InputStream; 28 29 import javax.xml.stream.XMLInputFactory; 30 import javax.xml.stream.XMLStreamConstants; 31 import javax.xml.stream.XMLStreamException; 32 import javax.xml.stream.XMLStreamReader; 33 34 import org.testng.Assert; 35 import org.testng.annotations.Listeners; 36 import org.testng.annotations.Test; 37 38 /* 39 * @summary Test Coalesce property works. 40 */ 41 @Listeners({jaxp.library.FilePolicy.class}) 42 public class CoalesceTest { 43 44 String countryElementContent = "START India CS}}}}}} India END"; 45 String descriptionElementContent = "a&b"; 46 String fooElementContent = "&< cdatastart<><>>><>><<<<cdataend entitystart insert entityend"; 47 48 @Test 49 public void testCoalesceProperty() { 50 try { 51 XMLInputFactory xifactory = XMLInputFactory.newInstance(); 52 xifactory.setProperty(XMLInputFactory.IS_COALESCING, new Boolean(true)); 53 InputStream xml = this.getClass().getResourceAsStream("coalesce.xml"); 54 XMLStreamReader streamReader = xifactory.createXMLStreamReader(xml); 55 while (streamReader.hasNext()) { 56 int eventType = streamReader.next(); 57 if (eventType == XMLStreamConstants.START_ELEMENT && streamReader.getLocalName().equals("country")) { 58 eventType = streamReader.next(); 59 if (eventType == XMLStreamConstants.CHARACTERS) { 60 String text = streamReader.getText(); 61 if (!text.equals(countryElementContent)) { |