Skip to content

Commit 9cee0d6

Browse files
termaashawley
authored andcommitted
SI-4520 Tests for OOE in XML parser
1 parent aed4cb3 commit 9cee0d6

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

jvm/src/test/scala/scala/xml/XMLTest.scala

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ class XMLTestJVM {
523523
import scala.xml.parsing._
524524
@UnitTest
525525
def dontLoop: Unit = {
526-
val xml = "<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> "
526+
val xml = "<!DOCTYPE xmeml SYSTEM 'uri'> <xmeml> <sequence> </sequence> </xmeml> "
527527
val sink = new PrintStream(new ByteArrayOutputStream())
528528
(Console withOut sink) {
529529
(Console withErr sink) {
@@ -639,4 +639,48 @@ class XMLTestJVM {
639639
assertEquals("<node>\n <leaf/>\n</node>", pp.format(x))
640640
}
641641

642+
@UnitTest(expected = classOf[FatalError])
643+
def shouldThrowFatalErrorWhenCantFindRequestedXToken {
644+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
645+
646+
x.xToken('b')
647+
}
648+
649+
@UnitTest(expected = classOf[FatalError])
650+
def shouldThrowFatalErrorWhenCantFindRequestedXCharData {
651+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
652+
653+
x.xCharData
654+
}
655+
656+
@UnitTest(expected = classOf[FatalError])
657+
def shouldThrowFatalErrorWhenCantFindRequestedXComment {
658+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
659+
660+
x.xComment
661+
}
662+
663+
@UnitTest(expected = classOf[FatalError])
664+
def shouldThrowFatalErrorWhenCantFindRequestedXmlProcInstr {
665+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
666+
667+
x.xmlProcInstr()
668+
}
669+
670+
@Ignore("Ignored for future fix, currently throw OOE because of infinity MarkupParserCommon:66")
671+
@UnitTest(expected = classOf[FatalError])
672+
def shouldThrowFatalErrorWhenCantFindRequestedXAttributeValue {
673+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
674+
675+
x.xAttributeValue()
676+
}
677+
678+
@Ignore("Ignored for future fix, currently return unexpected result")
679+
@UnitTest(expected = classOf[FatalError])
680+
def shouldThrowFatalErrorWhenCantFindRequestedXEntityValue {
681+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
682+
683+
assertEquals("a/>", x.xEntityValue())
684+
}
685+
642686
}

0 commit comments

Comments
 (0)