abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1374700 - in /abdera/java/trunk/parser/src/test: java/org/apache/abdera/test/parser/stax/ParserOptionsTest.java resources/parseroptionstest.xml
Date Sun, 19 Aug 2012 07:25:37 GMT
Author: veithen
Date: Sun Aug 19 07:25:37 2012
New Revision: 1374700

URL: http://svn.apache.org/viewvc?rev=1374700&view=rev
Log:
Added a unit test for attribute filtering.

Modified:
    abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserOptionsTest.java
    abdera/java/trunk/parser/src/test/resources/parseroptionstest.xml

Modified: abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserOptionsTest.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserOptionsTest.java?rev=1374700&r1=1374699&r2=1374700&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserOptionsTest.java
(original)
+++ abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserOptionsTest.java
Sun Aug 19 07:25:37 2012
@@ -19,6 +19,7 @@ package org.apache.abdera.test.parser.st
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.HashMap;
@@ -29,9 +30,11 @@ import javax.xml.namespace.QName;
 import org.apache.abdera.Abdera;
 import org.apache.abdera.filter.ParseFilter;
 import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
 import org.apache.abdera.parser.Parser;
 import org.apache.abdera.parser.ParserOptions;
+import org.apache.abdera.util.filter.AbstractParseFilter;
 import org.junit.Test;
 
 public class ParserOptionsTest {
@@ -74,6 +77,26 @@ public class ParserOptionsTest {
     }
     
     @Test
+    public void testAttributeFiltering() {
+        final QName filteredAttribute = new QName("urn:test", "attr");
+        Parser parser = abdera.getParser();
+        ParserOptions options = parser.getDefaultParserOptions();
+        options.setParseFilter(new AbstractParseFilter() {
+            public boolean acceptable(QName qname) {
+                return true;
+            }
+
+            public boolean acceptable(QName qname, QName attribute) {
+                return !filteredAttribute.equals(attribute);
+            }
+        });
+        Document<Feed> doc = parser.parse(ParserOptionsTest.class.getResourceAsStream(
+                "/parseroptionstest.xml"), options);
+        Entry entry = doc.getRoot().getEntries().get(0);
+        assertNull(entry.getAttributeValue(filteredAttribute));
+    }
+    
+    @Test
     public void testQNameAliasMapping() {
         Parser parser = abdera.getParser();
         ParserOptions options = parser.getDefaultParserOptions();

Modified: abdera/java/trunk/parser/src/test/resources/parseroptionstest.xml
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/test/resources/parseroptionstest.xml?rev=1374700&r1=1374699&r2=1374700&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/test/resources/parseroptionstest.xml (original)
+++ abdera/java/trunk/parser/src/test/resources/parseroptionstest.xml Sun Aug 19 07:25:37
2012
@@ -2,7 +2,7 @@
 <feed xmlns="http://www.w3.org/2005/Atom">
     <!-- comment -->
     <?pi processing instruction?>
-    <entry>
+    <entry x:attr="value" xmlns:x="urn:test">
         <title>Atom-Powered Robots Run Amok</title>
         <ns:mylink href="http://example.org/2003/12/13/atom03" xmlns:ns="urn:test"/>
         <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>



Mime
View raw message