[richfaces-svn-commits] JBoss Rich Faces SVN: r11712 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/layout/autotest and 3 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Dec 10 14:05:21 EST 2008


Author: andrei_exadel
Date: 2008-12-10 14:05:21 -0500 (Wed, 10 Dec 2008)
New Revision: 11712

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/layout/autotest/autoTestHiddens.xhtml
   trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarAutoTest.xhtml
   trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
   trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
RF-5232

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	2008-12-10 18:43:52 UTC (rev 11711)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java	2008-12-10 19:05:21 UTC (rev 11712)
@@ -8,8 +8,11 @@
 
 import java.util.Date;
 
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
 import javax.faces.event.ActionEvent;
 import javax.faces.event.FacesEvent;
 import javax.faces.event.ValueChangeEvent;
@@ -19,6 +22,8 @@
 import org.richfaces.event.NodeExpandedEvent;
 import org.richfaces.event.NodeSelectedEvent;
 
+import sun.awt.datatransfer.DataTransferer.IndexOrderComparator;
+
 /**
  * Bean for auto test
  * 
@@ -42,6 +47,8 @@
     public static final String NODE_SELECTED_LISTENER_STATUS = "NodeSelectedListener";
 
     public static final String NODE_EXPANDED_LISTENER_STATUS = "NodeExpandedListener";
+    
+    public static final String CONVERTER_ID = "autoTestConverter";
 
     public static final String VALIDATOR_ID = "autoTestValidator";
 
@@ -71,7 +78,51 @@
 
     private String validatorId = VALIDATOR_DEFAULT_ID;
     
-    public void actionListener(ActionEvent event) {
+    private Object value;
+   
+    private boolean converterSet;
+    
+    public class AutoTestConverter implements Converter {
+    	
+    	public static final String AS_OBJECT_STRING = "AUTO_TEST_CONVERTER_AS_OBJECT";
+
+    	/* (non-Javadoc)
+    	 * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
+    	 */
+    	public Object getAsObject(FacesContext context, UIComponent component,
+    			String v) {
+    		 value = AS_OBJECT_STRING;
+    		 return v; 
+    	}
+
+    	/* (non-Javadoc)
+    	 * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
+    	 */
+    	public String getAsString(FacesContext context, UIComponent component,
+    			Object value) {
+    		return null;
+    	}
+
+    };
+    
+    AutoTestConverter converter = new AutoTestConverter();
+
+   
+    /**
+	 * @return the value
+	 */
+	public Object getValue() {
+		return value;
+	}
+
+	/**
+	 * @param value the value to set
+	 */
+	public void setValue(Object value) {
+		this.value = value;
+	}
+
+	public void actionListener(ActionEvent event) {
         setStatus(getStatus() + ACTION_LISTENER_STATUS);
     }
     
@@ -91,6 +142,13 @@
     public void processExpansion(NodeExpandedEvent nodeExpandedEvent) {
         setStatus(getStatus() + NODE_EXPANDED_LISTENER_STATUS);
     }
+    
+    public void validate(FacesContext context, UIComponent component, Object o) {
+    	if (VALIDATOR_ID.equals(this.validatorId)) {
+    		AutoTestValidator validator = new AutoTestValidator();
+    		validator.validate(context, component, o);
+    	}
+    }
 
     public String load() {
         status = null;
@@ -99,6 +157,7 @@
 
     public String reset() {
         status = null;
+        value = null;
         return null;
     }
 
@@ -340,5 +399,29 @@
 		return VALIDATOR_MESSAGE;
 	}
 
+	/**
+	 * @return the converter
+	 */
+	public Converter getConverter() {
+		if (converterSet) {
+			return converter;
+		}
+		return null;
+	}
 
+	/**
+	 * @return the converterSet
+	 */
+	public boolean isConverterSet() {
+		return converterSet;
+	}
+
+	/**
+	 * @param converterSet the converterSet to set
+	 */
+	public void setConverterSet(boolean converterSet) {
+		this.converterSet = converterSet;
+	}
+
+
 }

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	2008-12-10 18:43:52 UTC (rev 11711)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml	2008-12-10 19:05:21 UTC (rev 11712)
@@ -55,6 +55,12 @@
 					</td>
 				</tr>
 				<tr>
+					<td>Converter:</td>
+					<td>
+						<h:selectBooleanCheckbox id="_auto_converter" value="#{autoTestBean.converterSet}"></h:selectBooleanCheckbox>
+					</td>
+				</tr>
+				<tr>
 					<td colspan="2"><h:commandButton id="_auto_load" actionListener="#{templateBean.reset}" action="#{autoTestBean.load}" value="Load"></h:commandButton> </td>
 				</tr>
 			</table>

Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestHiddens.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestHiddens.xhtml	2008-12-10 18:43:52 UTC (rev 11711)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestHiddens.xhtml	2008-12-10 19:05:21 UTC (rev 11712)
@@ -9,6 +9,7 @@
 			<h:outputText id="_auto_status" style="display: none;" value="#{autoTestBean.status}"></h:outputText>
 		</a4j:outputPanel>
 		<h:outputText  id="_auto_time" style="display: none;" value="#{autoTestBean.text}"></h:outputText>
+		<h:outputText  id="_auto_value" style="display: none;" value="#{autoTestBean.value}"></h:outputText>
 		<h:commandButton id="_auto_simple_submit" value="Simple submit" immediate="#{autoTestBean.immediate}" style="display: none;" />
 		<a4j:commandButton id="_auto_ajax_submit" value="Ajax submit" reRender="componentId" immediate="#{autoTestBean.immediate}" style="display: none;" />
 		<a4j:commandButton id="_auto_ajax_reset" value="Ajax reset" ajaxSingle="true" style="display: none;" action="#{autoTestBean.reset}" />

Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarAutoTest.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarAutoTest.xhtml	2008-12-10 18:43:52 UTC (rev 11711)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarAutoTest.xhtml	2008-12-10 19:05:21 UTC (rev 11712)
@@ -17,10 +17,11 @@
 							   rendered="#{autoTestBean.rendered}"
 							   oncomplete="#{autoTestBean.oncomplete}"
 							   validatorMessage="#{autoTestBean.validatorMessage}"
+							   validator="#{autoTestBean.validate}"
+							   converter="#{autoTestBean.converter}"
 							   mode="ajax"
 							   popup="false"
 							   >
-				<f:validator validatorId="#{autoTestBean.validatorId}" />			  
 				<f:param name="parameter1" value="value1" />
 			</rich:calendar>
 	</ui:define>

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	2008-12-10 18:43:52 UTC (rev 11711)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java	2008-12-10 19:05:21 UTC (rev 11712)
@@ -29,6 +29,8 @@
     private static final String INPUT_ID = "_auto_input";
 
     public static final String STATUS_ID = "_auto_status";
+    
+    public static final String VALUE_ID = "_auto_value";
 
     private static final String TIME_ID = "_auto_time";
     
@@ -404,10 +406,22 @@
         }
     }
     
+    public void testConverterAttribute() {
+    	setupControl(TestSetupEntry.converter, true);
+    	clickLoad();
+    	
+    	changeValue();
+    	
+    	clickSubmit();
+    	String value = getComponentValue();
+    	if (!AutoTestBean.AutoTestConverter.AS_OBJECT_STRING.equals(value)) {
+    		Assert.fail("Converter attribute does not work: getAsObject method failed of converter was not triggered. Expected component value: ["+AutoTestBean.AutoTestConverter.AS_OBJECT_STRING+"]. But was: ["+value+"]");
+    	}
+    }
+    
     public void testValidatorAndValidatorMessageAttributes() {
     	setInternalValidation(true);
     	clickLoad();
-    	renderPage(base.getTemplate(), null);
     	
     	changeValue();
     	clickSubmit();
@@ -419,7 +433,6 @@
     	
     	setInternalValidation(false);
     	clickLoad();
-    	renderPage(base.getTemplate(), null);
     	
     	changeValue();
     	clickSubmit();
@@ -490,6 +503,10 @@
     private String getStatus() {
         return base.getTextById(base.getParentId() + AUTOTEST_FORM_ID + STATUS_ID);
     }
+    
+    private String getComponentValue() {
+        return base.getTextById(base.getParentId() + AUTOTEST_FORM_ID + VALUE_ID);
+    }
 
     public static class TestSetupEntry {
 
@@ -523,6 +540,8 @@
         public static final TestSetupEntry bypassUpdate = new TestSetupEntry("bypassUpdate", Boolean.class, Boolean.FALSE);
 
         public static final TestSetupEntry limitToList = new TestSetupEntry("limitToList", Boolean.class, Boolean.FALSE);
+        
+        public static final TestSetupEntry converter = new TestSetupEntry("converter", Boolean.class, Boolean.FALSE);
 
         public static final List<TestSetupEntry> list = new ArrayList<TestSetupEntry>();
         static {
@@ -534,7 +553,7 @@
             list.add(bypassUpdate);
             list.add(limitToList);
             list.add(oncomplete);
-
+            list.add(converter);
         }
 
     }

Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java	2008-12-10 18:43:52 UTC (rev 11711)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java	2008-12-10 19:05:21 UTC (rev 11712)
@@ -268,6 +268,13 @@
          }
     }
     
+    @Test
+    public void testConverterAttribute(Template template) {
+    	AutoTester tester = getAutoTester(this);
+    	tester.renderPage(template, RESET_METHOD);
+    	calendarId = tester.getClientId(AutoTester.COMPONENT_ID, template);
+    	tester.testConverterAttribute();
+    }
     
     @Test
     public void testValidatorAndValidatorMessageAttributes(Template template) {




More information about the richfaces-svn-commits mailing list