From a38971c595a6a5ee6f4cf0b2c066311a4694a59c Mon Sep 17 00:00:00 2001 From: kou Date: Sat, 15 Nov 2014 11:45:27 +0000 Subject: * test/rexml/test_document.rb (REXMLTests::TestDocument::EntityExpansionLimitTest): Define test XML in each test method because (1) each XML in used only one test and (2) related data and code should be close. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rexml/test_document.rb | 130 ++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 65 deletions(-) (limited to 'test/rexml') diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index 8f37b2f12b..f4e78c9c03 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -41,7 +41,8 @@ EOF REXML::Security.entity_expansion_limit = @default_entity_expansion_limit end - XML_WITH_NESTED_ENTITY = < @@ -57,7 +58,21 @@ EOF EOF - XML_WITH_NESTED_EMPTY_ENTITY = < @@ -73,35 +88,21 @@ EOF EOF - XML_WITH_NESTED_PARAMETER_ENTITY = < - - - - - - - -]> - -EOF - - XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY = < - - - - - - - -]> - -EOF + doc = REXML::Document.new(xml) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + REXML::Security.entity_expansion_limit = 100 + assert_equal(100, REXML::Security.entity_expansion_limit) + doc = REXML::Document.new(xml) + assert_raise(RuntimeError) do + doc.root.children.first.value + end + assert_equal(101, doc.entity_expansion_count) + end - XML_WITH_4_ENTITY_EXPANSION = < @@ -114,64 +115,63 @@ EOF EOF - def test_general_entity_have_value - doc = REXML::Document.new(XML_WITH_NESTED_ENTITY) - assert_raise(RuntimeError) do - doc.root.children.first.value - end - REXML::Security.entity_expansion_limit = 100 - assert_equal(100, REXML::Security.entity_expansion_limit) - doc = REXML::Document.new(XML_WITH_NESTED_ENTITY) - assert_raise(RuntimeError) do - doc.root.children.first.value - end - assert_equal(101, doc.entity_expansion_count) - end - - def test_general_entity_empty_value - doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_ENTITY) - assert_raise(RuntimeError) do - doc.root.children.first.value - end - REXML::Security.entity_expansion_limit = 100 - assert_equal(100, REXML::Security.entity_expansion_limit) - doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_ENTITY) - assert_raise(RuntimeError) do - doc.root.children.first.value - end - assert_equal(101, doc.entity_expansion_count) - end - - def test_general_entity_with_default_entity REXML::Security.entity_expansion_limit = 4 - doc = REXML::Document.new(XML_WITH_4_ENTITY_EXPANSION) + doc = REXML::Document.new(xml) assert_equal("\na\na a\n<\n", doc.root.children.first.value) REXML::Security.entity_expansion_limit = 3 - doc = REXML::Document.new(XML_WITH_4_ENTITY_EXPANSION) + doc = REXML::Document.new(xml) assert_raise(RuntimeError) do doc.root.children.first.value end end def test_parameter_entity_have_value + xml = < + + + + + + + +]> + +EOF + assert_raise(REXML::ParseException) do - REXML::Document.new(XML_WITH_NESTED_PARAMETER_ENTITY) + REXML::Document.new(xml) end REXML::Security.entity_expansion_limit = 100 assert_equal(100, REXML::Security.entity_expansion_limit) assert_raise(REXML::ParseException) do - REXML::Document.new(XML_WITH_NESTED_PARAMETER_ENTITY) + REXML::Document.new(xml) end end def test_parameter_entity_empty_value + xml = < + + + + + + + +]> + +EOF + assert_raise(REXML::ParseException) do - REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY) + REXML::Document.new(xml) end REXML::Security.entity_expansion_limit = 100 assert_equal(100, REXML::Security.entity_expansion_limit) assert_raise(REXML::ParseException) do - REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY) + REXML::Document.new(xml) end end end -- cgit v1.2.3