wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nfisc...@apache.org
Subject svn commit: r799998 - in /incubator/wink/trunk/wink-common/src: main/java/org/apache/wink/common/model/atom/AtomJAXBUtils.java test/java/org/apache/wink/common/model/atom/AtomTest.java
Date Sun, 02 Aug 2009 06:30:33 GMT
Author: nfischer
Date: Sun Aug  2 06:30:32 2009
New Revision: 799998

URL: http://svn.apache.org/viewvc?rev=799998&view=rev
Log:
Fix for Error reading an Atom feed that has text directly under xhtml root div element [WINK-123]

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/atom/AtomJAXBUtils.java
    incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/atom/AtomJAXBUtils.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/atom/AtomJAXBUtils.java?rev=799998&r1=799997&r2=799998&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/atom/AtomJAXBUtils.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/atom/AtomJAXBUtils.java
Sun Aug  2 06:30:32 2009
@@ -710,9 +710,9 @@
                 }
                 if (isXmlOpen) {
                     result = result.trim();
-                    if (!result.startsWith("<")) {
+                    if (!result.startsWith("<") && !isXhtml) {
                         throw new RuntimeException(
-                                                   "Illegal atom content: must contain a
single child element");
+                                "Illegal atom content: must contain a single child element");
                     }
                 }
                 return result;
@@ -722,10 +722,6 @@
                 return elementCounter == 0;
             }
 
-            public void setContentIsXhtml(boolean isContentXhtml) {
-                this.isXhtml = isContentXhtml;
-            }
-
             private boolean isFirstElement() {
                 return elementCounter == 1;
             }

Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java?rev=799998&r1=799997&r2=799998&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java
(original)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java
Sun Aug  2 06:30:32 2009
@@ -57,6 +57,14 @@
                                                                  + "        <h1>title</h1>\n"
                                                                  + "    </div>\n"
                                                                  + "</title>\n";
+    private static final String ATOM_TEXT_XHTML_WITH_TEXT =
+        "<title type=\"xhtml\" xml:lang=\"en-us\" xml:base=\"http://title/base\" xmlns=\"http://www.w3.org/2005/Atom\">\n"
+ "    <div xmlns=\""
+            + RestConstants.NAMESPACE_XHTML
+            + "\">\n"
+            + "        title\n"
+            + "    </div>\n"
+            + "</title>\n";
+
     private static final String ATOM_TEXT_XHTML_WITH_DIV =
                                                              "<title type=\"xhtml\" xml:lang=\"en-us\"
xml:base=\"http://title/base\" xmlns=\"http://www.w3.org/2005/Atom\">\n" + "    <div
xmlns=\""
                                                                  + RestConstants.NAMESPACE_XHTML
@@ -78,6 +86,14 @@
                                                                  + "        <h1>title</h1>\n"
                                                                  + "    </div>\n"
                                                                  + "</content>\n";
+    private static final String ATOM_CONTENT_XHTML_WITH_TEXT       =
+        "<content type=\"xhtml\" xml:lang=\"en-us\" xml:base=\"http://title/base\" xmlns=\"http://www.w3.org/2005/Atom\">\n"
+ "    <div xmlns=\""
+            + RestConstants.NAMESPACE_XHTML
+            + "\">\n"
+            + "        title\n"
+            + "    </div>\n"
+            + "</content>\n";
+
     private static final String ATOM_CONTENT_XML         =
                                                              "<content type=\"application/xml\"
xml:lang=\"en-us\" xml:base=\"http://title/base\" xmlns=\"http://www.w3.org/2005/Atom\">\n"
+ "    <x xmlns=\"http://x/\">title</x>\n"
                                                                  + "</content>\n";
@@ -329,7 +345,18 @@
         assertEquals("<h1 xmlns=\"" + RestConstants.NAMESPACE_XHTML + "\">title</h1>",
text
             .getValue());
         assertEquals(AtomTextType.xhtml, text.getType());
-    }
+
+        element = AtomJAXBUtils.unmarshal(u, new StringReader(ATOM_TEXT_XHTML_WITH_TEXT));
+        assertNotNull(element);
+        assertTrue(element instanceof AtomText);
+        text = (AtomText)element;
+        assertNotNull(text);
+        assertEquals("en-us", text.getLang());
+        assertEquals("http://title/base", text.getBase());
+        assertEquals("title", text
+            .getValue());
+        assertEquals(AtomTextType.xhtml, text.getType());
+}
 
     public void testAtomTextUnmarshalXhtml() throws Exception {
         Unmarshaller u = JAXBUtils.createUnmarshaller(ctx);
@@ -418,6 +445,17 @@
         assertEquals("<h1 xmlns=\"" + RestConstants.NAMESPACE_XHTML + "\">title</h1>",
content
             .getValue());
         assertEquals("xhtml", content.getType());
+        
+        element = AtomJAXBUtils.unmarshal(u, new StringReader(ATOM_CONTENT_XHTML_WITH_TEXT));
+        assertNotNull(element);
+        assertTrue(element instanceof AtomContent);
+        content = (AtomContent)element;
+        assertNotNull(content);
+        assertEquals("en-us", content.getLang());
+        assertEquals("http://title/base", content.getBase());
+        assertEquals("title", content
+            .getValue());
+        assertEquals("xhtml", content.getType());        
 
         element = AtomJAXBUtils.unmarshal(u, new StringReader(ATOM_CONTENT_XML));
         assertNotNull(element);



Mime
View raw message