< prev index next >

test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug8153781.java

Print this page




  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.XMLEventReaderTest;
  25 
  26 import java.io.StringReader;
  27 
  28 import javax.xml.stream.XMLEventReader;
  29 import javax.xml.stream.XMLInputFactory;
  30 import javax.xml.stream.XMLStreamException;
  31 import javax.xml.stream.events.XMLEvent;
  32 
  33 import org.testng.Assert;

  34 import org.testng.annotations.Test;
  35 
  36 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
  37 
  38 /*
  39  * @bug 8153781
  40  * @summary Test if method skipDTD of class XMLDTDScannerImpl will correctly skip the DTD section,
  41  *          even if a call to XMLEntityScanner.scanData for skipping to the closing ']' returns true.
  42  */

  43 public class Bug8153781 {
  44     public static int DOCTYPE_SECTION_LENGTH = XMLEntityManager.DEFAULT_BUFFER_SIZE * 2;
  45     public static int DOCUMENT_LENGTH = DOCTYPE_SECTION_LENGTH + 4096;
  46 
  47     public String createXMLDocument(int doctypeoffset) {
  48         StringBuilder xmlcontentbuilder = new StringBuilder(DOCUMENT_LENGTH);
  49         xmlcontentbuilder.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n");
  50         xmlcontentbuilder.append("<!DOCTYPE dummy [\r\n");
  51         xmlcontentbuilder.append("  <!ELEMENT dummy EMPTY>\r\n");
  52         xmlcontentbuilder.append("  <!--\r\n");
  53         int doctypelines = DOCTYPE_SECTION_LENGTH / 3;
  54         for (int i = 0; i < doctypeoffset; i++)
  55             xmlcontentbuilder.append('a');
  56         for (int i = 0; i < doctypelines; i++)
  57             xmlcontentbuilder.append("a\r\n");
  58         xmlcontentbuilder.append("  -->\r\n");
  59         xmlcontentbuilder.append("  ]\r\n");
  60         xmlcontentbuilder.append(">\r\n");
  61         xmlcontentbuilder.append("<dummy>\r\n");
  62         xmlcontentbuilder.append("</dummy>\r\n");




  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.XMLEventReaderTest;
  25 
  26 import java.io.StringReader;
  27 
  28 import javax.xml.stream.XMLEventReader;
  29 import javax.xml.stream.XMLInputFactory;
  30 import javax.xml.stream.XMLStreamException;
  31 import javax.xml.stream.events.XMLEvent;
  32 
  33 import org.testng.Assert;
  34 import org.testng.annotations.Listeners;
  35 import org.testng.annotations.Test;
  36 
  37 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
  38 
  39 /*
  40  * @bug 8153781
  41  * @summary Test if method skipDTD of class XMLDTDScannerImpl will correctly skip the DTD section,
  42  *          even if a call to XMLEntityScanner.scanData for skipping to the closing ']' returns true.
  43  */
  44 @Listeners({jaxp.library.BasePolicy.class})
  45 public class Bug8153781 {
  46     public static int DOCTYPE_SECTION_LENGTH = XMLEntityManager.DEFAULT_BUFFER_SIZE * 2;
  47     public static int DOCUMENT_LENGTH = DOCTYPE_SECTION_LENGTH + 4096;
  48 
  49     public String createXMLDocument(int doctypeoffset) {
  50         StringBuilder xmlcontentbuilder = new StringBuilder(DOCUMENT_LENGTH);
  51         xmlcontentbuilder.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n");
  52         xmlcontentbuilder.append("<!DOCTYPE dummy [\r\n");
  53         xmlcontentbuilder.append("  <!ELEMENT dummy EMPTY>\r\n");
  54         xmlcontentbuilder.append("  <!--\r\n");
  55         int doctypelines = DOCTYPE_SECTION_LENGTH / 3;
  56         for (int i = 0; i < doctypeoffset; i++)
  57             xmlcontentbuilder.append('a');
  58         for (int i = 0; i < doctypelines; i++)
  59             xmlcontentbuilder.append("a\r\n");
  60         xmlcontentbuilder.append("  -->\r\n");
  61         xmlcontentbuilder.append("  ]\r\n");
  62         xmlcontentbuilder.append(">\r\n");
  63         xmlcontentbuilder.append("<dummy>\r\n");
  64         xmlcontentbuilder.append("</dummy>\r\n");


< prev index next >