Author: dsvyatobatsko
Date: 2009-01-30 10:24:38 -0500 (Fri, 30 Jan 2009)
New Revision: 12504
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5887
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java 2009-01-30
13:08:33 UTC (rev 12503)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java 2009-01-30
15:24:38 UTC (rev 12504)
@@ -72,6 +72,8 @@
public static final String VALIDATOR_MESSAGE = "Validator message";
+ public static final String REQUIRED_MESSAGE = "Required message";
+
public static final String AUTOTEST_BEAN_NAME = "autoTestBean";
// private String input = INPUT_TEXT;
@@ -101,7 +103,9 @@
private String processInput;
private boolean processSet = false;
-
+
+ private boolean required;
+
public class AutoTestConverter implements Converter {
public static final String AS_OBJECT_STRING =
"AUTO_TEST_CONVERTER_AS_OBJECT";
@@ -425,69 +429,95 @@
this.validatorId = validatorId;
}
- /**
- * @return the validatorMessage
- */
- public String getValidatorMessage() {
- return VALIDATOR_MESSAGE;
- }
+ /**
+ * @return the requiredMessage
+ */
+ public String getRequiredMessage() {
+ return REQUIRED_MESSAGE;
+ }
- /**
- * @return the converter
- */
- public Converter getConverter() {
- if (converterSet) {
- return converter;
- }
- return null;
- }
+ /**
+ * @return the validatorMessage
+ */
+ public String getValidatorMessage() {
+ return VALIDATOR_MESSAGE;
+ }
- /**
- * @return the converterSet
- */
- public boolean isConverterSet() {
- return converterSet;
- }
+ /**
+ * @return the converter
+ */
+ public Converter getConverter() {
+ if (converterSet) {
+ return converter;
+ }
+ return null;
+ }
- /**
- * @param converterSet the converterSet to set
- */
- public void setConverterSet(boolean converterSet) {
- this.converterSet = converterSet;
- }
+ /**
+ * @return the converterSet
+ */
+ public boolean isConverterSet() {
+ return converterSet;
+ }
- /**
- * @return the processSet
- */
- public boolean isProcessSet() {
- return processSet;
- }
+ /**
+ * @param converterSet
+ * the converterSet to set
+ */
+ public void setConverterSet(boolean converterSet) {
+ this.converterSet = converterSet;
+ }
- /**
- * @param processSet the processSet to set
- */
- public void setProcessSet(boolean processSet) {
- this.processSet = processSet;
- }
+ /**
+ * @return the processSet
+ */
+ public boolean isProcessSet() {
+ return processSet;
+ }
- /**
- * @return the processInput
- */
- public String getProcessInput() {
- return null;
- }
+ /**
+ * @param processSet
+ * the processSet to set
+ */
+ public void setProcessSet(boolean processSet) {
+ this.processSet = processSet;
+ }
- /**
- * @param processInput the processInput to set
- */
- public void setProcessInput(String processInput) {
- if (processSet) {
+ /**
+ * @return the processInput
+ */
+ public String getProcessInput() {
+ return null;
+ }
+
+ /**
+ * @param processInput
+ * the processInput to set
+ */
+ public void setProcessInput(String processInput) {
+ if (processSet) {
setStatus(getStatus() + PROCESS_INPUT_UPDATE_MODEL);
}
- }
+ }
- public String getProcess() {
- return (processSet) ? "_auto_process_input" : "_auto_input";
- }
+ public String getProcess() {
+ return (processSet) ? "_auto_process_input" : "_auto_input";
+ }
+ /**
+ * Gets value of required field.
+ * @return value of required field
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * Set a new value for required field.
+ * @param required a new value for required field
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml 2009-01-30
13:08:33 UTC (rev 12503)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml 2009-01-30
15:24:38 UTC (rev 12504)
@@ -67,7 +67,13 @@
</td>
</tr>
<tr>
+ <td>Required:</td>
<td>
+ <h:selectBooleanCheckbox id="_auto_required"
value="#{autoTestBean.required}"></h:selectBooleanCheckbox>
+ </td>
+ </tr>
+ <tr>
+ <td>
<h:commandButton id="_auto_load"
actionListener="#{templateBean.reset}" action="#{autoTestBean.load}"
value="Load"></h:commandButton>
</td>
<td>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2009-01-30
13:08:33 UTC (rev 12503)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2009-01-30
15:24:38 UTC (rev 12504)
@@ -443,6 +443,10 @@
base.changeValue();
}
+ private void setValueEmpty() {
+ base.setValueEmpty();
+ }
+
public void setInternalValidation(boolean passed) {
setupControl(TestSetupEntry.validatorId, (passed) ?
AutoTestBean.VALIDATOR_DEFAULT_ID : AutoTestBean.VALIDATOR_ID);
}
@@ -532,6 +536,28 @@
}
}
+ public void testRequiredAndRequiredMessageAttributes() {
+ reset();
+ setupControl(TestSetupEntry.required, true);
+ clickLoad();
+ setValueEmpty();
+ clickSubmit();
+
+ String errorMessage = getValidatorMessage();
+
+ if (null == errorMessage ||
!errorMessage.contains(AutoTestBean.REQUIRED_MESSAGE)) {
+ Assert.fail("requiredMessage attribute does not work. RequiredMessage
expected: ["
+ + AutoTestBean.REQUIRED_MESSAGE + "].But was [" +
errorMessage + "]");
+ }
+
+ try {
+ checkUpdateModel(false);
+ checkValueChangeListener(false);
+ } catch (AssertionError ae) {
+ Assert.fail("required attribute does not work. Cause: " +
ae.getMessage());
+ }
+ }
+
public void checkActionListener(boolean passed) {
String status = getStatus();
if (passed && status != null &&
status.indexOf(AutoTestBean.ACTION_LISTENER_STATUS) == -1) {
@@ -659,6 +685,8 @@
public static final TestSetupEntry process = new
TestSetupEntry("process", Boolean.class, Boolean.FALSE);
+ public static final TestSetupEntry required = new
TestSetupEntry("required", Boolean.class, Boolean.FALSE);
+
public static final List<TestSetupEntry> list = new
ArrayList<TestSetupEntry>();
static {
list.add(reRender);
@@ -671,6 +699,7 @@
list.add(oncomplete);
list.add(converter);
list.add(process);
+ list.add(required);
}
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-30
13:08:33 UTC (rev 12503)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-30
15:24:38 UTC (rev 12504)
@@ -1224,6 +1224,14 @@
}
/**
+ * This call back has to bring auto test component value to the state as if a user
has not provided a submitted value for the component
+ * Used for auto testing only.
+ */
+ public void setValueEmpty() {
+ throw new UnsupportedOperationException("This method has always to be
overridden before usage");
+ }
+
+ /**
* Returns the array of components' ids that are rerendering after ajax request
from the component.
* This method should be overridden for auto test
*/
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-30
13:08:33 UTC (rev 12503)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-30
15:24:38 UTC (rev 12504)
@@ -64,6 +64,15 @@
}
@Test
+ public void testRequiredAndRequiredMessageAttributes(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+
+ writeStatus("Check required & requiredMessage attributes");
+ tester.testRequiredAndRequiredMessageAttributes();
+ }
+
+ @Test
public void testCycleMode(Template template) {
renderPage(template, RESET_METHOD);
writeStatus("Check cycled attribute");
@@ -261,6 +270,11 @@
}
@Override
+ public void setValueEmpty() {
+ selenium.type("name=" + getParentId() + FORM_ID +
"componentId", " ");
+ }
+
+ @Override
public String getAutoTestUrl() {
return "pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml";
}