abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject svn commit: r471722 - /incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java
Date Mon, 06 Nov 2006 13:23:47 GMT
Author: ugo
Date: Mon Nov  6 05:23:47 2006
New Revision: 471722

URL: http://svn.apache.org/viewvc?view=rev&rev=471722
Log:
Test case for ABDERA-22.

Modified:
    incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java

Modified: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java?view=diff&rev=471722&r1=471721&r2=471722
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java
(original)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java
Mon Nov  6 05:23:47 2006
@@ -17,6 +17,12 @@
 */
 package org.apache.abdera.test.parser.stax;
 
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import junit.framework.TestCase;
+
 import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Entry;
@@ -24,8 +30,6 @@
 import org.apache.abdera.model.Service;
 import org.apache.abdera.parser.Parser;
 
-import junit.framework.TestCase;
-
 public class ParserTest extends TestCase {
 
   private static Abdera abdera = new Abdera();
@@ -47,6 +51,43 @@
     Document<Service> serviceDoc = getParser().parse(ParserTest.class.getResourceAsStream("/simpleService.xml"));
     assertTrue(serviceDoc.getRoot() instanceof Service);
     assertEquals(serviceDoc.getCharset(), "utf-8");
+    
+  }
+  
+  public static void testParseReader() throws Exception {
+
+    InputStream is = ParserTest.class.getResourceAsStream("/simpleFeed.xml");
+    Document<Feed> feedDoc = getParser().parse(new InputStreamReader(is), 
+        ParserTest.class.getResource("/simpleEntry.xml").toExternalForm());
+    assertTrue(feedDoc.getRoot() instanceof Feed);
+    assertEquals(feedDoc.getCharset(), "utf-8");
+
+    is = ParserTest.class.getResourceAsStream("/simpleEntry.xml");
+    Document<Entry> entryDoc = getParser().parse(new InputStreamReader(is),
+        ParserTest.class.getResource("/simpleEntry.xml").toExternalForm());
+    assertTrue(entryDoc.getRoot() instanceof Entry);
+    assertEquals(entryDoc.getCharset(), "utf-8");
+
+    is = ParserTest.class.getResourceAsStream("/simpleService.xml");
+    Document<Service> serviceDoc = getParser().parse(new InputStreamReader(is),
+        ParserTest.class.getResource("/simpleEntry.xml").toExternalForm());
+    assertTrue(serviceDoc.getRoot() instanceof Service);
+    assertEquals(serviceDoc.getCharset(), "utf-8");
+    
+  }
+  
+  /**
+   * Test for ABDERA-22.
+   * 
+   * @see https://issues.apache.org/jira/browse/ABDERA-22
+   */
+  public static void testParseReaderNoBase() throws Exception {
+
+    InputStream is = ParserTest.class.getResourceAsStream("/simpleEntry.xml");
+    Reader reader = new InputStreamReader(is);
+    Document<Entry> entryDoc = getParser().parse(reader);
+    assertTrue(entryDoc.getRoot() instanceof Entry);
+    assertEquals(entryDoc.getCharset(), "utf-8");
     
   }
   



Mime
View raw message