@@ -392,20 +392,25 @@ public void testSubsequentProcessingInstructionMoreThan8k()
392
392
}
393
393
394
394
@ Test
395
- public void testFillBuf_NoOverflow ()
395
+ public void testLargeText_NoOverflow ()
396
396
throws Exception
397
397
{
398
- MXParser parser = new MXParser ();
399
- parser .reader = new StringReader ("testFillBuf_NoOverflow" );
400
- parser .bufEnd = 15941364 ;
401
- parser .buf = new char [16777216 ];
398
+ StringBuffer sb = new StringBuffer ();
399
+ sb .append ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>" );
400
+ sb .append ("<largetextblock>" );
401
+ // Anything above 33,554,431 would fail without a fix for
402
+ // https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228
403
+ // with java.io.IOException: error reading input, returned 0
404
+ sb .append (new String (new char [33554432 ]));
405
+ sb .append ("</largetextblock>" );
402
406
403
- parser .fillBuf ();
407
+ MXParser parser = new MXParser ();
408
+ parser .setInput (new StringReader (sb .toString ()));
404
409
405
- // Without this fix
406
- // https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228
407
- // the integer value overflows to -11072962
408
- assertTrue ( parser . bufSoftLimit >= 0 );
410
+ assertEquals ( XmlPullParser . PROCESSING_INSTRUCTION , parser . nextToken ());
411
+ assertEquals ( XmlPullParser . START_TAG , parser . nextToken ());
412
+ assertEquals ( XmlPullParser . TEXT , parser . nextToken ());
413
+ assertEquals ( XmlPullParser . END_TAG , parser . nextToken () );
409
414
}
410
415
411
416
public void testMalformedProcessingInstructionAfterTag ()
0 commit comments