Skip to content

Commit

Permalink
SI-4520 Tests for OOE in XML parser
Browse files Browse the repository at this point in the history
  • Loading branch information
terma authored and ashawley committed Apr 16, 2018
1 parent aed4cb3 commit 9cee0d6
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion jvm/src/test/scala/scala/xml/XMLTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class XMLTestJVM {
import scala.xml.parsing._
@UnitTest
def dontLoop: Unit = {
val xml = "<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> "
val xml = "<!DOCTYPE xmeml SYSTEM 'uri'> <xmeml> <sequence> </sequence> </xmeml> "
val sink = new PrintStream(new ByteArrayOutputStream())
(Console withOut sink) {
(Console withErr sink) {
Expand Down Expand Up @@ -639,4 +639,48 @@ class XMLTestJVM {
assertEquals("<node>\n <leaf/>\n</node>", pp.format(x))
}

@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXToken {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)

x.xToken('b')
}

@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXCharData {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)

x.xCharData
}

@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXComment {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)

x.xComment
}

@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXmlProcInstr {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)

x.xmlProcInstr()
}

@Ignore("Ignored for future fix, currently throw OOE because of infinity MarkupParserCommon:66")
@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXAttributeValue {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)

x.xAttributeValue()
}

@Ignore("Ignored for future fix, currently return unexpected result")
@UnitTest(expected = classOf[FatalError])
def shouldThrowFatalErrorWhenCantFindRequestedXEntityValue {
val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<a/>"), false)

assertEquals("a/>", x.xEntityValue())
}

}

0 comments on commit 9cee0d6

Please sign in to comment.