[richfaces-svn-commits] JBoss Rich Faces SVN: r11959 - in trunk/ui/beanValidator/src: test/java/org/richfaces/component and 1 other directory.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Mon Dec 22 08:06:14 EST 2008
Author: alevkovsky
Date: 2008-12-22 08:06:14 -0500 (Mon, 22 Dec 2008)
New Revision: 11959
Added:
trunk/ui/beanValidator/src/test/java/org/richfaces/component/BeanValidatorComponentTest.java
trunk/ui/beanValidator/src/test/java/org/richfaces/component/GraphValidatorComponentTest.java
Removed:
trunk/ui/beanValidator/src/test/java/org/richfaces/component/JSFComponentTest.java
Modified:
trunk/ui/beanValidator/src/main/config/component/beanValidator.xml
Log:
Add JUnits for BeanValidator and GraphValidator
Modified: trunk/ui/beanValidator/src/main/config/component/beanValidator.xml
===================================================================
--- trunk/ui/beanValidator/src/main/config/component/beanValidator.xml 2008-12-21 16:23:05 UTC (rev 11958)
+++ trunk/ui/beanValidator/src/main/config/component/beanValidator.xml 2008-12-22 13:06:14 UTC (rev 11959)
@@ -103,6 +103,14 @@
org.richfaces.component.html.HtmlGraphValidator
</classname>
<superclass>org.richfaces.component.UIGraphValidator</superclass>
+ <test>
+ <classname>
+ org.richfaces.component.html.GraphValidatorTest
+ </classname>
+ <superclassname>
+ org.ajax4jsf.tests.AbstractAjax4JsfTestCase
+ </superclassname>
+ </test>
<description><![CDATA[The <rich:graphValidator> component allows to register Hibernate Validators for multiple input components.]]></description>
<tag>
<name>graphValidator</name>
@@ -156,6 +164,14 @@
<classname>
org.richfaces.validator.FacesBeanValidator
</classname>
+ <test>
+ <classname>
+ org.richfaces.component.html.BeanValidatorTest
+ </classname>
+ <superclassname>
+ org.ajax4jsf.tests.AbstractAjax4JsfTestCase
+ </superclassname>
+ </test>
<description>
<![CDATA[Validate Input by the Bean/Hibernate validator annotations]]>
</description>
Added: trunk/ui/beanValidator/src/test/java/org/richfaces/component/BeanValidatorComponentTest.java
===================================================================
--- trunk/ui/beanValidator/src/test/java/org/richfaces/component/BeanValidatorComponentTest.java (rev 0)
+++ trunk/ui/beanValidator/src/test/java/org/richfaces/component/BeanValidatorComponentTest.java 2008-12-22 13:06:14 UTC (rev 11959)
@@ -0,0 +1,186 @@
+/**
+ * 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 java.util.Set;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.MethodInfo;
+import javax.el.PropertyNotFoundException;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIMessages;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.el.MethodNotFoundException;
+import javax.faces.event.ActionEvent;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.webapp.taglib.MethodExpressionAjaxListener;
+import org.richfaces.component.html.HtmlInputText;
+import org.richfaces.event.ValidationEvent;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class BeanValidatorComponentTest extends AbstractAjax4JsfTestCase {
+
+ UIForm form = null;
+ UIBeanValidator validator = null;
+ HtmlInputText input = null;
+ UIMessages messages = null;
+
+ public BeanValidatorComponentTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+ input = (HtmlInputText)application.createComponent(HtmlInputText.COMPONENT_TYPE);
+ validator = (UIBeanValidator)application.createComponent(UIBeanValidator.COMPONENT_TYPE);
+ validator.setId("validator");
+
+ input.getChildren().add(validator);
+ input.setId("input");
+ form.getChildren().add(input);
+ messages = (UIMessages)application.createComponent(UIMessages.COMPONENT_TYPE);
+ messages.setId("messages");
+ form.getChildren().add(messages);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testValidator() throws Exception {
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ assertNotNull(validator.getMessages(facesContext));
+ }
+
+ public void testAddRemoveListenerValidator() throws Exception {
+
+ AjaxListener listener = new MethodExpressionAjaxListener(listenerExpression);
+ validator.addAjaxListener(listener);
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ assertEquals(1, validator.getAjaxListeners().length);
+ assertEquals(listenerExpression, validator.getAjaxListener());
+ validator.setAjaxListener(listenerExpression2);
+ assertEquals(1, validator.getAjaxListeners().length);
+ }
+
+ public void testBroadcast() throws Exception {
+
+ AjaxListener listener = new MethodExpressionAjaxListener(listenerExpression);
+ validator.addAjaxListener(listener);
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ validator.broadcast(new AjaxEvent(validator));
+ assertTrue(facesContext.getMessages(validator.getClientId(facesContext)).hasNext());
+
+ }
+
+ public void testQueueEvent() throws Exception {
+
+ AjaxListener listener = new MethodExpressionAjaxListener(listenerExpression);
+ validator.addAjaxListener(listener);
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ validator.queueEvent(new ValidationEvent(validator));
+ }
+
+ MethodExpression listenerExpression = new MethodExpression(){
+
+ public Object invoke(ELContext context, Object[] params) throws PropertyNotFoundException, MethodNotFoundException,
+ ELException {
+ facesContext.addMessage(validator.getClientId(facesContext), new FacesMessage("Method invoked!"));
+ return "invoked";
+ }
+
+ public MethodInfo getMethodInfo(ELContext context) {
+
+ return null;
+ }
+
+ public boolean equals(Object obj) {
+ return (obj instanceof MethodExpression && obj.hashCode() == this.hashCode());
+ }
+
+
+ public String getExpressionString() {
+ return null;
+ }
+
+ public int hashCode() {
+ return 0;
+ }
+
+ public boolean isLiteralText() {
+ return false;
+ }
+
+ };
+
+ MethodExpression listenerExpression2 = new MethodExpression(){
+
+ public Object invoke(ELContext context, Object[] params) throws PropertyNotFoundException, MethodNotFoundException,
+ ELException {
+ facesContext.addMessage(validator.getClientId(facesContext), new FacesMessage("Method invoked!"));
+ return "invoked";
+ }
+
+ public MethodInfo getMethodInfo(ELContext context) {
+
+ return null;
+ }
+
+ public boolean equals(Object obj) {
+ return (obj instanceof MethodExpression && obj.hashCode() == this.hashCode());
+ }
+
+
+ public String getExpressionString() {
+ return null;
+ }
+
+ public int hashCode() {
+ return 0;
+ }
+
+ public boolean isLiteralText() {
+ return false;
+ }
+
+ };
+
+
+}
Property changes on: trunk/ui/beanValidator/src/test/java/org/richfaces/component/BeanValidatorComponentTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/ui/beanValidator/src/test/java/org/richfaces/component/GraphValidatorComponentTest.java
===================================================================
--- trunk/ui/beanValidator/src/test/java/org/richfaces/component/GraphValidatorComponentTest.java (rev 0)
+++ trunk/ui/beanValidator/src/test/java/org/richfaces/component/GraphValidatorComponentTest.java 2008-12-22 13:06:14 UTC (rev 11959)
@@ -0,0 +1,72 @@
+/**
+ * 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.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIMessages;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class GraphValidatorComponentTest extends AbstractAjax4JsfTestCase {
+
+ UIForm form = null;
+ UIGraphValidator validator = null;
+ UIInput input = null;
+ UIMessages messages = null;
+
+ public GraphValidatorComponentTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ validator = (UIGraphValidator) application
+ .createComponent(UIGraphValidator.COMPONENT_TYPE);
+ validator.setId("validator");
+ input = (UIInput) application.createComponent(UIInput.COMPONENT_TYPE);
+ input.setId("input");
+ validator.getChildren().add(input);
+ form.getChildren().add(validator);
+ messages = (UIMessages) application
+ .createComponent(UIMessages.COMPONENT_TYPE);
+ messages.setId("messages");
+ form.getChildren().add(messages);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testValidator() throws Exception {
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ }
+
+}
Property changes on: trunk/ui/beanValidator/src/test/java/org/richfaces/component/GraphValidatorComponentTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Deleted: trunk/ui/beanValidator/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/ui/beanValidator/src/test/java/org/richfaces/component/JSFComponentTest.java 2008-12-21 16:23:05 UTC (rev 11958)
+++ trunk/ui/beanValidator/src/test/java/org/richfaces/component/JSFComponentTest.java 2008-12-22 13:06:14 UTC (rev 11959)
@@ -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.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 );
- }
-}
More information about the richfaces-svn-commits
mailing list