Asiri, you need to use JIRA issue references in your commits.
You already have one open for the officeimporter work so why don't you
use it?
Thanks
-Vincent
On Jan 7, 2009, at 8:25 AM, asiri (SVN) wrote:
Author: asiri
Date: 2009-01-07 08:25:13 +0100 (Wed, 07 Jan 2009)
New Revision: 15121
Modified:
sandbox/xwiki-officeimporter/src/test/java/org/xwiki/
officeimporter/internal/cleaner/OpenOfficeHTMLCleanerTest.java
Log:
* Added one more test case.
Modified: sandbox/xwiki-officeimporter/src/test/java/org/xwiki/
officeimporter/internal/cleaner/OpenOfficeHTMLCleanerTest.java
===================================================================
--- sandbox/xwiki-officeimporter/src/test/java/org/xwiki/
officeimporter/internal/cleaner/OpenOfficeHTMLCleanerTest.java
2009-01-07 07:07:10 UTC (rev 15120)
+++ sandbox/xwiki-officeimporter/src/test/java/org/xwiki/
officeimporter/internal/cleaner/OpenOfficeHTMLCleanerTest.java
2009-01-07 07:25:13 UTC (rev 15121)
@@ -227,4 +227,32 @@
assertEquals(Node.COMMENT_NODE, stopComment.getNodeType());
assertTrue(stopComment.getNodeValue().equals("stopimage"));
}
+
+ /**
+ * Test handling of image links.
+ */
+ public void testImageLinks() {
+ String html = header + "<a
href=\"http://www.xwiki.org
\"><img src=\"foo.png\"/></a>" + footer;
+ Document doc = cleaner.clean(new
StringReader(html),Collections.singletonMap("targetDocument",
"Import.Test"));
+ NodeList nodes = doc.getElementsByTagName("img");
+ assertEquals(1, nodes.getLength());
+ Element image = (Element)nodes.item(0);
+ Node startImageComment = image.getPreviousSibling();
+ Node stopImageComment = image.getNextSibling();
+ assertEquals(Node.COMMENT_NODE,
startImageComment.getNodeType());
+
assertTrue
(startImageComment.getNodeValue().equals("startimage:foo.png"));
+ assertEquals("/bridge/foo.png", image.getAttribute("src"));
+ assertEquals(Node.COMMENT_NODE,
stopImageComment.getNodeType());
+
assertTrue(stopImageComment.getNodeValue().equals("stopimage"));
+ Element link = (Element) image.getParentNode();
+ assertEquals("a", link.getNodeName());
+ assertEquals("http://www.xwiki.org",
link.getAttribute("href"));
+ Element span = (Element) link.getParentNode();
+ assertEquals("span", span.getNodeName());
+ assertEquals("wikiexternallink",
span.getAttribute("class"));
+ Node startLinkComment = span.getPreviousSibling();
+
assertTrue
(startLinkComment.getNodeValue().startsWith("startwikilink"));
+ Node stopLinkComment = span.getNextSibling();
+
assertTrue(stopLinkComment.getNodeValue().startsWith("stopwikilink"));
+ }
}