Added initial ATOM and RSS feed parser and generator.
(work in progress)
This commit is contained in:
91
library/text/parser/feed/tests/application.e
Normal file
91
library/text/parser/feed/tests/application.e
Normal file
@@ -0,0 +1,91 @@
|
||||
note
|
||||
description: "Summary description for {APPLICATION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make
|
||||
-- New test routine
|
||||
do
|
||||
test_file ("data_rss_1_0.rss")
|
||||
test_web ("https://bertrandmeyer.com/feed/")
|
||||
end
|
||||
|
||||
test_file (fn: READABLE_STRING_GENERAL)
|
||||
local
|
||||
t: STRING
|
||||
f: PLAIN_TEXT_FILE
|
||||
do
|
||||
create f.make_with_name (fn)
|
||||
f.open_read
|
||||
create t.make_empty
|
||||
from
|
||||
f.read_stream_thread_aware (1_024)
|
||||
until
|
||||
f.last_string.count < 1024
|
||||
loop
|
||||
t.append (f.last_string)
|
||||
f.read_stream_thread_aware (1_024)
|
||||
end
|
||||
t.append (f.last_string)
|
||||
f.close
|
||||
test_feed (t)
|
||||
end
|
||||
|
||||
test_feed (t: READABLE_STRING_8)
|
||||
local
|
||||
feed_parser: FEED_DEFAULT_PARSERS
|
||||
vis: FEED_TO_STRING_32_VISITOR
|
||||
gen: RSS_2_GENERATOR
|
||||
atom_gen: ATOM_GENERATOR
|
||||
s: STRING_32
|
||||
s8: STRING_8
|
||||
pp: XML_PRETTY_PRINT_FILTER
|
||||
do
|
||||
create feed_parser
|
||||
if attached feed_parser.feed_from_string (t) as l_feed then
|
||||
create s.make_empty
|
||||
create vis.make (s)
|
||||
l_feed.accept (vis)
|
||||
print (s)
|
||||
|
||||
create s8.make_empty
|
||||
create gen.make (s8)
|
||||
l_feed.accept (gen)
|
||||
print (s8)
|
||||
|
||||
create s8.make_empty
|
||||
create atom_gen.make (s8)
|
||||
l_feed.accept (atom_gen)
|
||||
print (s8)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
test_web (a_url: READABLE_STRING_8)
|
||||
local
|
||||
cl: LIBCURL_HTTP_CLIENT
|
||||
sess: HTTP_CLIENT_SESSION
|
||||
do
|
||||
create cl.make
|
||||
sess := cl.new_session (a_url)
|
||||
sess.set_is_insecure (True)
|
||||
if attached sess.get ("", Void) as resp then
|
||||
if
|
||||
not resp.error_occurred and then
|
||||
attached resp.body as l_feed
|
||||
then
|
||||
test_feed (l_feed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
74
library/text/parser/feed/tests/atom_test_set.e
Normal file
74
library/text/parser/feed/tests/atom_test_set.e
Normal file
@@ -0,0 +1,74 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
ATOM_TEST_SET
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_atom
|
||||
-- New test routine
|
||||
local
|
||||
feed_parser: FEED_DEFAULT_PARSERS
|
||||
vis: FEED_TO_STRING_32_VISITOR
|
||||
s: STRING_32
|
||||
do
|
||||
create feed_parser
|
||||
if attached feed_parser.feed_from_string (atom_string_1) as l_feed then
|
||||
create s.make_empty
|
||||
create vis.make (s)
|
||||
l_feed.accept (vis)
|
||||
print (s)
|
||||
assert ("not_implemented", False)
|
||||
end
|
||||
assert ("not_implemented", False)
|
||||
end
|
||||
|
||||
feature {NONE} -- Data
|
||||
|
||||
atom_string_1: STRING = "[
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
|
||||
<title>Example Feed</title>
|
||||
<subtitle>A subtitle.</subtitle>
|
||||
<link href="http://example.org/feed/" rel="self" />
|
||||
<link href="http://example.org/" />
|
||||
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
|
||||
<updated>2003-12-13T18:30:02Z</updated>
|
||||
|
||||
|
||||
<entry>
|
||||
<title>Atom-Powered Robots Run Amok</title>
|
||||
<link href="http://example.org/2003/12/13/atom03" />
|
||||
<link rel="alternate" type="text/html" href="http://example.org/2003/12/13/atom03.html"/>
|
||||
<link rel="edit" href="http://example.org/2003/12/13/atom03/edit"/>
|
||||
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
||||
<updated>2003-12-13T18:30:02Z</updated>
|
||||
<summary>Some text.</summary>
|
||||
<content type="xhtml">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">
|
||||
<p>This is the entry content.</p>
|
||||
</div>
|
||||
</content>
|
||||
<author>
|
||||
<name>John Doe</name>
|
||||
<email>johndoe@example.com</email>
|
||||
</author>
|
||||
</entry>
|
||||
|
||||
</feed>
|
||||
]"
|
||||
end
|
||||
|
||||
|
||||
60
library/text/parser/feed/tests/rss_test_set.e
Normal file
60
library/text/parser/feed/tests/rss_test_set.e
Normal file
@@ -0,0 +1,60 @@
|
||||
note
|
||||
description: "Summary description for {RSS_TEST_SET}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
RSS_TEST_SET
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_rss_2
|
||||
-- New test routine
|
||||
local
|
||||
feed_parser: FEED_DEFAULT_PARSERS
|
||||
vis: FEED_TO_STRING_32_VISITOR
|
||||
s: STRING_32
|
||||
do
|
||||
create feed_parser
|
||||
if attached feed_parser.feed_from_string (rss_2_string_1) as l_feed then
|
||||
create s.make_empty
|
||||
create vis.make (s)
|
||||
l_feed.accept (vis)
|
||||
print (s)
|
||||
assert ("not_implemented", False)
|
||||
end
|
||||
assert ("not_implemented", False)
|
||||
end
|
||||
|
||||
feature {NONE} -- Data
|
||||
|
||||
rss_2_string_1: STRING = "[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>Mon site</title>
|
||||
<description>Ceci est un exemple de flux RSS 2.0</description>
|
||||
<lastBuildDate>Sat, 07 Sep 2002 00:00:01 GMT</lastBuildDate>
|
||||
<link>http://www.example.org</link>
|
||||
<item>
|
||||
<title>Post N1</title>
|
||||
<description>This is my first post</description>
|
||||
<pubDate>Sat, 07 Sep 2002 00:00:01 GMT</pubDate>
|
||||
<link>http://www.example.org/actu1</link>
|
||||
</item>
|
||||
<item>
|
||||
<title>Post N2</title>
|
||||
<description>This is my second post</description>
|
||||
<pubDate>Sat, 07 Sep 2002 00:00:01 GMT</pubDate>
|
||||
<link>http://www.example.org/actu2</link>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
]"
|
||||
end
|
||||
|
||||
|
||||
14
library/text/parser/feed/tests/tests-safe.ecf
Normal file
14
library/text/parser/feed/tests/tests-safe.ecf
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="tests" uuid="C68BD5DC-F756-484E-A9FE-F2D1FD432B2A">
|
||||
<target name="tests">
|
||||
<root class="APPLICATION" feature="make"/>
|
||||
<setting name="console_application" value="false"/>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="feed" location="..\feed-safe.ecf" readonly="false"/>
|
||||
<library name="http_client" location="$ISE_LIBRARY\contrib\library\network\http_client\http_client-safe.ecf"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<library name="xml_parser" location="$ISE_LIBRARY\library\text\parser\xml\parser\xml_parser-safe.ecf"/>
|
||||
<tests name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
12
library/text/parser/feed/tests/tests.ecf
Normal file
12
library/text/parser/feed/tests/tests.ecf
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="tests" uuid="C68BD5DC-F756-484E-A9FE-F2D1FD432B2A">
|
||||
<target name="tests">
|
||||
<root class="ANY" feature="default_create"/>
|
||||
<setting name="console_application" value="false"/>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="feed" location="..\feed.ecf"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing.ecf"/>
|
||||
<tests name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
Reference in New Issue
Block a user