This patch moves the feedparser xml files into the tree, instead of
fetching them from http://www.feedparser.org/ at runtime. It also
adds the appropriate NOTICE and LICENSE entries for the files.
-garrett
[[[
Stop fetching feedparser xml files from feedparser.org at test time.
* NOTICE: Note presence of software from feedparser.
* LICENSE: Add the feedparser license for their data files.
* build/build.xml
(compile.parser): Copy feedparser files into test tree.
* parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java
Remove import of java.net.URI.
(get): Removed.
(parse): New method.
(setUp): Removed.
(testAtom10Namespace, testEntryAuthorEmail,
testEntryAuthorName, testEntryContentBase64,
testEntryContentBase642): Use parse, not get.
* parser/src/test/resources/feedparser/entry_content_base64_2.xml: New file.
* parser/src/test/resources/feedparser/entry_author_name.xml: Ditto.
* parser/src/test/resources/feedparser/entry_author_email.xml: Ditto.
* parser/src/test/resources/feedparser/atom10_namespace.xml: Ditto.
* parser/src/test/resources/feedparser/entry_content_base64.xml: Ditto.
]]]
Index: build/build.xml
===================================================================
--- build/build.xml (revision 415683)
+++ build/build.xml (working copy)
@@ -101,6 +101,12 @@
<include name="*.xml"/>
</fileset>
</copy>
+ <mkdir dir="${test}/feedparser" />
+ <copy todir="${test}/feedparser">
+ <fileset dir="${parser.test.resources}/feedparser">
+ <include name="*.xml"/>
+ </fileset>
+ </copy>
</target>
<target name="build" depends="init,compile.core,compile.parser"></target>
Index: NOTICE
===================================================================
--- NOTICE (revision 415683)
+++ NOTICE (working copy)
@@ -11,3 +11,6 @@
licensed to the Apache Software Foundation under the
"Software Grant and Corporate Contribution License Agreement",
informally known as the "Abdera CLA".
+
+This software's test suite contains data files derived from the
+Universal Feed Parser, Copyright (c) 2002-2005, Mark Pilgrim.
Index: LICENSE
===================================================================
--- LICENSE (revision 415683)
+++ LICENSE (working copy)
@@ -200,3 +200,29 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+
+For parser/src/tests/resources/feedparser/*.xml:
+
+Copyright (c) 2002-2005, Mark Pilgrim
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
Index:
parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java
===================================================================
--- parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java
(revision 415683)
+++ parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java
(working copy)
@@ -20,7 +20,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
-import java.net.URI;
import javax.activation.DataHandler;
@@ -36,32 +35,22 @@
public class FeedParserTest extends TestCase {
- private static URI baseURI = null;
-
- private static Document<Feed> get(URI uri) {
+ private static Document<Feed> parse(String name) {
try {
- return Parser.INSTANCE.parse(uri.toURL().openStream(), uri);
+ String path = "/feedparser/" + name;
+ InputStream stream = FeedParserTest.class.getResourceAsStream(path);
+ return Parser.INSTANCE.parse(stream);
} catch (Exception e) {}
return null;
}
- @Override
- protected void setUp() throws Exception {
- try {
- baseURI = new URI("http://www.feedparser.org/tests/wellformed/atom10/");
- } catch (Exception e) {}
- super.setUp();
- }
-
public void testAtom10Namespace() throws Exception {
- URI uri = baseURI.resolve("atom10_namespace.xml");
- Document doc = get(uri);
+ Document doc = parse("atom10_namespace.xml");
assertNotNull(doc);
}
public void testEntryAuthorEmail() throws Exception {
- URI uri = baseURI.resolve("entry_author_email.xml");
- Document doc = get(uri);
+ Document doc = parse("entry_author_email.xml");
Feed feed = (Feed) doc.getRoot();
Entry entry = feed.getEntries().get(0);
Person person = entry.getAuthor();
@@ -69,8 +58,7 @@
}
public void testEntryAuthorName() throws Exception {
- URI uri = baseURI.resolve("entry_author_name.xml");
- Document doc = get(uri);
+ Document doc = parse("entry_author_name.xml");
Feed feed = (Feed) doc.getRoot();
Entry entry = feed.getEntries().get(0);
Person person = entry.getAuthor();
@@ -78,8 +66,7 @@
}
public void testEntryContentBase64() throws Exception {
- URI uri = baseURI.resolve("entry_content_base64.xml");
- Document doc = get(uri);
+ Document doc = parse("entry_content_base64.xml");
Feed feed = (Feed)doc.getRoot();
Entry entry = feed.getEntries().get(0);
Content mediaContent = entry.getContentElement();
@@ -93,8 +80,7 @@
}
public void testEntryContentBase642() throws Exception {
- URI uri = baseURI.resolve("entry_content_base64_2.xml");
- Document doc = get(uri);
+ Document doc = parse("entry_content_base64_2.xml");
Feed feed = (Feed)doc.getRoot();
Entry entry = feed.getEntries().get(0);
Content mediaContent = entry.getContentElement();
Index: parser/src/test/resources/feedparser/entry_content_base64_2.xml
===================================================================
--- parser/src/test/resources/feedparser/entry_content_base64_2.xml
(revision 0)
+++ parser/src/test/resources/feedparser/entry_content_base64_2.xml
(revision 0)
@@ -0,0 +1,11 @@
+<!--
+Description: entry content base64-encoded
+Expect: not bozo and entries[0]['content'][0]['value'] == u'<p>History of
the <blink> tag</p>'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+<entry>
+<content type="application/octet-stream">
+PHA+SGlzdG9yeSBvZiB0aGUgJmx0O2JsaW5rJmd0OyB0YWc8L3A+
+</content>
+</entry>
+</feed>
\ No newline at end of file
Index: parser/src/test/resources/feedparser/entry_author_name.xml
===================================================================
--- parser/src/test/resources/feedparser/entry_author_name.xml (revision 0)
+++ parser/src/test/resources/feedparser/entry_author_name.xml (revision 0)
@@ -0,0 +1,13 @@
+<!--
+Description: entry author name
+Expect: not bozo and entries[0]['author_detail']['name'] == u'Example
author'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+<entry>
+ <author>
+ <name>Example author</name>
+ <email>[EMAIL PROTECTED]</email>
+ <uri>http://example.com/</uri>
+ </author>
+</entry>
+</feed>
\ No newline at end of file
Index: parser/src/test/resources/feedparser/entry_author_email.xml
===================================================================
--- parser/src/test/resources/feedparser/entry_author_email.xml (revision 0)
+++ parser/src/test/resources/feedparser/entry_author_email.xml (revision 0)
@@ -0,0 +1,13 @@
+<!--
+Description: entry author email
+Expect: not bozo and entries[0]['author_detail']['email'] == u'[EMAIL
PROTECTED]'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+<entry>
+ <author>
+ <name>Example author</name>
+ <email>[EMAIL PROTECTED]</email>
+ <uri>http://example.com/</uri>
+ </author>
+</entry>
+</feed>
\ No newline at end of file
Index: parser/src/test/resources/feedparser/atom10_namespace.xml
===================================================================
--- parser/src/test/resources/feedparser/atom10_namespace.xml (revision 0)
+++ parser/src/test/resources/feedparser/atom10_namespace.xml (revision 0)
@@ -0,0 +1,7 @@
+<!--
+Description: Atom namespace (official)
+Expect: not bozo and feed['title'] == u'Example Atom'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>Example Atom</title>
+</feed>
\ No newline at end of file
Index: parser/src/test/resources/feedparser/entry_content_base64.xml
===================================================================
--- parser/src/test/resources/feedparser/entry_content_base64.xml
(revision 0)
+++ parser/src/test/resources/feedparser/entry_content_base64.xml
(revision 0)
@@ -0,0 +1,11 @@
+<!--
+Description: entry content base64-encoded
+Expect: not bozo and entries[0]['content'][0]['value'] == u'Example
<b>Atom</b>'
+-->
+<feed xmlns="http://www.w3.org/2005/Atom">
+<entry>
+ <content type="application/octet-stream">
+ RXhhbXBsZSA8Yj5BdG9tPC9iPg==
+ </content>
+</entry>
+</feed>
\ No newline at end of file