Skip to content

Commit 4940b6a

Browse files
termaashawley
authored andcommitted
SI-4520 Tests for OOE in XML parser
1 parent e6c490e commit 4940b6a

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

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

+46-1
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) {
@@ -765,4 +765,49 @@ class XMLTestJVM {
765765
val formatted = pp.format(x)
766766
assertEquals(x, XML.loadString(formatted))
767767
}
768+
769+
@UnitTest(expected = classOf[FatalError])
770+
def shouldThrowFatalErrorWhenCantFindRequestedXToken {
771+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
772+
773+
x.xToken('b')
774+
}
775+
776+
@UnitTest(expected = classOf[FatalError])
777+
def shouldThrowFatalErrorWhenCantFindRequestedXCharData {
778+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
779+
780+
x.xCharData
781+
}
782+
783+
@UnitTest(expected = classOf[FatalError])
784+
def shouldThrowFatalErrorWhenCantFindRequestedXComment {
785+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
786+
787+
x.xComment
788+
}
789+
790+
@UnitTest(expected = classOf[FatalError])
791+
def shouldThrowFatalErrorWhenCantFindRequestedXmlProcInstr {
792+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
793+
794+
x.xmlProcInstr()
795+
}
796+
797+
@Ignore("Ignored for future fix, currently throw OOE because of infinity MarkupParserCommon:66")
798+
@UnitTest(expected = classOf[FatalError])
799+
def shouldThrowFatalErrorWhenCantFindRequestedXAttributeValue {
800+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
801+
802+
x.xAttributeValue()
803+
}
804+
805+
@Ignore("Ignored for future fix, currently return unexpected result")
806+
@UnitTest(expected = classOf[FatalError])
807+
def shouldThrowFatalErrorWhenCantFindRequestedXEntityValue {
808+
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)
809+
810+
assertEquals("a/>", x.xEntityValue())
811+
}
812+
768813
}

0 commit comments

Comments
 (0)