abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r416516 - in /incubator/abdera/java/trunk: build/ parser/src/test/java/org/apache/abdera/test/parser/stax/ parser/src/test/resources/conformance/ parser/src/test/resources/feedparser/ parser/src/test/resources/www.feedparser.org/ parser/src...
Date Thu, 22 Jun 2006 23:52:05 GMT
Author: jmsnell
Date: Thu Jun 22 16:52:05 2006
New Revision: 416516

URL: http://svn.apache.org/viewvc?rev=416516&view=rev
Log:
>From Garrett Rooney...

Move code for reading xml files off of disk into a common base class.

[ in parser/src/java/org/apache/abdera/test/parser/stax ]

* BaseParserTestCase.java: New file.

* AtomConformanceTest.java
 Extend BaseParserTestCase.
 (parse): Removed.
 (testContentTypes, testOrder, testLink): Don't call .toString() on our
  URI.

* FeedParserTest.java
 Extend BaseParserTestCase.
 (parse): Removed.
 (baseURI): New member.
 (setUp): New method, initializes baseURI.
 (testAtom10Namespace, testEntryAuthorEmail, testEntryAuthorName,
  testEntryContentBase64, testEntryContentBase642): Use our baseURI to
  resolve the actual URI, and pass it to parse. 

* build/build.xml
 (compile.parser): Copy all the contents of the resource directory. 

Added:
    incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/BaseParserTestCase.java
    incubator/abdera/java/trunk/parser/src/test/resources/www.feedparser.org/
    incubator/abdera/java/trunk/parser/src/test/resources/www.feedparser.org/tests/
    incubator/abdera/java/trunk/parser/src/test/resources/www.snellspace.com/
    incubator/abdera/java/trunk/parser/src/test/resources/www.snellspace.com/public/
    incubator/abdera/java/trunk/parser/src/test/resources/www.snellspace.com/public/contentsummary.xml
      - copied unchanged from r416512, incubator/abdera/java/trunk/parser/src/test/resources/conformance/contentsummary.xml
    incubator/abdera/java/trunk/parser/src/test/resources/www.snellspace.com/public/linktests.xml
      - copied unchanged from r416512, incubator/abdera/java/trunk/parser/src/test/resources/conformance/linktests.xml
    incubator/abdera/java/trunk/parser/src/test/resources/www.snellspace.com/public/ordertest.xml
      - copied unchanged from r416512, incubator/abdera/java/trunk/parser/src/test/resources/conformance/ordertest.xml
Removed:
    incubator/abdera/java/trunk/parser/src/test/resources/conformance/
    incubator/abdera/java/trunk/parser/src/test/resources/feedparser/
Modified:
    incubator/abdera/java/trunk/build/build.xml
    incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java
    incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java

Modified: incubator/abdera/java/trunk/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/build/build.xml?rev=416516&r1=416515&r2=416516&view=diff
==============================================================================
--- incubator/abdera/java/trunk/build/build.xml (original)
+++ incubator/abdera/java/trunk/build/build.xml Thu Jun 22 16:52:05 2006
@@ -102,23 +102,11 @@
   	       destdir="${test}"
   	       classpathref="jar.dependencies"
   	       classpath="${core.work};${parser.work}" />
-  	<copy todir="${test}">
-  	  <fileset dir="${parser.test.resources}">
-  	    <include name="*.xml"/>
-  	  </fileset>
-  	</copy>
-        <mkdir dir="${test}/feedparser" />
-        <copy todir="${test}/feedparser">
-  	  <fileset dir="${parser.test.resources}/feedparser">
-  	    <include name="*.xml"/>
-  	  </fileset>
-  	</copy>
-        <mkdir dir="${test}/conformance" />
-        <copy todir="${test}/conformance">
-  	  <fileset dir="${parser.test.resources}/conformance">
-  	    <include name="*.xml"/>
-  	  </fileset>
-  	</copy>
+    <copy todir="${test}">
+      <fileset dir="${parser.test.resources}">
+        <include name="**"/>
+      </fileset>
+    </copy>
   </target>
 	
   <target name="compile.server" depends="init, compile.core">

Modified: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java?rev=416516&r1=416515&r2=416516&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java
(original)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java
Thu Jun 22 16:52:05 2006
@@ -36,16 +36,7 @@
 
 import junit.framework.TestCase;
 
-public class AtomConformanceTest extends TestCase {
-
-  private static Document<Feed> parse(String uri) {
-    try {
-      String path = "/conformance/" + uri.substring(uri.lastIndexOf('/'));
-      InputStream stream = AtomConformanceTest.class.getResourceAsStream(path);
-      return Parser.INSTANCE.parse(stream, uri);
-    } catch (Exception e) {}
-    return null;
-  }
+public class AtomConformanceTest extends BaseParserTestCase {
 
   private static Document<Feed> get(URI uri) {
     try {
@@ -53,14 +44,14 @@
     } catch (Exception e) {}
     return null;
   }
-  
+
   /**
    * Test to make sure that the parser properly detects the various kinds of
    * extended content types allowed by Atom
    */
   public static void testContentTypes() throws Exception {
     URI uri = new URI("http://www.snellspace.com/public/contentsummary.xml");
-    Document<Feed> doc = parse(uri.toString());
+    Document<Feed> doc = parse(uri);
     Feed feed = doc.getRoot();
     int n = 1;
     for (Entry entry : feed.getEntries()) {
@@ -328,7 +319,7 @@
   public static void testOrder() throws Exception {
     //http://www.snellspace.com/public/ordertest.xml
     URI uri = new URI("http://www.snellspace.com/public/ordertest.xml");
-    Document<Feed> doc = parse(uri.toString());
+    Document<Feed> doc = parse(uri);
     assertNotNull(doc);
     Feed feed = doc.getRoot();
     List<Entry> entries = feed.getEntries();
@@ -423,7 +414,7 @@
   public static void testLink() throws Exception {
     //http://www.snellspace.com/public/linktests.xml
     URI uri = new URI("http://www.snellspace.com/public/linktests.xml");
-    Document<Feed> doc = parse(uri.toString());
+    Document<Feed> doc = parse(uri);
     assertNotNull(doc);
     Feed feed = doc.getRoot();
     List<Entry> entries = feed.getEntries();

Added: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/BaseParserTestCase.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/BaseParserTestCase.java?rev=416516&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/BaseParserTestCase.java
(added)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/BaseParserTestCase.java
Thu Jun 22 16:52:05 2006
@@ -0,0 +1,42 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* 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 additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.test.parser.stax;
+
+import junit.framework.TestCase;
+
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.parser.Parser;
+
+import java.io.InputStream;
+import java.net.URI;
+
+public abstract class BaseParserTestCase extends TestCase {
+
+  protected static <T extends Element>Document<T> parse(URI uri) {
+    try {
+      String uriStr = uri.toString();
+      String path = uriStr.substring(uriStr.indexOf("//") + 1);
+      InputStream stream = BaseParserTestCase.class.getResourceAsStream(path);
+      return Parser.INSTANCE.parse(stream, uri);
+    } catch (Exception e) {}
+    return null;
+  }
+
+}

Modified: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java?rev=416516&r1=416515&r2=416516&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java
(original)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FeedParserTest.java
Thu Jun 22 16:52:05 2006
@@ -20,6 +20,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.net.URI;
 
 import javax.activation.DataHandler;
 
@@ -33,24 +34,21 @@
 
 import junit.framework.TestCase;
 
-public class FeedParserTest extends TestCase {
+public class FeedParserTest extends BaseParserTestCase {
 
-  private static Document<Feed> parse(String name) {
-    try {
-      String path = "/feedparser/" + name;
-      InputStream stream = FeedParserTest.class.getResourceAsStream(path);
-      return Parser.INSTANCE.parse(stream);
-    } catch (Exception e) {}
-    return null;
+  static URI baseURI;
+
+  protected void setUp() throws Exception {
+    baseURI = new URI("http://www.feedparser.org/tests/wellformed/atom10/");
   }
-  
+
   public void testAtom10Namespace() throws Exception {
-    Document doc = parse("atom10_namespace.xml");
+    Document doc = parse(baseURI.resolve("atom10_namespace.xml"));
     assertNotNull(doc);
   }
   
   public void testEntryAuthorEmail() throws Exception {
-    Document doc = parse("entry_author_email.xml");
+    Document doc = parse(baseURI.resolve("entry_author_email.xml"));
     Feed feed = (Feed) doc.getRoot();
     Entry entry = feed.getEntries().get(0);
     Person person = entry.getAuthor();
@@ -58,7 +56,7 @@
   }
   
   public void testEntryAuthorName() throws Exception {
-    Document doc = parse("entry_author_name.xml");
+    Document doc = parse(baseURI.resolve("entry_author_name.xml"));
     Feed feed = (Feed) doc.getRoot();
     Entry entry = feed.getEntries().get(0);
     Person person = entry.getAuthor();
@@ -66,7 +64,7 @@
   }
   
   public void testEntryContentBase64() throws Exception {
-    Document doc = parse("entry_content_base64.xml");
+    Document doc = parse(baseURI.resolve("entry_content_base64.xml"));
     Feed feed = (Feed)doc.getRoot();
     Entry entry = feed.getEntries().get(0);
     Content mediaContent = entry.getContentElement();
@@ -80,7 +78,7 @@
   }
   
   public void testEntryContentBase642() throws Exception {
-    Document doc = parse("entry_content_base64_2.xml");
+    Document doc = parse(baseURI.resolve("entry_content_base64_2.xml"));
     Feed feed = (Feed)doc.getRoot();
     Entry entry = feed.getEntries().get(0);
     Content mediaContent = entry.getContentElement();



Mime
View raw message