Skip to content

Commit 40d7eb8

Browse files
termaashawley
authored andcommitted
SI-4520 Tests for OOE in XML parser
1 parent 488f069 commit 40d7eb8

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
@@ -633,7 +633,7 @@ class XMLTestJVM {
633633
import scala.xml.parsing._
634634
@UnitTest
635635
def dontLoop: Unit = {
636-
val xml = "<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> "
636+
val xml = "<!DOCTYPE xmeml SYSTEM 'uri'> <xmeml> <sequence> </sequence> </xmeml> "
637637
val sink = new PrintStream(new ByteArrayOutputStream())
638638
(Console withOut sink) {
639639
(Console withErr sink) {
@@ -749,4 +749,48 @@ class XMLTestJVM {
749749
assertEquals("<node>\n <leaf/>\n</node>", pp.format(x))
750750
}
751751

752+
@UnitTest(expected = classOf[FatalError])
753+
def shouldThrowFatalErrorWhenCantFindRequestedXToken {
754+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
755+
756+
x.xToken('b')
757+
}
758+
759+
@UnitTest(expected = classOf[FatalError])
760+
def shouldThrowFatalErrorWhenCantFindRequestedXCharData {
761+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
762+
763+
x.xCharData
764+
}
765+
766+
@UnitTest(expected = classOf[FatalError])
767+
def shouldThrowFatalErrorWhenCantFindRequestedXComment {
768+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
769+
770+
x.xComment
771+
}
772+
773+
@UnitTest(expected = classOf[FatalError])
774+
def shouldThrowFatalErrorWhenCantFindRequestedXmlProcInstr {
775+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
776+
777+
x.xmlProcInstr()
778+
}
779+
780+
@Ignore("Ignored for future fix, currently throw OOE because of infinity MarkupParserCommon:66")
781+
@UnitTest(expected = classOf[FatalError])
782+
def shouldThrowFatalErrorWhenCantFindRequestedXAttributeValue {
783+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
784+
785+
x.xAttributeValue()
786+
}
787+
788+
@Ignore("Ignored for future fix, currently return unexpected result")
789+
@UnitTest(expected = classOf[FatalError])
790+
def shouldThrowFatalErrorWhenCantFindRequestedXEntityValue {
791+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
792+
793+
assertEquals("a/>", x.xEntityValue())
794+
}
795+
752796
}

0 commit comments

Comments
 (0)