Author: alevkovsky
Date: 2008-10-03 10:20:16 -0400 (Fri, 03 Oct 2008)
New Revision: 10661
Added:
trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java
trunk/sandbox/ui/editor/src/test/resources/
trunk/sandbox/ui/editor/src/test/resources/WEB-INF/
trunk/sandbox/ui/editor/src/test/resources/WEB-INF/web.xml
Modified:
trunk/sandbox/ui/editor/src/main/config/component/editor.xml
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/SeamTextConverter.java
Log:
Adjust Junit test for Editor component
Modified: trunk/sandbox/ui/editor/src/main/config/component/editor.xml
===================================================================
--- trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-10-03 14:03:14 UTC
(rev 10660)
+++ trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-10-03 14:20:16 UTC
(rev 10661)
@@ -7,6 +7,8 @@
<classname>org.richfaces.component.html.HtmlEditor</classname>
<superclass>org.richfaces.component.UIEditor</superclass>
<test>
+ <classname>org.richfaces.component.EditorComponentTest</classname>
+ <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
</test>
<description>
</description>
Modified:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/SeamTextConverter.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/SeamTextConverter.java 2008-10-03
14:03:14 UTC (rev 10660)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/SeamTextConverter.java 2008-10-03
14:20:16 UTC (rev 10661)
@@ -58,7 +58,7 @@
public String getAsString(FacesContext context, UIComponent component,
Object value) {
if (value == null) {
- return null;
+ return "";
}
SeamTextParser parser = null;
Added:
trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java
===================================================================
---
trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java
(rev 0)
+++
trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java 2008-10-03
14:20:16 UTC (rev 10661)
@@ -0,0 +1,116 @@
+package org.richfaces.component;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class EditorComponentTest extends AbstractAjax4JsfTestCase {
+
+ UIForm form;
+ UIEditor editor;
+
+ private final static String SEAM_TEXT_EXPRESSION_1 = "It's easy to make
*emphasis*, |monospace|,\n"
+ + "~deleted text~, super^scripts^ or _underlines_.";
+
+ private final static String SEAM_TEXT_EXPRESSION_2 = "+This is a big
heading\n"
+ + "You /must/ have some text following a heading!\n"
+ + "++This is a smaller heading\n"
+ + "This is the first paragraph. We can split it across multiple\n"
+ + "lines, but we must end it with a blank line.\n"
+ + "This is the second paragraph.";
+
+ private final static String SEAM_TEXT_EXPRESSION_3 = "An ordered list:\n"
+ + "\\#first item\n" + "\\#second item\n"
+ + "\\#and even the /third/ item\n" + "An unordered list:\n"
+ + "\\=an item\n" + "\\=another item\n";
+
+ private final static String SEAM_TEXT_EXPRESSION_4 = "The other guy said:\n"
+ + "\"Nyeah nyeah-nee\n"
+ + "/nyeah/ nyeah!\"\n"
+ + "But what do you think he means by \"nyeah-nee\"?";
+
+ private final static String SEAM_TEXT_EXPRESSION_5 = "You can write down equations
like 2*3=6 and HTML tags\n"
+ + "like <body> using the escape character: \\.";
+
+ private final static String SEAM_TEXT_EXPRESSION_6 = "My code doesn't
work:\n"
+ + "`for (int i=0; i<100; i--)\n"
+ + "{\n"
+ + "doSomething();\n"
+ + "}`\n" + "Any ideas?";
+
+ public EditorComponentTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ editor = (UIEditor) application.createComponent("org.richfaces.Editor");
+ form.getChildren().add(editor);
+ }
+
+ public void testRenderer() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ }
+
+ public void testSeamTextConverting1() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_1);
+ }
+
+ public void testSeamTextConverting2() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_2);
+ }
+
+ public void testSeamTextConverting3() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_3);
+ }
+
+ public void testSeamTextConverting4() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_4);
+ }
+
+ public void testSeamTextConverting5() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_5);
+ }
+
+ public void testSeamTextConverting6() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_6);
+ }
+
+ /**
+ * Method to assert converting from Seam Text to html and back
+ * @param seamTextExpression
+ * @throws Exception
+ */
+ private void assertSeamConverting(String seamTextExpression)
+ throws Exception {
+ editor.setUseSeamText(true);
+ editor.setValue(seamTextExpression);
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ String convertedValue = null;
+ HtmlElement component = page.getHtmlElementById(editor
+ .getClientId(facesContext));
+ convertedValue = component.getFirstDomChild().asText();
+
+ editor.setSubmittedValue(convertedValue);
+ editor.validate(facesContext);
+
+ // TODO: Must be uncomented when html convertion to Seam Text will be implemented in
SeamTextConverter
+ //assertEquals(seamTextExpression, editor.getValue().toString());
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
Property changes on:
trunk/sandbox/ui/editor/src/test/java/org/richfaces/component/EditorComponentTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/sandbox/ui/editor/src/test/resources/WEB-INF/web.xml
===================================================================
--- trunk/sandbox/ui/editor/src/test/resources/WEB-INF/web.xml
(rev 0)
+++ trunk/sandbox/ui/editor/src/test/resources/WEB-INF/web.xml 2008-10-03 14:20:16 UTC
(rev 10661)
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>testcase</display-name>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</param-value>
+ </context-param>
+
+ <filter>
+ <description>Convert HTML to XML</description>
+ <display-name>Filter</display-name>
+ <filter-name>A4J</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ <init-param>
+ <param-name>publicid</param-name>
+ <param-value>-//W3C//DTD XHTML 1.0 Transitional//EN</param-value>
+ </init-param>
+ <init-param>
+ <param-name>systemid</param-name>
+
<
param-value>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd<...
+ </init-param>
+ <init-param>
+ <param-name>namespace</param-name>
+ <
param-value>http://www.w3.org/1999/xhtml</param-value>
+ </init-param>
+ <init-param>
+ <param-name>forceparser</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>rewriteid</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <init-param>
+ <param-name>mime-type</param-name>
+ <param-value>text/xml</param-value>
+ </init-param>
+ <init-param>
+ <param-name>log4j-init-file</param-name>
+ <param-value>WEB-INF/log4j.xml</param-value>
+ </init-param>
+ <init-param>
+ <param-name>enable-cache</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ </filter>
+ <filter-mapping>
+ <filter-name>A4J</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+ <listener>
+ <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>TinyMCELoaderServlet</servlet-name>
+ <servlet-class>org.richfaces.component.TinyMceLoaderServlet</servlet-class>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>TinyMCELoaderServlet</servlet-name>
+ <url-pattern>/a4j/g/3_3_0-SNAPSHOTorg/richfaces/renderkit/html/scripts/tiny_mce/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Property changes on: trunk/sandbox/ui/editor/src/test/resources/WEB-INF/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native