Author: Alex.Kolonitsky
Date: 2010-10-25 07:22:38 -0400 (Mon, 25 Oct 2010)
New Revision: 19665
Added:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/IgnoreScriptsContent.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuRendererTest.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
trunk/ui/output/ui/src/test/resources/org/
trunk/ui/output/ui/src/test/resources/org/richfaces/
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu.xhtml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu.xmlunit.xml
Modified:
trunk/ui/output/ui/pom.xml
Log:
BaseRenderer with xml unit
Modified: trunk/ui/output/ui/pom.xml
===================================================================
--- trunk/ui/output/ui/pom.xml 2010-10-25 11:12:37 UTC (rev 19664)
+++ trunk/ui/output/ui/pom.xml 2010-10-25 11:22:38 UTC (rev 19665)
@@ -68,6 +68,12 @@
<groupId>org.richfaces.ui.output</groupId>
<artifactId>richfaces-ui-output-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<scm>
Added:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/IgnoreScriptsContent.java
===================================================================
---
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/IgnoreScriptsContent.java
(rev 0)
+++
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/IgnoreScriptsContent.java 2010-10-25
11:22:38 UTC (rev 19665)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import org.custommonkey.xmlunit.Difference;
+import org.custommonkey.xmlunit.DifferenceConstants;
+import org.custommonkey.xmlunit.DifferenceListener;
+import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener;
+import org.w3c.dom.Node;
+
+import java.util.Arrays;
+
+/**
+ * @author akolonitsky
+ * @since Oct 22, 2010
+ */
+public class IgnoreScriptsContent implements DifferenceListener {
+ private static final int[] IGNORE = new int[] {
+ DifferenceConstants.HAS_DOCTYPE_DECLARATION_ID,
+ DifferenceConstants.DOCTYPE_NAME_ID,
+ DifferenceConstants.DOCTYPE_PUBLIC_ID_ID,
+ DifferenceConstants.DOCTYPE_SYSTEM_ID_ID
+ };
+
+ static {
+ Arrays.sort(IGNORE);
+ }
+
+ public int differenceFound(Difference difference) {
+ if (DifferenceConstants.TEXT_VALUE_ID == difference.getId()
+ &&
!"script".equalsIgnoreCase(difference.getTestNodeDetail().getNode().getLocalName()))
{
+
+ return RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
+ }
+ return RETURN_ACCEPT_DIFFERENCE;
+ }
+
+ public void skippedComparison(Node node, Node node1) {
+
+ }
+}
Added:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuRendererTest.java
===================================================================
---
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuRendererTest.java
(rev 0)
+++
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/PanelMenuRendererTest.java 2010-10-25
11:22:38 UTC (rev 19665)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+
+package org.richfaces.renderkit.html;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+
+ /**
+ * @author akolonitsky
+ * @since 2010-10-25
+ */
+public class PanelMenuRendererTest extends RendererTestBase {
+
+ @Test
+ @Ignore
+ public void testDoEncode() throws IOException, SAXException {
+ doTest("panelMenu", "panelMenu");
+ }
+
+}
+
+
+
Added:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
(rev 0)
+++
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-10-25
11:22:38 UTC (rev 19665)
@@ -0,0 +1,92 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.xml.sax.SAXException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author akolonitsky
+ * @since Oct 22, 2010
+ */
+public abstract class RendererTestBase {
+
+ static {
+ XMLUnit.setNormalizeWhitespace(true);
+ XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
+ XMLUnit.setIgnoreWhitespace(true);
+ XMLUnit.setIgnoreComments(true);
+
+ }
+
+ protected HtmlUnitEnvironment environment;
+
+ @Before
+ public void setUp() throws URISyntaxException {
+ environment = new HtmlUnitEnvironment();
+ environment.withWebRoot(new
File(this.getClass().getResource(".").toURI()));
+ environment.start();
+ }
+
+ @After
+ public void tearDown() {
+ environment.release();
+ environment = null;
+ }
+
+ protected void doTest(String pageName, String pageElementToTest) throws IOException,
SAXException {
+ HtmlPage page = environment.getPage('/' + pageName + ".jsf");
+ HtmlElement panel = page.getElementById(pageElementToTest);
+ assertNotNull(panel);
+
+ checkXmlStructure(pageName, panel.asXml());
+ }
+
+ protected void checkXmlStructure(String pageName, String pageCode) throws
SAXException, IOException {
+ InputStream expectedPageCode = this.getClass().getResourceAsStream(pageName +
".xmlunit.xml");
+ if (expectedPageCode == null) {
+ return;
+ }
+
+ Diff xmlDiff = new Diff(new StringReader(pageCode), new
InputStreamReader(expectedPageCode));
+ xmlDiff.overrideDifferenceListener(new IgnoreScriptsContent());
+ Assert.assertTrue("XML was not similar:" + xmlDiff.toString(),
xmlDiff.similar());
+ }
+
+}
+
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu.xhtml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu.xhtml
(rev 0)
+++
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu.xhtml 2010-10-25
11:22:38 UTC (rev 19665)
@@ -0,0 +1,47 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright ${year}, Red Hat, Inc. and individual contributors
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:pn="http://richfaces.org/output"
+
xmlns:rich="http://richfaces.org/rich">
+
+ <h:head>
+ <title>Richfaces PanelMenu Test</title>
+ </h:head>
+
+<h:body>
+ <h:form id="f" style="border:blue solid thin;">
+ <pn:panelMenu id="panelMenu">
+ <!-- TODO -->
+ </pn:panelMenu>
+ </h:form>
+</h:body>
+</html>
+
+
Added:
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu.xmlunit.xml
===================================================================
---
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu.xmlunit.xml
(rev 0)
+++
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/panelMenu.xmlunit.xml 2010-10-25
11:22:38 UTC (rev 19665)
@@ -0,0 +1,5 @@
+<div id="panelMenu" class="rf-panelMenu">
+ <script type="text/javascript">
+ // Text between <script> ... </script> don't compared
+ </script>
+</div>