Author: konstantin.mishin
Date: 2008-11-26 08:31:12 -0500 (Wed, 26 Nov 2008)
New Revision: 11392
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/MessageBean2.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/message.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/MessageTest.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
Log:
RF-5012
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/MessageBean2.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/MessageBean2.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/MessageBean2.java 2008-11-26
13:31:12 UTC (rev 11392)
@@ -0,0 +1,51 @@
+package org.ajax4jsf.bean;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+public class MessageBean2 implements Validator{
+
+ static public final String MESSAGE = "Validation is failed";
+
+ private String string;
+
+ public MessageBean2() {
+
+ }
+
+ public void init() {
+ string = "something";
+ }
+
+ public void validate(FacesContext context, UIComponent component,
+ Object value) throws ValidatorException {
+ Severity severity = null;
+ if ("fatal".equals(value)) {
+ severity = FacesMessage.SEVERITY_FATAL;
+ } else if ("error".equals(value)) {
+ severity = FacesMessage.SEVERITY_ERROR;
+ } else if ("warn".equals(value)) {
+ severity = FacesMessage.SEVERITY_WARN;
+ } else if ("info".equals(value)) {
+ severity = FacesMessage.SEVERITY_INFO;
+ }
+ if (severity != null) {
+ FacesMessage message = new FacesMessage(MESSAGE);
+ message.setSeverity(severity);
+ throw new ValidatorException(message);
+ }
+ }
+
+ public void setString(String string) {
+ this.string = string;
+ }
+
+ public String getString() {
+ return string;
+ }
+
+}
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-26
13:01:12 UTC (rev 11391)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-11-26
13:31:12 UTC (rev 11392)
@@ -46,6 +46,12 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>messageBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.MessageBean2</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
<managed-bean>
<managed-bean-name>indexBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.IndexBean</managed-bean-class>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/message.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/message.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/message.xhtml 2008-11-26
13:31:12 UTC (rev 11392)
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.template}">
+ <ui:define name="style">
+
+ </ui:define>
+ <ui:define name="component">
+ <h:form id="mainForm">
+ <h:panelGroup id="panel">
+ <h:inputText id="inputText" value="#{messageBean.string}"
validator="#{messageBean.validate}"></h:inputText>
+ <rich:message for="inputText">
+ <f:facet name="fatalMarker">
+ <h:outputText id="fatalMarker"
value="fatalMarker"></h:outputText>
+ </f:facet>
+ <f:facet name="errorMarker">
+ <h:outputText id="errorMarker"
value="errorMarker"></h:outputText>
+ </f:facet>
+ <f:facet name="warnMarker">
+ <h:outputText id="warnMarker"
value="warnMarker"></h:outputText>
+ </f:facet>
+ <f:facet name="infoMarker">
+ <h:outputText id="infoMarker"
value="infoMarker"></h:outputText>
+ </f:facet>
+ <f:facet name="passedMarker">
+ <h:outputText id="passedMarker"
value="passedMarker"></h:outputText>
+ </f:facet>
+ </rich:message>
+ </h:panelGroup>
+ <a4j:commandButton id="submit" value="Submit"
reRender="panel"></a4j:commandButton>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/MessageTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/MessageTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/MessageTest.java 2008-11-26
13:31:12 UTC (rev 11392)
@@ -0,0 +1,49 @@
+package org.richfaces.testng;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.SeleniumTestBase;
+import org.testng.annotations.Test;
+
+public class MessageTest extends SeleniumTestBase {
+
+ private String mainForm;
+
+ private String inputText;
+
+ private String submit;
+
+ private void init(Template template) {
+ renderPage(template, "#{messageBean.init}");
+ mainForm = getParentId() + "mainForm";
+ inputText = mainForm + ":inputText";
+ submit = mainForm + ":submit";
+ }
+
+ /**
+ * check markers rendering
+ */
+ @Test
+ public void testMarkers(Template template) {
+ init(template);
+ selenium.isElementPresent(mainForm + ":passedMarker");
+ selenium.type(inputText, "fatal");
+ clickAjaxCommandAndWait(submit);
+ selenium.isElementPresent(mainForm + ":fatalMarker");
+ selenium.type(inputText, "error");
+ clickAjaxCommandAndWait(submit);
+ selenium.isElementPresent(mainForm + ":errorMarker");
+ selenium.type(inputText, "warn");
+ clickAjaxCommandAndWait(submit);
+ selenium.isElementPresent(mainForm + ":warnMarker");
+ selenium.type(inputText, "info");
+ clickAjaxCommandAndWait(submit);
+ selenium.isElementPresent(mainForm + ":infoMarker");
+ }
+
+
+ @Override
+ public String getTestUrl() {
+ return "pages/message/message.xhtml";
+ }
+
+}