Skip to content

Commit a3f9276

Browse files
committed
call public api for test
1 parent 6c55f73 commit a3f9276

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3658,7 +3658,7 @@ else if ( expand )
36583658
buf = newBuf;
36593659
if ( bufLoadFactor > 0 )
36603660
{
3661-
// Include fix for https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228
3661+
// Include a fix for https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228
36623662
bufSoftLimit = (int) (bufferLoadFactor * buf.length);
36633663
}
36643664

src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,20 +392,25 @@ public void testSubsequentProcessingInstructionMoreThan8k()
392392
}
393393

394394
@Test
395-
public void testFillBuf_NoOverflow()
395+
public void testLargeText_NoOverflow()
396396
throws Exception
397397
{
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>");
402406

403-
parser.fillBuf();
407+
MXParser parser = new MXParser();
408+
parser.setInput(new StringReader(sb.toString()));
404409

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());
409414
}
410415

411416
public void testMalformedProcessingInstructionAfterTag()

0 commit comments

Comments
 (0)