Author: sergeyhalipov
Date: 2007-11-23 09:12:08 -0500 (Fri, 23 Nov 2007)
New Revision: 4219
Added:
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/JSFComponentTest.java
Removed:
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/JSFComponentTest.java
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/sandbox/
Modified:
branches/3.1.x/ui/componentControl/pom.xml
branches/3.1.x/ui/componentControl/src/main/java/org/richfaces/sandbox/component/UIComponentControl.java
Log:
http://jira.jboss.com/jira/browse/RF-1367
Modified: branches/3.1.x/ui/componentControl/pom.xml
===================================================================
--- branches/3.1.x/ui/componentControl/pom.xml 2007-11-23 13:42:45 UTC (rev 4218)
+++ branches/3.1.x/ui/componentControl/pom.xml 2007-11-23 14:12:08 UTC (rev 4219)
@@ -21,6 +21,13 @@
<goal>generate</goal>
</goals>
</execution>
+ <execution>
+ <id>generate-test-sources</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>generate-tests</goal>
+ </goals>
+ </execution>
</executions>
<configuration>
<library>
@@ -46,4 +53,4 @@
<version>3.1.3-SNAPSHOT</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified:
branches/3.1.x/ui/componentControl/src/main/java/org/richfaces/sandbox/component/UIComponentControl.java
===================================================================
---
branches/3.1.x/ui/componentControl/src/main/java/org/richfaces/sandbox/component/UIComponentControl.java 2007-11-23
13:42:45 UTC (rev 4218)
+++
branches/3.1.x/ui/componentControl/src/main/java/org/richfaces/sandbox/component/UIComponentControl.java 2007-11-23
14:12:08 UTC (rev 4219)
@@ -165,5 +165,10 @@
}
}
}
+
+ public abstract void setName(String name);
+ public abstract String getName();
+ public abstract void setAttachTiming( String attachTiming);
+ public abstract String getAttachTiming();
}
Copied: branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component (from rev
4177, branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/sandbox/component)
Added:
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java
===================================================================
---
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java
(rev 0)
+++
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java 2007-11-23
14:12:08 UTC (rev 4219)
@@ -0,0 +1,176 @@
+/**
+ * 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.component;
+
+import javax.faces.FacesException;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UIParameter;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.sandbox.component.UIComponentControl;
+
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * Unit test for simple Component.
+ */
+public class ComponentControlTest extends AbstractAjax4JsfTestCase {
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public ComponentControlTest( String testName )
+ {
+ super( testName );
+ }
+
+ private UIForm form = null;
+ private UIComponentControl componentControl = null;
+ private UIInput input = null;
+ private UIOutput output = null;
+ public UIParameter param = null;
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ application.addComponent(UIComponentControl.COMPONENT_TYPE,
"org.richfaces.sandbox.component.html.HtmlComponentControl");
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ input = new UIInput();
+ input.setId("input");
+ input.setValue("value");
+ form.getChildren().add(input);
+
+ componentControl = (UIComponentControl)
application.createComponent(UIComponentControl.COMPONENT_TYPE);
+ componentControl.setEvent("onclick");
+ componentControl.setOperation("testOperation");
+ componentControl.setName("testName");
+ componentControl.setId("componentControl");
+ componentControl.setParams("x:'y'");
+ componentControl.setFor("button");
+ input.getChildren().add(componentControl);
+
+ output = new UIOutput();
+ output.setId("output");
+ output.setValue("test");
+ form.getChildren().add(output);
+
+ param = new UIParameter();
+ param.setName("name");
+ param.setValue("value");
+ componentControl.getChildren().add(param);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ param = null;
+ input = null;
+ componentControl = null;
+ output = null;
+ form = null;
+ }
+
+ public void testEventString() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ HtmlInput htmlInput =
(HtmlInput)page.getHtmlElementById(input.getClientId(facesContext));
+ assertNotNull(htmlInput);
+
+ String eventString = htmlInput.getAttributeValue("onclick");
+ assertNotNull(eventString);
+
assertTrue(eventString.contains("Richfaces.componentControl.performOperation"));
+ String [] params = eventString.split(",");
+ assertEquals(5, params.length);
+
+ assertTrue(params[0].trim().endsWith("event"));
+ assertEquals("'#button'", params[1].trim());
+ assertEquals("'testOperation'", params[2].trim());
+ assertTrue(params[3].trim().startsWith("{"));
+ assertTrue(params[4].trim().endsWith("});"));
+
+ assertTrue( true );
+ }
+
+ public void testParametersMap() throws Exception {
+ String paramMap = componentControl.getEncodedParametersMap();
+ assertNotNull(paramMap);
+
+ String [] arr = paramMap.split(",");
+ assertEquals(2, arr.length);
+
+ String [] arr1 = arr[0].split(":");
+ assertEquals(2, arr1.length);
+ String [] arr2 = arr[1].split(":");
+ assertEquals(2, arr2.length);
+ if ("x".equals(arr1[0].trim())) {
+ assertEquals("'y'", arr1[1].trim());
+ assertEquals("'name'", arr2[0].trim());
+ assertEquals("'value'", arr2[1].trim());
+ } else {
+ assertEquals("'name'", arr1[0].trim());
+ assertEquals("'value'", arr1[1].trim());
+ assertEquals("x", arr2[0].trim());
+ assertEquals("'y'", arr2[1].trim());
+ }
+
+ param.setName(null);
+ try {
+ renderView();
+ assertTrue("Parameter name is null, but exception isn't thrown!",
false);
+ } catch (IllegalArgumentException e) {
+
+ }
+ }
+
+ public void testCheckValidity() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ componentControl.setAttachTiming("wrong value");
+ try {
+ renderView();
+ assertTrue("attachTiming attribute has wrong value, but exception isn't
thrown!", false);
+ } catch (FacesException e) {
+
+ }
+
+ componentControl.setAttachTiming("onload");
+ componentControl.setOperation("");
+ try {
+ renderView();
+ assertTrue("operation is empty, but exception isn't thrown!", false);
+ } catch (FacesException e) {
+
+ }
+ }
+}
Deleted:
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
---
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java 2007-11-22
12:30:58 UTC (rev 4177)
+++
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-11-23
14:12:08 UTC (rev 4219)
@@ -1,53 +0,0 @@
-/**
- * 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.sandbox.component;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
-
-/**
- * Unit test for simple Component.
- */
-public class JSFComponentTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public JSFComponentTest( String testName )
- {
- super( testName );
- }
-
-
- /**
- * Rigourous Test :-)
- */
- public void testComponent()
- {
- assertTrue( true );
- }
-}
Copied:
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/JSFComponentTest.java
(from rev 4217,
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java)
===================================================================
---
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/JSFComponentTest.java
(rev 0)
+++
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-11-23
14:12:08 UTC (rev 4219)
@@ -0,0 +1,53 @@
+/**
+ * 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.sandbox.component;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import javax.faces.component.UIComponent;
+
+/**
+ * Unit test for simple Component.
+ */
+public class JSFComponentTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public JSFComponentTest( String testName )
+ {
+ super( testName );
+ }
+
+
+ /**
+ * Rigourous Test :-)
+ */
+ public void testComponent()
+ {
+ assertTrue( true );
+ }
+}