Author: alexsmirnov
Date: 2010-10-15 19:58:54 -0400 (Fri, 15 Oct 2010)
New Revision: 19587
Added:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptObject.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererTest.java
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorTestBase.java
Log:
OPEN - issue RF-9507: ClientValidatorRendererunit tests and implementation.
https://jira.jboss.org/browse/RF-9507
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-15
19:19:49 UTC (rev 19586)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-15
23:58:54 UTC (rev 19587)
@@ -3,10 +3,16 @@
//
// Imports
//
+import javax.faces.FacesException;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.render.ClientBehaviorRenderer;
+import org.richfaces.component.UIValidatorScript;
+import org.richfaces.component.behavior.ClientValidatorBehavior;
+import org.richfaces.validator.ScriptNotFoundException;
+import org.richfaces.validator.ValidatorDescriptor;
+
/**
* Renderer for component class org.richfaces.renderkit.html.AjaxValidatorRenderer
*/
@@ -20,6 +26,36 @@
@Override
public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior
behavior) {
+ if (behavior instanceof ClientValidatorBehavior) {
+ ClientValidatorBehavior clientValidator = (ClientValidatorBehavior)
behavior;
+
+ } else {
+ throw new FacesException(
+ "ClientBehavior for ClientValidatorRenderer does not implement
ClientValidatorBehavior interface");
+ }
return null;
}
+
+ String buildValidatorScript(ClientBehaviorContext behaviorContext,
ClientValidatorBehavior behavior){
+ return null;
+ }
+
+ UIValidatorScript getOrCreateValidatorScriptComponent(ClientBehaviorContext
behaviorContext, ClientValidatorBehavior behavior){
+ return null;
+ }
+
+ ComponentValidatorScript createValidatorScript(ClientBehaviorContext
behaviorContext,
+ ClientValidatorBehavior behavior) {
+ return null;
+ }
+
+ ScriptObject getConverterScript(ClientBehaviorContext behaviorContext,
ClientValidatorBehavior behavior)
+ throws ScriptNotFoundException {
+ return null;
+ }
+
+ ScriptObject getValidatorScript(ClientBehaviorContext behaviorContext,
ValidatorDescriptor validator)
+ throws ScriptNotFoundException {
+ return null;
+ }
}
Added:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
(rev 0)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-10-15
23:58:54 UTC (rev 19587)
@@ -0,0 +1,5 @@
+package org.richfaces.renderkit.html;
+
+public class ComponentValidatorScript {
+
+}
Property changes on:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptObject.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptObject.java
(rev 0)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptObject.java 2010-10-15
23:58:54 UTC (rev 19587)
@@ -0,0 +1,73 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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 java.util.Collection;
+
+import org.richfaces.validator.ClientScript;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ScriptObject {
+
+ private ClientScript script;
+
+ private Collection<Object> parameters;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the script
+ */
+ public ClientScript getScript() {
+ return this.script;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param script the script to set
+ */
+ public void setScript(ClientScript script) {
+ this.script = script;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the parameters
+ */
+ public Collection<Object> getParameters() {
+ return this.parameters;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param parameters the parameters to set
+ */
+ public void setParameters(Collection<Object> parameters) {
+ this.parameters = parameters;
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorTestBase.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorTestBase.java 2010-10-15
19:19:49 UTC (rev 19586)
+++
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorTestBase.java 2010-10-15
23:58:54 UTC (rev 19587)
@@ -29,7 +29,7 @@
@Mock
protected ClientBehaviorRenderer behaviorRenderer;
protected MockController controller;
- protected ClientValidatorImpl behavior;
+ protected ClientValidatorBehavior behavior;
@Mock
protected ValueExpression expression;
@Stub
@@ -50,7 +50,7 @@
return behaviorContext;
}
- private ClientValidatorImpl createBehavior() {
+ protected ClientValidatorBehavior createBehavior() {
return new ClientValidatorImpl();
}
Added:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
(rev 0)
+++
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-10-15
23:58:54 UTC (rev 19587)
@@ -0,0 +1,19 @@
+package org.richfaces.renderkit.html;
+
+import org.richfaces.component.behavior.BehaviorTestBase;
+import org.richfaces.component.behavior.ClientValidatorBehavior;
+
+public class RendererTestBase extends BehaviorTestBase {
+
+ protected ClientValidatorRenderer renderer = new ClientValidatorRenderer();
+
+ public RendererTestBase() {
+ super();
+ }
+
+ @Override
+ protected ClientValidatorBehavior createBehavior() {
+ return controller.createMock(ClientValidatorBehavior.class);
+ }
+
+}
\ No newline at end of file
Property changes on:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererTest.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererTest.java
(rev 0)
+++
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererTest.java 2010-10-15
23:58:54 UTC (rev 19587)
@@ -0,0 +1,31 @@
+package org.richfaces.renderkit.html;
+
+import javax.faces.FacesException;
+import javax.faces.component.behavior.ClientBehavior;
+
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * <p class="changed_added_4_0">Test getScript method for wrong
parameters.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(MockTestRunner.class)
+public class ValidatorRendererTest extends RendererTestBase {
+
+ @Test(expected=NullPointerException.class)
+ public void testGetScriptNullContext() {
+ renderer.getScript(null, behavior);
+ }
+ @Test(expected=NullPointerException.class)
+ public void testGetScriptNullBehavior() {
+ renderer.getScript(setupBehaviorContext(input), null);
+ }
+
+ @Test(expected=FacesException.class)
+ public void testGetScriptWrongBehavior() {
+ renderer.getScript(null, controller.createNiceMock(ClientBehavior.class));
+ }
+}
Property changes on:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/ValidatorRendererTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain