* test/rexml/: fix fixture data path. All REXML tests are worked.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2010-09-17 13:31:16 +00:00
Родитель d357d7279a
Коммит 146bf4fdaf
12 изменённых файлов: 75 добавлений и 57 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Fri Sep 17 22:29:56 2010 Kouhei Sutou <kou@cozmixng.org>
* test/rexml/: fix fixture data path. All REXML tests are worked.
Fri Sep 17 22:15:15 2010 Kouhei Sutou <kou@cozmixng.org>
* test/rexml/test_listener.rb: remove needless codes.

Просмотреть файл

@ -0,0 +1,5 @@
module REXMLTestUtils
def fixture_path(*components)
File.join(File.dirname(__FILE__), "data", *components)
end
end

Просмотреть файл

@ -1,11 +1,13 @@
# coding: binary
require "test/unit/testcase"
require "rexml_test_utils"
require "rexml/document"
require "rexml/parseexception"
require "rexml/formatters/default"
class ContribTester < Test::Unit::TestCase
include REXMLTestUtils
include REXML
XML_STRING_01 = <<DELIMITER
@ -275,7 +277,7 @@ EOF
f.write( tn, Output.new(o = "", "ISO-8859-1") )
assert_equal(expected_iso, o.strip)
doc = Document.new File.new('test/data/xmlfile-bug.xml')
doc = Document.new File.new(fixture_path('xmlfile-bug.xml'))
tn = XPath.first(doc, "//nebenspalte/text()[2]")
assert_equal(expected_utf, tn.to_s.strip)
f.write( tn, Output.new(o = "", "ISO-8859-1") )
@ -295,7 +297,7 @@ EOF
end
def test_namespaces_in_attlist_tobias
in_string = File.open('test/data/foo.xml', 'r') do |file|
in_string = File.open(fixture_path('foo.xml'), 'r') do |file|
file.read
end
@ -309,7 +311,7 @@ EOF
# Alun ap Rhisiart
def test_less_than_in_element_content
source = File.new('test/data/ProductionSupport.xml')
source = File.new(fixture_path('ProductionSupport.xml'))
h = Hash.new
doc = REXML::Document.new source
doc.elements.each("//CommonError") { |el|
@ -450,8 +452,8 @@ EOL
def test_external_entity
xp = '//channel/title'
%w{data/working.rss data/broken.rss}.each do |path|
File.open(File.join( "test", path )) do |file|
%w{working.rss broken.rss}.each do |path|
File.open(File.join(fixture_path(path))) do |file|
doc = REXML::Document.new file.readlines.join('')
# check to make sure everything is kosher

Просмотреть файл

@ -1,13 +1,13 @@
# coding: binary
require "test/unit/testcase"
require "rexml_test_utils"
require 'rexml/source'
class EncodingTester < Test::Unit::TestCase
include REXMLTestUtils
include REXML
TEST_DIR="test/data"
def setup
@encoded = "<?xml version='1.0' encoding='ISO-8859-3'?>"+
"<a><b>\346</b></a>"
@ -85,7 +85,7 @@ class EncodingTester < Test::Unit::TestCase
end
def test_ticket_110
utf16 = REXML::Document.new(File.new(File.join(TEST_DIR,"ticket_110_utf16.xml")))
utf16 = REXML::Document.new(File.new(fixture_path("ticket_110_utf16.xml")))
assert_equal( "UTF-16", utf16.encoding )
assert( utf16[0].kind_of?(REXML::XMLDecl))
end

Просмотреть файл

@ -1,11 +1,13 @@
require 'rexml_test_utils'
require "rexml/document"
require "rexml/xpath"
require 'test/unit/testcase'
# Harness to test REXML's capabilities against the test suite from Jaxen
# ryan.a.cox@gmail.com
class JaxenTester < Test::Unit::TestCase
include REXMLTestUtils
include REXML
def test_axis ; test("axis") ; end
@ -32,19 +34,17 @@ class JaxenTester < Test::Unit::TestCase
def test_web ; test("web") ; end
def test_web2 ; test("web2") ; end
private
def test( fname )
xml_dir = "test/data"
# Dir.entries( xml_dir ).each { |fname|
# if fname =~ /\.xml$/
file = File.new( File.join( xml_dir, fname+".xml" ))
file = File.new(fixture_path(fname+".xml"))
doc = Document.new( file )
XPath.each( doc, "/tests/document" ) {|e| handleDocument(e)}
# end
# }
end
private
# processes a tests/document/context node
def handleContext( testDoc, ctxElement)
testCtx = XPath.match( testDoc, ctxElement.attributes["select"] )[0]

Просмотреть файл

@ -1,12 +1,13 @@
require "test/unit/testcase"
require "rexml_test_utils"
require "rexml/light/node"
require "rexml/parsers/lightparser"
include REXML::Light
class LightTester < Test::Unit::TestCase
include REXMLTestUtils
include REXML::Light
def test_parse_large
parser = REXML::Parsers::LightParser.new( File.new( "test/data/documentation.xml" ) )
parser = REXML::Parsers::LightParser.new(fixture_path("documentation.xml"))
root = parser.parse
end

Просмотреть файл

@ -1,10 +1,11 @@
require 'test/unit/testcase'
require 'rexml_test_utils'
require 'rexml/parsers/lightparser'
class LightParserTester < Test::Unit::TestCase
include REXMLTestUtils
include REXML
def test_parsing
f = File.new( "test/data/documentation.xml" )
f = File.new(fixture_path("documentation.xml"))
parser = REXML::Parsers::LightParser.new( f )
root = parser.parse
end

Просмотреть файл

@ -1,9 +1,12 @@
# coding: binary
require 'rexml_test_utils'
require 'rexml/document'
require 'rexml/streamlistener'
class BaseTester < Test::Unit::TestCase
include REXMLTestUtils
def test_empty
return unless defined? @listener
# Empty.
@ -90,7 +93,7 @@ class BaseTester < Test::Unit::TestCase
end
assert_equal( 'é', a.value)
doc = REXML::Document.parse_stream(
File::new("test/data/stream_accents.xml"),
File::new(fixture_path("stream_accents.xml")),
AccentListener::new
)
end

Просмотреть файл

@ -1,8 +1,22 @@
require 'test/unit'
require 'rexml_test_utils'
require 'rexml/document'
require 'zlib'
class OrderTester < Test::Unit::TestCase
include REXMLTestUtils
TESTDOC = <<END
<a>
<b/>
<x id='1'/>
<c/>
<d>
<x id='2'/>
</d>
<x id='3'/>
</a>
END
def setup
@doc = REXML::Document.new(TESTDOC)
@items = REXML::XPath.match(@doc,'//x')
@ -29,7 +43,7 @@ class OrderTester < Test::Unit::TestCase
end
# Provided by Tom Talbott
def test_more_ordering
doc = REXML::Document.new( Zlib::GzipReader.new( File.new( 'test/data/LostineRiver.kml.gz' ) ) )
doc = REXML::Document.new(Zlib::GzipReader.new(File.new(fixture_path('LostineRiver.kml.gz'))))
actual = [
"Head south from Phinney Ave N",
"Turn left at N 36th St",
@ -86,16 +100,3 @@ class OrderTester < Test::Unit::TestCase
}
end
end
TESTDOC = <<END
<a>
<b/>
<x id='1'/>
<c/>
<d>
<x id='2'/>
</d>
<x id='3'/>
</a>
END

Просмотреть файл

@ -1,11 +1,10 @@
#!/sw/bin/ruby
require 'test/unit'
require 'rexml_test_utils'
require 'rexml/document'
class TestIssuezillaParsing < Test::Unit::TestCase
include REXMLTestUtils
def test_rexml
doc = REXML::Document.new(File.new("test/data/ofbiz-issues-full-177.xml"))
doc = REXML::Document.new(File.new(fixture_path("ofbiz-issues-full-177.xml")))
ctr = 1
doc.root.each_element('//issue') do |issue|
assert_equal( ctr, issue.elements['issue_id'].text.to_i )

Просмотреть файл

@ -1,8 +1,9 @@
require "test/unit/testcase"
require "rexml_test_utils"
require 'rexml/sax2listener'
require 'rexml/parsers/sax2parser'
class SAX2Tester < Test::Unit::TestCase
include REXMLTestUtils
include REXML
def test_characters
d = Document.new( "<A>@blah@</A>" )
@ -29,7 +30,7 @@ class SAX2Tester < Test::Unit::TestCase
end
def test_sax2
f = File.new("test/data/documentation.xml")
f = File.new(fixture_path("documentation.xml"))
parser = Parsers::SAX2Parser.new( f )
# Listen to all events on the following elements
count = 0
@ -267,7 +268,7 @@ class SAX2Tester < Test::Unit::TestCase
include REXML::SAX2Listener
end
def test_ticket_68
parser = REXML::Parsers::SAX2Parser.new( File.new('test/data/ticket_68.xml') )
parser = REXML::Parsers::SAX2Parser.new(File.new(fixture_path('ticket_68.xml')))
parser.listen( Ticket68.new )
begin
parser.parse

Просмотреть файл

@ -1,8 +1,9 @@
require "test/unit/testcase"
require "rexml_test_utils"
require "rexml/document"
class XPathTester < Test::Unit::TestCase
include REXMLTestUtils
include REXML
SOURCE = <<-EOF
<a id='1'>
@ -128,7 +129,7 @@ class XPathTester < Test::Unit::TestCase
assert_equal("b", XPath::first(c, "..").name)
assert_equal("a", XPath::first(@@doc, "a/b/..").name)
doc = REXML::Document.new(File.new("test/data/project.xml"))
doc = REXML::Document.new(File.new(fixture_path("project.xml")))
c = each_test(doc.root, "./Description" ) { |child|
assert_equal("Description",child.name)
}
@ -185,7 +186,7 @@ class XPathTester < Test::Unit::TestCase
end
def no_test_ancestor
doc = REXML::Document.new(File.new("test/data/testsrc.xml"))
doc = REXML::Document.new(File.new(fixture_path("testsrc.xml")))
doc.elements.each("//item") { |el| print el.name
if el.attributes['x']
puts " -- "+el.attributes['x']
@ -208,8 +209,8 @@ class XPathTester < Test::Unit::TestCase
# This method reads a document from a file, and then a series of xpaths,
# also from a file. It then checks each xpath against the source file.
def test_more
xmlsource = "test/data/testsrc.xml"
xpathtests = "test/data/xp.tst"
xmlsource = fixture_path("testsrc.xml")
xpathtests = fixture_path("xp.tst")
doc = REXML::Document.new(File.new(xmlsource))
#results = ""
@ -313,7 +314,7 @@ class XPathTester < Test::Unit::TestCase
end
def test_lang
doc = Document.new(File.new("test/data/lang0.xml"))
doc = Document.new(File.new(fixture_path("lang0.xml")))
#puts IO.read( "test/lang.xml" )
#puts XPath.match( doc, "//language/*" ).size
@ -646,9 +647,9 @@ class XPathTester < Test::Unit::TestCase
REXML::XPath.match(doc, '/a/c[( @id )]').size )
assert_equal( 1, REXML::XPath.match(doc.root,
'/a/c[ ( @id ) ]').size )
assert( 1, REXML::XPath.match(doc,
assert_equal( 1, REXML::XPath.match(doc,
'/a/c [ ( @id ) ] ').size )
assert( 1, REXML::XPath.match(doc,
assert_equal( 1, REXML::XPath.match(doc,
' / a / c [ ( @id ) ] ').size )
end
@ -895,7 +896,7 @@ class XPathTester < Test::Unit::TestCase
def test_ticket_56
namespaces = {'h' => 'http://www.w3.org/1999/xhtml'}
finaldoc = REXML::Document.new(File.read('test/data/google.2.xml'))
finaldoc = REXML::Document.new(File.read(fixture_path('google.2.xml')))
column_headers = []
@ -934,10 +935,10 @@ EOF
def test_ticket_43
#url = http://news.search.yahoo.com/news/rss?p=market&ei=UTF-8&fl=0&x=wrt
sum = Document.new(File.new("test/data/yahoo.xml")).elements.to_a("//item").size
sum = Document.new(File.new(fixture_path("yahoo.xml"))).elements.to_a("//item").size
assert_equal( 10, sum )
text = Document.new(File.new("test/data/yahoo.xml")).elements.to_a(%Q{//title[contains(text(), "'")]}).collect{|e| e.text}.join
text = Document.new(File.new(fixture_path("yahoo.xml"))).elements.to_a(%Q{//title[contains(text(), "'")]}).collect{|e| e.text}.join
assert_equal( "Broward labor market's a solid performer (Miami Herald)", text )
end
@ -995,13 +996,13 @@ EOF
end
def test_ticket_61_text
file = File.open( "test/data/ticket_61.xml" )
file = File.open(fixture_path("ticket_61.xml"))
doc = REXML::Document.new file
ticket_61_fixture( doc, "//div[text()='Add' and @class='ButtonText']" )
end
def test_ticket_61_contains
file = File.open( "test/data/ticket_61.xml" )
file = File.open(fixture_path("ticket_61.xml"))
doc = REXML::Document.new file
ticket_61_fixture( doc, "//div[contains(.,'Add') and @class='ButtonText']" )
end