2004-01-28 09:09:27 +03:00
|
|
|
# -*- tab-width: 2 -*- vim: ts=2
|
|
|
|
|
2004-03-21 13:03:17 +03:00
|
|
|
require "test/unit"
|
|
|
|
require 'rss-assertions'
|
|
|
|
|
|
|
|
module RSS
|
2004-10-16 08:51:15 +04:00
|
|
|
class TestCase < Test::Unit::TestCase
|
|
|
|
|
|
|
|
include RSS
|
|
|
|
include Assertions
|
|
|
|
|
|
|
|
XMLDECL_VERSION = "1.0"
|
|
|
|
XMLDECL_ENCODING = "UTF-8"
|
|
|
|
XMLDECL_STANDALONE = "no"
|
|
|
|
|
|
|
|
RDF_ABOUT = "http://www.xml.com/xml/news.rss"
|
|
|
|
RDF_RESOURCE = "http://xml.com/universal/images/xml_tiny.gif"
|
|
|
|
TITLE_VALUE = "XML.com"
|
|
|
|
LINK_VALUE = "http://xml.com/pub"
|
|
|
|
URL_VALUE = "http://xml.com/universal/images/xml_tiny.gif"
|
|
|
|
NAME_VALUE = "hogehoge"
|
|
|
|
LANGUAGE_VALUE = "ja"
|
|
|
|
DESCRIPTION_VALUE = "
|
2004-01-28 06:46:13 +03:00
|
|
|
XML.com features a rich mix of information and services
|
|
|
|
for the XML community.
|
2004-10-16 08:51:15 +04:00
|
|
|
"
|
|
|
|
RESOURCES = [
|
|
|
|
"http://xml.com/pub/2000/08/09/xslt/xslt.html",
|
|
|
|
"http://xml.com/pub/2000/08/09/rdfdb/index.html",
|
|
|
|
]
|
|
|
|
|
|
|
|
CLOUD_DOMAIN = "data.ourfavoritesongs.com"
|
|
|
|
CLOUD_PORT = "80"
|
|
|
|
CLOUD_PATH = "/RPC2"
|
|
|
|
CLOUD_REGISTER_PROCEDURE = "ourFavoriteSongs.rssPleaseNotify"
|
|
|
|
CLOUD_PROTOCOL = "xml-rpc"
|
|
|
|
|
|
|
|
ENCLOSURE_URL = "http://www.scripting.com/mp3s/weatherReportSuite.mp3"
|
|
|
|
ENCLOSURE_LENGTH = "12216320"
|
|
|
|
ENCLOSURE_TYPE = "audio/mpeg"
|
|
|
|
|
|
|
|
CATEGORY_DOMAIN = "http://www.superopendirectory.com/"
|
|
|
|
|
|
|
|
def default_test
|
|
|
|
# This class isn't tested
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def make_xmldecl(v=XMLDECL_VERSION, e=XMLDECL_ENCODING, s=XMLDECL_STANDALONE)
|
|
|
|
rv = "<?xml version='#{v}'"
|
|
|
|
rv << " encoding='#{e}'" if e
|
|
|
|
rv << " standalone='#{s}'" if s
|
|
|
|
rv << "?>"
|
|
|
|
rv
|
|
|
|
end
|
|
|
|
|
|
|
|
def make_RDF(content=nil, xmlns=[])
|
|
|
|
<<-EORSS
|
2004-01-28 06:46:13 +03:00
|
|
|
#{make_xmldecl}
|
|
|
|
<rdf:RDF xmlns="#{URI}" xmlns:rdf="#{RDF::URI}"
|
|
|
|
#{xmlns.collect {|pre, uri| "xmlns:#{pre}='#{uri}'"}.join(' ')}>
|
|
|
|
#{block_given? ? yield : content}
|
|
|
|
</rdf:RDF>
|
|
|
|
EORSS
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_channel(content=nil)
|
|
|
|
<<-EOC
|
2004-01-28 06:46:13 +03:00
|
|
|
<channel rdf:about="#{RDF_ABOUT}">
|
2004-10-16 08:51:15 +04:00
|
|
|
<title>#{TITLE_VALUE}</title>
|
|
|
|
<link>#{LINK_VALUE}</link>
|
|
|
|
<description>#{DESCRIPTION_VALUE}</description>
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
<image rdf:resource="#{RDF_RESOURCE}" />
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
<items>
|
|
|
|
<rdf:Seq>
|
2004-01-28 06:46:13 +03:00
|
|
|
#{RESOURCES.collect do |res| '<rdf:li resource="' + res + '" />' end.join("\n")}
|
2004-10-16 08:51:15 +04:00
|
|
|
</rdf:Seq>
|
|
|
|
</items>
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
<textinput rdf:resource="#{RDF_RESOURCE}" />
|
2004-01-28 06:46:13 +03:00
|
|
|
|
|
|
|
#{block_given? ? yield : content}
|
|
|
|
</channel>
|
|
|
|
EOC
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_image(content=nil)
|
|
|
|
<<-EOI
|
2004-01-28 06:46:13 +03:00
|
|
|
<image rdf:about="#{RDF_ABOUT}">
|
2004-10-16 08:51:15 +04:00
|
|
|
<title>#{TITLE_VALUE}</title>
|
|
|
|
<url>#{URL_VALUE}</url>
|
|
|
|
<link>#{LINK_VALUE}</link>
|
2004-01-28 06:46:13 +03:00
|
|
|
#{block_given? ? yield : content}
|
|
|
|
</image>
|
|
|
|
EOI
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_item(content=nil)
|
|
|
|
<<-EOI
|
2004-01-28 06:46:13 +03:00
|
|
|
<item rdf:about="#{RDF_ABOUT}">
|
2004-10-16 08:51:15 +04:00
|
|
|
<title>#{TITLE_VALUE}</title>
|
|
|
|
<link>#{LINK_VALUE}</link>
|
|
|
|
<description>#{DESCRIPTION_VALUE}</description>
|
2004-01-28 06:46:13 +03:00
|
|
|
#{block_given? ? yield : content}
|
|
|
|
</item>
|
|
|
|
EOI
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_textinput(content=nil)
|
|
|
|
<<-EOT
|
2004-01-28 06:46:13 +03:00
|
|
|
<textinput rdf:about="#{RDF_ABOUT}">
|
2004-10-16 08:51:15 +04:00
|
|
|
<title>#{TITLE_VALUE}</title>
|
|
|
|
<description>#{DESCRIPTION_VALUE}</description>
|
|
|
|
<name>#{NAME_VALUE}</name>
|
|
|
|
<link>#{LINK_VALUE}</link>
|
2004-01-28 06:46:13 +03:00
|
|
|
#{block_given? ? yield : content}
|
|
|
|
</textinput>
|
|
|
|
EOT
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-02-13 14:02:03 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_sample_RDF
|
|
|
|
make_RDF(<<-EOR)
|
2004-03-21 12:20:47 +03:00
|
|
|
#{make_channel}
|
|
|
|
#{make_image}
|
|
|
|
#{make_item}
|
|
|
|
#{make_textinput}
|
|
|
|
EOR
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-03-21 12:20:47 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_rss20(content=nil, xmlns=[])
|
|
|
|
<<-EORSS
|
2004-02-13 14:02:03 +03:00
|
|
|
#{make_xmldecl}
|
|
|
|
<rss version="2.0"
|
|
|
|
#{xmlns.collect {|pre, uri| "xmlns:#{pre}='#{uri}'"}.join(' ')}>
|
|
|
|
#{block_given? ? yield : content}
|
|
|
|
</rss>
|
|
|
|
EORSS
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-02-13 14:02:03 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_channel20(content=nil)
|
|
|
|
<<-EOC
|
2004-02-13 14:02:03 +03:00
|
|
|
<channel>
|
2004-10-16 08:51:15 +04:00
|
|
|
<title>#{TITLE_VALUE}</title>
|
|
|
|
<link>#{LINK_VALUE}</link>
|
|
|
|
<description>#{DESCRIPTION_VALUE}</description>
|
|
|
|
<language>#{LANGUAGE_VALUE}</language>
|
2004-02-13 14:02:03 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
<image>
|
|
|
|
<url>#{RDF_RESOURCE}</url>
|
|
|
|
<title>#{TITLE_VALUE}</title>
|
|
|
|
<link>#{LINK_VALUE}</link>
|
|
|
|
</image>
|
2004-02-13 14:02:03 +03:00
|
|
|
|
|
|
|
#{RESOURCES.collect do |res| '<item><link>' + res + '</link></item>' end.join("\n")}
|
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
<textInput>
|
|
|
|
<title>#{TITLE_VALUE}</title>
|
|
|
|
<description>#{DESCRIPTION_VALUE}</description>
|
|
|
|
<name>#{NAME_VALUE}</name>
|
|
|
|
<link>#{RDF_RESOURCE}</link>
|
|
|
|
</textInput>
|
2004-02-13 14:02:03 +03:00
|
|
|
|
|
|
|
#{block_given? ? yield : content}
|
|
|
|
</channel>
|
|
|
|
EOC
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-02-13 14:02:03 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_item20(content=nil)
|
|
|
|
<<-EOI
|
2004-02-13 14:02:03 +03:00
|
|
|
<item>
|
2004-10-16 08:51:15 +04:00
|
|
|
<title>#{TITLE_VALUE}</title>
|
|
|
|
<link>#{LINK_VALUE}</link>
|
|
|
|
<description>#{DESCRIPTION_VALUE}</description>
|
2004-02-13 14:02:03 +03:00
|
|
|
#{block_given? ? yield : content}
|
|
|
|
</item>
|
|
|
|
EOI
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-07-06 21:43:05 +04:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
def make_cloud20
|
|
|
|
<<-EOC
|
2004-07-06 21:43:05 +04:00
|
|
|
<cloud
|
|
|
|
domain="#{CLOUD_DOMAIN}"
|
|
|
|
port="#{CLOUD_PORT}"
|
|
|
|
path="#{CLOUD_PATH}"
|
|
|
|
registerProcedure="#{CLOUD_REGISTER_PROCEDURE}"
|
|
|
|
protocol="#{CLOUD_PROTOCOL}" />
|
|
|
|
EOC
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-07-06 21:43:05 +04:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2004-01-28 06:46:13 +03:00
|
|
|
end
|