Author: alexsmirnov
Date: 2010-09-14 19:40:15 -0400 (Tue, 14 Sep 2010)
New Revision: 19208
Added:
branches/RF-8742/ui/validator/ui/src/test/java/ClientValidatorBehaviorTest.java
Log:
https://jira.jboss.org/browse/RF-9219
Added: branches/RF-8742/ui/validator/ui/src/test/java/ClientValidatorBehaviorTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/ClientValidatorBehaviorTest.java
(rev 0)
+++
branches/RF-8742/ui/validator/ui/src/test/java/ClientValidatorBehaviorTest.java 2010-09-14
23:40:15 UTC (rev 19208)
@@ -0,0 +1,112 @@
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.component.behavior.ClientBehaviorContext;
+
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockController;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.jboss.test.faces.mock.Stub;
+import org.jboss.test.faces.mock.Environment.Feature;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.component.ClientValidatorBehavior;
+
+
+/**
+ * <p class="changed_added_4_0">This class tests client validator
behavior.
+ * as it described at
https://community.jboss.org/wiki/ClientSideValidation # Server-side
rendering algorithm</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(MockTestRunner.class)
+public class ClientValidatorBehaviorTest {
+
+ @Mock()
+ @Environment({Feature.APPLICATION})
+ protected MockFacesEnvironment environment;
+
+ @Stub
+ private UIOutput output;
+
+ @Mock
+ protected UIInput input;
+
+ @Mock
+ private ClientBehaviorContext behaviorContext;
+
+ protected MockController controller;
+
+ /**
+ * <p class="changed_added_4_0">Server-side rendering algorithm
.1</p>
+ */
+ @Test(expected=FacesException.class)
+ public void testGetScriptForIllegalComponent() {
+ getScript(output);
+ }
+
+ /**
+ * <p class="changed_added_4_0">Server-side rendering algorithm
.2</p>
+ * @throws Exception
+ */
+ @Test
+ public void testGetScriptWithoutMessageComponent() throws Exception {
+
+ }
+
+ /**
+ * <p class="changed_added_4_0">Server-side rendering algorithm .3 -
determine client-side converter</p>
+ * @throws Exception
+ */
+ @Test
+ public void testGetClientConverter() throws Exception {
+
+ }
+ /**
+ * <p class="changed_added_4_0">Server-side rendering algorithm
.3</p>
+ * @throws Exception
+ */
+ @Test
+ public void testGetScriptWithoutClientConverter() throws Exception {
+
+ }
+
+ /**
+ * <p class="changed_added_4_0">Server-side rendering algorithm
.3</p>
+ * @throws Exception
+ */
+ @Test
+ public void testGetScriptWithClientConverter() throws Exception {
+
+ }
+
+ private String getScript(UIComponent component) {
+ ClientValidatorBehavior behavior = createBehavior();
+ controller.replay();
+ String script = behavior.getScript(setupBehaviorContext(component));
+ controller.verify();
+ return script;
+ }
+
+ private ClientBehaviorContext setupBehaviorContext(UIComponent component) {
+ expect(behaviorContext.getComponent()).andStubReturn(component);
+
expect(behaviorContext.getFacesContext()).andStubReturn(environment.getFacesContext());
+ return behaviorContext;
+ }
+
+ private ClientValidatorBehavior createBehavior() {
+ return new ClientValidatorBehavior();
+ }
+
+ @Test
+ public void testDecode() {
+ fail("Not yet implemented");
+ }
+
+}