Author: vmolotkov
Date: 2008-11-04 12:55:54 -0500 (Tue, 04 Nov 2008)
New Revision: 11025
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/InplaceInputValidator.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/testValidator.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InplaceInputTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InplaceInputTest.java
Log:
tests for inplaceinput
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InplaceInputTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InplaceInputTestBean.java 2008-11-04
17:25:58 UTC (rev 11024)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InplaceInputTestBean.java 2008-11-04
17:55:54 UTC (rev 11025)
@@ -1,5 +1,10 @@
package org.ajax4jsf.bean;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
public class InplaceInputTestBean {
public final static class Messages {
@@ -27,4 +32,10 @@
public void action() {
setText(InplaceInputTestBean.Messages.ACTION_CALLED);
}
+
+ public void validator(FacesContext arg0, UIComponent arg1, Object arg2) {
+ if (!"test".equals(arg2)) {
+ throw new ValidatorException(new FacesMessage("Value isn't correct!"));
+ }
+ }
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/InplaceInputValidator.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/InplaceInputValidator.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/InplaceInputValidator.java 2008-11-04
17:55:54 UTC (rev 11025)
@@ -0,0 +1,26 @@
+/**
+ *
+ */
+package org.ajax4jsf.validators;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * @author Vladimir Molotkov
+ *
+ */
+public class InplaceInputValidator implements Validator {
+
+ public void validate(FacesContext arg0, UIComponent arg1, Object arg2)
+ throws ValidatorException {
+ if (!"test".equals(arg2)) {
+ throw new ValidatorException(new FacesMessage("Value isn't correct!"));
+ }
+
+ }
+
+}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-11-04
17:25:58 UTC (rev 11024)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-11-04
17:55:54 UTC (rev 11025)
@@ -25,6 +25,11 @@
<validator-class>org.ajax4jsf.validators.ValidatorWithAttribute</validator-class>
</validator>
+ <validator>
+ <validator-id>inplaceInputValidator</validator-id>
+
<validator-class>org.ajax4jsf.validators.InplaceInputValidator</validator-class>
+ </validator>
+
<validator>
<validator-id>autoTestValidator</validator-id>
<validator-class>org.ajax4jsf.autotest.bean.AutoTestValidator</validator-class>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/testValidator.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/testValidator.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inplaceInput/testValidator.xhtml 2008-11-04
17:55:54 UTC (rev 11025)
@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+ template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testControlsFacet</ui:define>
+ <ui:define name="caseBody">
+ <h:form id="_form">
+ <table cellpadding="5" >
+ <tr>
+ <td>1</td>
+ <td>
+ <rich:inplaceInput id="ii_tv1" value="test"
validator="#{inplaceInputBean.validator}">
+ </rich:inplaceInput>
+ <h:commandButton id="bn_tv1"
action="#{inplaceInputBean.action}"
value="Submit"></h:commandButton>
+ </td>
+ <td><span id="text_tv1"><h:message
for="ii_tv1"/></span></td>
+ </tr>
+ <tr>
+ <td>2</td>
+ <td>
+ <rich:inplaceInput id="ii_tv2" value="test" >
+ <f:validator validatorId="inplaceInputValidator" />
+ </rich:inplaceInput>
+ <h:commandButton id="bn_tv2"
action="#{inplaceInputBean.action}" value="Submit"/>
+ </td>
+ <td><span id="text_tv2"><h:message
for="ii_tv2"></h:message></span></td>
+ </tr>
+ </table>
+ </h:form>
+ </ui:define>
+</ui:composition>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InplaceInputTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InplaceInputTest.java 2008-11-04
17:25:58 UTC (rev 11024)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InplaceInputTest.java 2008-11-04
17:55:54 UTC (rev 11025)
@@ -57,6 +57,10 @@
private static final String SHOW_CONTROLS_ATTRIBUTE_BAR = "bar";
+ private static final String VALIDATOR_PAGE = "testValidator.xhtml";
+
+ private static final String VALIDATOR_PAGE_ID_PREFIX = "_tv";
+
private String testUrl;
private String formId;
@@ -189,123 +193,176 @@
//
// }
- /**
- * 'required' and 'requiredMessage' attributes work
- *
- * @param template - current template
- */
- @Test
- public void testRequiredAttributes(Template template) {
- setTestUrl(REQUIRED_ATTRIBUTES_PAGE);
- init(template);
-
- selenium.click("id=" + buttonId + REQUIRED_ATTRIBUTES_ID_PREFIX);
- waitForPageToLoad();
- checkMessage(messageId + REQUIRED_ATTRIBUTES_ID_PREFIX,
"text:requiredMsg", CommonUtils.getSuccessfulTestMessage(inplaceInputId +
REQUIRED_ATTRIBUTES_ID_PREFIX), CommonUtils.getFailedTestMessage(inplaceInputId +
REQUIRED_ATTRIBUTES_ID_PREFIX));
- }
+// /**
+// * 'required' and 'requiredMessage' attributes work
+// *
+// * @param template - current template
+// */
+// @Test
+// public void testRequiredAttributes(Template template) {
+// setTestUrl(REQUIRED_ATTRIBUTES_PAGE);
+// init(template);
+//
+// selenium.click("id=" + buttonId + REQUIRED_ATTRIBUTES_ID_PREFIX);
+// waitForPageToLoad();
+// checkMessage(messageId + REQUIRED_ATTRIBUTES_ID_PREFIX,
"text:requiredMsg", CommonUtils.getSuccessfulTestMessage(inplaceInputId +
REQUIRED_ATTRIBUTES_ID_PREFIX), CommonUtils.getFailedTestMessage(inplaceInputId +
REQUIRED_ATTRIBUTES_ID_PREFIX));
+// }
+//
+// /**
+// * Check 'editEvent' attribute
+// *
+// * @param template - current template
+// */
+// @Test
+// public void testEditEventAttribute(Template template) {
+// setTestUrl(EDITEVENT_ATTRIBUTES_PAGE);
+// init(template);
+//
+// selenium.doubleClick(inplaceInputId + EDITEVENT_ATTRIBUTES_ID_PREFIX);
+// Map<String, String> expMap = new HashMap<String, String>();
+// expMap.put("clip", "rect(auto auto auto auto)");
+// assertStyleAttributes(inplaceInputId + EDITEVENT_ATTRIBUTES_ID_PREFIX +
"tempValue", expMap);
+// }
+//
+// /**
+// * Check 'controls' facet
+// *
+// * @param template - current template
+// */
+// @Test
+// public void testControlsFacet(Template template) {
+// setTestUrl(CONTROLS_FACET_PAGE);
+// init(template);
+//
+// check((isPresentById(CONTROLS_FACET_BN_OK + CONTROLS_FACET_ID_PREFIX) ||
isPresentById(CONTROLS_FACET_BN_CANCEL + CONTROLS_FACET_ID_PREFIX)),
+// CommonUtils.getSuccessfulTestMessage(inplaceInputId +
CONTROLS_FACET_ID_PREFIX),
+// CommonUtils.getFailedTestMessage(inplaceInputId + CONTROLS_FACET_ID_PREFIX));
+// }
+//
+// /**
+// * Input some spaces in inplaceInput; verify that defaultLabel is
+// * displayed after selecting; component does not disappear from the page
+// *
+// * @param template - current template
+// */
+// @Test
+// public void testDefaultLabelAndSpaces(Template template) {
+// setTestUrl(DEFAULTLABEL_AND_SPACES_PAGE);
+// init(template);
+//
+// String iid = inplaceInputId + DEFAULTLABEL_AND_SPACES_PAGE_ID_PREFIX;
+//
+// checkMessage(iid, "defaultLabel",
+// CommonUtils.getSuccessfulTestMessage(iid),
+// CommonUtils.getFailedTestMessage(iid));
+//
+// typeAndCheck(iid, " ", "defaultLabel");
+// typeAndCheck(iid, "test", "test");
+// }
+//
+// /**
+// * Verify component behaviour with showControls="false" attribute
+// *
+// * @param template - current template
+// */
+// @Test
+// public void testShowControlsAttribute1(Template template) {
+// setTestUrl(SHOW_CONTROLS_ATTRIBUTE1_PAGE);
+// init(template);
+//
+// String iid = inplaceInputId + SHOW_CONTROLS_ATTRIBUTE1_PAGE_ID_PREFIX;
+//
+// clickById(iid);
+// check(!isVisibleById(iid + SHOW_CONTROLS_ATTRIBUTE_BAR),
+// CommonUtils.getSuccessfulTestMessage(iid),
+// CommonUtils.getFailedTestMessage(iid));
+//
+// Map<String, String> expMap = new HashMap<String, String>();
+// expMap.put("clip", "rect(auto auto auto auto)");
+// assertStyleAttributes(iid+ "tempValue", expMap);
+// selenium.fireEvent(iid + "tempValue", "blur");
+// expMap.remove("clip");
+// expMap.put("clip", "rect(0px 0px 0px 0px)");
+// assertStyleAttributes(iid+ "tempValue", expMap);
+// }
+//
+// /**
+// * The same as previous but with showControls="true" attribute
+// *
+// * @param template - current template
+// */
+// @Test
+// public void testShowControlsAttribute2(Template template) {
+// setTestUrl(SHOW_CONTROLS_ATTRIBUTE2_PAGE);
+// init(template);
+//
+// String iid = inplaceInputId + SHOW_CONTROLS_ATTRIBUTE2_PAGE_ID_PREFIX;
+//
+// clickById(iid);
+// check(isVisibleById(iid + SHOW_CONTROLS_ATTRIBUTE_BAR),
+// CommonUtils.getSuccessfulTestMessage(iid),
+// CommonUtils.getFailedTestMessage(iid));
+//
+// Map<String, String> expMap = new HashMap<String, String>();
+// expMap.put("clip", "rect(auto auto auto auto)");
+// assertStyleAttributes(iid+ "tempValue", expMap);
+// selenium.fireEvent(iid + "tempValue", "blur");
+// expMap.remove("clip");
+// expMap.put("clip", "rect(auto auto auto auto)");
+// assertStyleAttributes(iid+ "tempValue", expMap);
+// }
/**
- * Check 'editEvent' attribute
+ * Validator defined by component attribute and nested tags work
*
* @param template - current template
*/
@Test
- public void testEditEventAttribute(Template template) {
- setTestUrl(EDITEVENT_ATTRIBUTES_PAGE);
+ public void testValidator1(Template template) {
+ setTestUrl(VALIDATOR_PAGE);
init(template);
- selenium.doubleClick(inplaceInputId + EDITEVENT_ATTRIBUTES_ID_PREFIX);
- Map<String, String> expMap = new HashMap<String, String>();
- expMap.put("clip", "rect(auto auto auto auto)");
- assertStyleAttributes(inplaceInputId + EDITEVENT_ATTRIBUTES_ID_PREFIX +
"tempValue", expMap);
- }
-
- /**
- * Check 'controls' facet
- *
- * @param template - current template
- */
- @Test
- public void testControlsFacet(Template template) {
- setTestUrl(CONTROLS_FACET_PAGE);
- init(template);
+ String iid = inplaceInputId + VALIDATOR_PAGE_ID_PREFIX;
- check((isPresentById(CONTROLS_FACET_BN_OK + CONTROLS_FACET_ID_PREFIX) ||
isPresentById(CONTROLS_FACET_BN_CANCEL + CONTROLS_FACET_ID_PREFIX)),
- CommonUtils.getSuccessfulTestMessage(inplaceInputId + CONTROLS_FACET_ID_PREFIX),
- CommonUtils.getFailedTestMessage(inplaceInputId + CONTROLS_FACET_ID_PREFIX));
- }
-
- /**
- * Input some spaces in inplaceInput; verify that defaultLabel is
- * displayed after selecting; component does not disappear from the page
- *
- * @param template - current template
- */
- @Test
- public void testDefaultLabelAndSpaces(Template template) {
- setTestUrl(DEFAULTLABEL_AND_SPACES_PAGE);
- init(template);
+ clickById(buttonId + VALIDATOR_PAGE_ID_PREFIX + "1");
+ waitForPageToLoad();
+ check("".equals(getTextById(messageId + VALIDATOR_PAGE_ID_PREFIX +
"1")),
+ CommonUtils.getSuccessfulTestMessage(iid + "1"),
+ CommonUtils.getFailedTestMessage(iid + "1"));
- String iid = inplaceInputId + DEFAULTLABEL_AND_SPACES_PAGE_ID_PREFIX;
-
- checkMessage(iid, "defaultLabel",
- CommonUtils.getSuccessfulTestMessage(iid),
- CommonUtils.getFailedTestMessage(iid));
-
- typeAndCheck(iid, " ", "defaultLabel");
- typeAndCheck(iid, "test", "test");
+ clickById(buttonId + VALIDATOR_PAGE_ID_PREFIX + "2");
+ waitForPageToLoad();
+ check("".equals(getTextById(messageId + VALIDATOR_PAGE_ID_PREFIX +
"2")),
+ CommonUtils.getSuccessfulTestMessage(iid + "2"),
+ CommonUtils.getFailedTestMessage(iid + "2"));
}
/**
- * Verify component behaviour with showControls="false" attribute
+ * Validator defined by component attribute and nested tags work
*
* @param template - current template
*/
@Test
- public void testShowControlsAttribute1(Template template) {
- setTestUrl(SHOW_CONTROLS_ATTRIBUTE1_PAGE);
+ public void testValidator2(Template template) {
+ setTestUrl(VALIDATOR_PAGE);
init(template);
- String iid = inplaceInputId + SHOW_CONTROLS_ATTRIBUTE1_PAGE_ID_PREFIX;
+ String iid = inplaceInputId + VALIDATOR_PAGE_ID_PREFIX;
- clickById(iid);
- check(!isVisibleById(iid + SHOW_CONTROLS_ATTRIBUTE_BAR),
- CommonUtils.getSuccessfulTestMessage(iid),
- CommonUtils.getFailedTestMessage(iid));
+ setValueById(iid + "1" + "value", "test1");
+ setValueById(iid + "2" + "value", "test1");
- Map<String, String> expMap = new HashMap<String, String>();
- expMap.put("clip", "rect(auto auto auto auto)");
- assertStyleAttributes(iid+ "tempValue", expMap);
- selenium.fireEvent(iid + "tempValue", "blur");
- expMap.remove("clip");
- expMap.put("clip", "rect(0px 0px 0px 0px)");
- assertStyleAttributes(iid+ "tempValue", expMap);
- }
-
- /**
- * The same as previous but with showControls="true" attribute
- *
- * @param template - current template
- */
- @Test
- public void testShowControlsAttribute2(Template template) {
- setTestUrl(SHOW_CONTROLS_ATTRIBUTE2_PAGE);
- init(template);
+ clickById(buttonId + VALIDATOR_PAGE_ID_PREFIX + "1");
+ waitForPageToLoad();
+ check("Value isn't correct!".equals(getTextById(messageId +
VALIDATOR_PAGE_ID_PREFIX + "1")),
+ CommonUtils.getSuccessfulTestMessage(iid + "1"),
+ CommonUtils.getFailedTestMessage(iid + "1"));
- String iid = inplaceInputId + SHOW_CONTROLS_ATTRIBUTE2_PAGE_ID_PREFIX;
-
- clickById(iid);
- check(isVisibleById(iid + SHOW_CONTROLS_ATTRIBUTE_BAR),
- CommonUtils.getSuccessfulTestMessage(iid),
- CommonUtils.getFailedTestMessage(iid));
-
- Map<String, String> expMap = new HashMap<String, String>();
- expMap.put("clip", "rect(auto auto auto auto)");
- assertStyleAttributes(iid+ "tempValue", expMap);
- selenium.fireEvent(iid + "tempValue", "blur");
- expMap.remove("clip");
- expMap.put("clip", "rect(auto auto auto auto)");
- assertStyleAttributes(iid+ "tempValue", expMap);
+ clickById(buttonId + VALIDATOR_PAGE_ID_PREFIX + "2");
+ waitForPageToLoad();
+ check("Value isn't correct!".equals(getTextById(messageId +
VALIDATOR_PAGE_ID_PREFIX + "2")),
+ CommonUtils.getSuccessfulTestMessage(iid + "2"),
+ CommonUtils.getFailedTestMessage(iid + "2"));
}
private void typeAndCheck(String iid, String word, String expectedWord) {