JBoss Rich Faces SVN: r6738 - trunk/ui/listShuttle/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-12 05:51:57 -0400 (Wed, 12 Mar 2008)
New Revision: 6738
Modified:
trunk/ui/listShuttle/src/main/config/component/listShuttle.xml
Log:
added more sophisticated tests
Modified: trunk/ui/listShuttle/src/main/config/component/listShuttle.xml
===================================================================
--- trunk/ui/listShuttle/src/main/config/component/listShuttle.xml 2008-03-12 09:51:45 UTC (rev 6737)
+++ trunk/ui/listShuttle/src/main/config/component/listShuttle.xml 2008-03-12 09:51:57 UTC (rev 6738)
@@ -220,7 +220,7 @@
Defines target list caption representation text
</description>
</property>
- <property>
+ <property el="false">
<name>var</name>
<classname>java.lang.String</classname>
<description>
@@ -257,12 +257,12 @@
<classname>java.lang.Object</classname>
<description>RowKey is a representation of an identifier for a specific data row</description>
</property>
- <property>
+ <property el="false">
<name>rowKeyVar</name>
<classname>java.lang.String</classname>
<description>The attribute provides access to a row key in a Request scope</description>
</property>
- <property>
+ <property el="false">
<name>stateVar</name>
<classname>java.lang.String</classname>
<description>
16 years, 10 months
JBoss Rich Faces SVN: r6737 - trunk/ui/message/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-12 05:51:45 -0400 (Wed, 12 Mar 2008)
New Revision: 6737
Modified:
trunk/ui/message/src/main/config/component/message.xml
Log:
added more sophisticated tests
Modified: trunk/ui/message/src/main/config/component/message.xml
===================================================================
--- trunk/ui/message/src/main/config/component/message.xml 2008-03-12 09:51:32 UTC (rev 6736)
+++ trunk/ui/message/src/main/config/component/message.xml 2008-03-12 09:51:45 UTC (rev 6737)
@@ -32,7 +32,7 @@
<test>
<classname>org.richfaces.taglib.RichMessageTagTest</classname>
- <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname>
</test>
</tag>
@@ -289,7 +289,7 @@
<test>
<classname>org.richfaces.taglib.RichMessagesTagTest</classname>
- <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname>
</test>
</tag>
16 years, 10 months
JBoss Rich Faces SVN: r6736 - trunk/ui/calendar/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-12 05:51:32 -0400 (Wed, 12 Mar 2008)
New Revision: 6736
Modified:
trunk/ui/calendar/src/main/config/component/calendar.xml
Log:
added more sophisticated tests
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2008-03-12 09:51:20 UTC (rev 6735)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2008-03-12 09:51:32 UTC (rev 6736)
@@ -38,7 +38,7 @@
org.richfaces.component.html.HtmlCalendarTest
</classname>
<superclassname>
- org.ajax4jsf.tests.AbstractAjax4JsfTestCase
+ org.ajax4jsf.tests.AbstractJspTestCase
</superclassname>
</test>
</tag>
16 years, 10 months
JBoss Rich Faces SVN: r6735 - trunk/ui/dataTable/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-12 05:51:20 -0400 (Wed, 12 Mar 2008)
New Revision: 6735
Modified:
trunk/ui/dataTable/src/main/config/component/dataList.xml
Log:
added more sophisticated tests
Modified: trunk/ui/dataTable/src/main/config/component/dataList.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataList.xml 2008-03-12 09:51:05 UTC (rev 6734)
+++ trunk/ui/dataTable/src/main/config/component/dataList.xml 2008-03-12 09:51:20 UTC (rev 6735)
@@ -57,14 +57,14 @@
<classname>java.lang.Object</classname>
<description>The current value for this component</description>
</property>
- <property>
+ <property el="false">
<name>stateVar</name>
<classname>java.lang.String</classname>
<description>
The attribute provides access to a component state on the client side
</description>
</property>
- <property>
+ <property el="false">
<name>rowKeyVar</name>
<classname>java.lang.String</classname>
<description>The attribute provides access to a row key in a Request scope</description>
@@ -107,6 +107,7 @@
<superclass>
org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
+ <test/>
</tag>
<!--
<taghandler>
@@ -133,7 +134,7 @@
<classname>java.lang.Object</classname>
<description>The current value for this component</description>
</property>
- <property>
+ <property el="false">
<name>stateVar</name>
<classname>java.lang.String</classname>
<description>
@@ -182,6 +183,7 @@
<superclass>
org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
</superclass>
+ <test/>
</tag>
<!--
<taghandler>
@@ -212,7 +214,7 @@
<classname>java.lang.Object</classname>
<description>The current value for this component</description>
</property>
- <property>
+ <property el="false">
<name>stateVar</name>
<classname>java.lang.String</classname>
<description>The attribute provides access to a component state on the client side</description>
16 years, 10 months
JBoss Rich Faces SVN: r6734 - in trunk/cdk/generator/src/main: java/org/ajax4jsf/builder/generator and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-12 05:51:05 -0400 (Wed, 12 Mar 2008)
New Revision: 6734
Added:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TagTestClassHolder.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator2.java
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java
trunk/cdk/generator/src/main/resources/META-INF/schema/entities/ui_command_attributes.ent
trunk/cdk/generator/src/main/resources/META-INF/schema/entities/ui_data_attributes.ent
trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm
Log:
added more sophisticated tests
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java 2008-03-12 09:50:18 UTC (rev 6733)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java 2008-03-12 09:51:05 UTC (rev 6734)
@@ -311,7 +311,7 @@
digester.addSetNext(path, "setTag");
path = "components/component/tag/test";
- digester.addObjectCreate(path, TestClassHolder.class);
+ digester.addObjectCreate(path, TagTestClassHolder.class);
digester.addBeanPropertySetter(path + "/?");
digester.addSetProperties(path);
digester.addSetNext(path, "setTest");
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TagTestClassHolder.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TagTestClassHolder.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TagTestClassHolder.java 2008-03-12 09:51:05 UTC (rev 6734)
@@ -0,0 +1,19 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.config;
+
+/**
+ * @author Administrator
+ *
+ */
+public class TagTestClassHolder extends TestClassHolder {
+
+ /**
+ *
+ */
+ public TagTestClassHolder() {
+ setSuperclassname("org.ajax4jsf.tests.AbstractJspTestCase");
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java 2008-03-12 09:50:18 UTC (rev 6733)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java 2008-03-12 09:51:05 UTC (rev 6734)
@@ -30,6 +30,8 @@
System.out.println("Preparing to generate test for tag class... ");
VelocityContext context = new VelocityContext();
context.put("generator",this);
+ context.put("testDataGenerator", new TestDataGenerator2(getClassLoader(), getLog()));
+
Template template = getTemplate();
// Put common properties
for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
@@ -47,7 +49,7 @@
context.put("tag", component.getTag());
context.put("package", component.getTag().getPackageName());
Set<String> importClasses = new HashSet<String>();
- for (Iterator it = component.getProperties().iterator(); it
+ for (Iterator<PropertyBean> it = component.getProperties().iterator(); it
.hasNext();) {
PropertyBean property = (PropertyBean) it.next();
// For non-primitive types, add import declaration.
@@ -88,4 +90,14 @@
return COMPONENT_FILE_TEMPLATE;
}
+ public String getSetterTestName(PropertyBean property){
+ String setterName = property.getSetterName();
+ String className = property.getSimpleClassName();
+ StringBuilder name = new StringBuilder("test");
+ name.append(Character.toUpperCase(setterName.charAt(0)));
+ name.append(setterName.substring(1));
+ name.append(Character.toUpperCase(className.charAt(0)));
+ name.append(className.substring(1));
+ return name.toString();
+ }
}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java 2008-03-12 09:50:18 UTC (rev 6733)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java 2008-03-12 09:51:05 UTC (rev 6734)
@@ -136,6 +136,8 @@
} else {
return "\"" + propertyName + "_" + propertyName + "\"";
}
+ } else if (clazz.isEnum()) {
+ return getEnumData(propertyName, (Class<Enum<?>>)clazz, number);
}
} catch(Exception e) {
@@ -145,6 +147,23 @@
return "createTestData_" + number + "_" + propertyName + "()";
}
+ private String getEnumData(String propertyName, Class<Enum<?>> clazz, int number) {
+ if (clazz.isEnum()) {
+ Enum<?>[] enumConstants = clazz.getEnumConstants();
+ if (enumConstants.length > 0) {
+ if (number >= enumConstants.length) {
+ return enumToString(enumConstants[enumConstants.length - 1]);
+ }
+ return enumToString(enumConstants[number]);
+ }
+ }
+ return "null";
+ }
+
+ private String enumToString(Enum<?> e) {
+ return e.getClass().getName() + "." + e;
+ }
+
public String getTestData(PropertyBean propertyBean) {
return getTestData(propertyBean.getName(), propertyBean.getClassname(), 0);
}
@@ -152,4 +171,13 @@
public String getTestData1(PropertyBean propertyBean) {
return getTestData(propertyBean.getName(), propertyBean.getClassname(), 1);
}
+ /**
+ * Returns true if property
+ * @param propertyBean
+ * @return
+ */
+ public boolean isNativelySupported(PropertyBean propertyBean) {
+ String classname = propertyBean.getClassname();
+ return testData.containsKey(classname) || "java.lang.String".equals(classname);
+ }
}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator2.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator2.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator2.java 2008-03-12 09:51:05 UTC (rev 6734)
@@ -0,0 +1,56 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.generator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.ajax4jsf.builder.config.PropertyBean;
+
+/**
+ * @author Administrator
+ *
+ */
+public class TestDataGenerator2 extends TestDataGenerator {
+
+
+ @SuppressWarnings("serial")
+ private static final Map<String, String> testData = new HashMap<String, String>() {
+ {
+ put(java.util.Date.class.getName(), "new Date()");
+ put(java.util.Calendar.class.getName(), "Calendar.getInstance()");
+ }
+ };
+
+ public TestDataGenerator2(ClassLoader loader, Logger logger) {
+ super(loader, logger);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public String getTestData(PropertyBean propertyBean) {
+ String classname = propertyBean.getClassname();
+ if (testData.containsKey(classname)) {
+ return testData.get(classname);
+ }
+ return super.getTestData(propertyBean);
+ }
+
+ @Override
+ public String getTestData1(PropertyBean propertyBean) {
+ String classname = propertyBean.getClassname();
+ if (testData.containsKey(classname)) {
+ return testData.get(classname);
+ }
+ return super.getTestData1(propertyBean);
+ }
+
+ @Override
+ /**
+ * Disable date types
+ */
+ public boolean isNativelySupported(PropertyBean propertyBean) {
+ return super.isNativelySupported(propertyBean) && !testData.containsKey(propertyBean.getClassname());
+ }
+}
Modified: trunk/cdk/generator/src/main/resources/META-INF/schema/entities/ui_command_attributes.ent
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/schema/entities/ui_command_attributes.ent 2008-03-12 09:50:18 UTC (rev 6733)
+++ trunk/cdk/generator/src/main/resources/META-INF/schema/entities/ui_command_attributes.ent 2008-03-12 09:51:05 UTC (rev 6734)
@@ -16,6 +16,19 @@
<returntype>java.lang.Object</returntype>
<methodargs> </methodargs>
</property>
+ <property attachedstate="true" hidden="true">
+ <name>actionExpression</name>
+ <classname>javax.el.MethodExpression</classname>
+ <description>
+ MethodExpression pointing at the application action to be invoked,
+ if this UIComponent is activated by you, during the Apply
+ Request Values or Invoke Application phase of the request
+ processing lifecycle, depending on the value of the immediate
+ property
+ </description>
+ <returntype>java.lang.Object</returntype>
+ <methodargs> </methodargs>
+ </property>
<property elonly="true" attachedstate="true">
<name>actionListener</name>
<classname>javax.faces.el.MethodBinding</classname>
Modified: trunk/cdk/generator/src/main/resources/META-INF/schema/entities/ui_data_attributes.ent
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/schema/entities/ui_data_attributes.ent 2008-03-12 09:50:18 UTC (rev 6733)
+++ trunk/cdk/generator/src/main/resources/META-INF/schema/entities/ui_data_attributes.ent 2008-03-12 09:51:05 UTC (rev 6734)
@@ -14,7 +14,7 @@
rows in the table
</description>
</property>
- <property>
+ <property el="false">
<name>var</name>
<classname>java.lang.String</classname>
<description>
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm 2008-03-12 09:50:18 UTC (rev 6733)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm 2008-03-12 09:51:05 UTC (rev 6734)
@@ -44,6 +44,8 @@
setActionProperty(comp, this._${prop.name});
#elseif($prop.name == "actionListener")
setActionListenerProperty(comp, this._${prop.name});
+ #elseif($prop.name == "actionExpression")
+ //Do nothing. Use 'action' instead
#elseif($prop.name == "converter")
setConverterProperty(comp, this._${prop.name});
#elseif($prop.name == "validator")
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm 2008-03-12 09:50:18 UTC (rev 6733)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm 2008-03-12 09:51:05 UTC (rev 6734)
@@ -132,8 +132,10 @@
assertEquals(${prop.name}Values[i], component.${prop.getterName}());
}
#else
+ #if ($prop.el)
component.setValueBinding("${prop.name}", new MockValueBinding($testDataGenerator.getTestVeData(${prop}), ${testDataGenerator.getTestVeClass(${prop})}.class));
assertEquals($testDataGenerator.getTestData(${prop}), component.${prop.getterName}());
+ #end
component.${prop.setterName}($testDataGenerator.getTestData1(${prop}) );
assertEquals($testDataGenerator.getTestData1(${prop}), component.${prop.getterName}());
#end
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm 2008-03-12 09:50:18 UTC (rev 6733)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm 2008-03-12 09:51:05 UTC (rev 6734)
@@ -7,11 +7,19 @@
#foreach($import in $imports)
import $import ;
#end
+import javax.faces.convert.Converter ;
+import javax.faces.context.FacesContext ;
import javax.faces.component.UIComponent;
-import javax.faces.webapp.UIComponentTag;
+import javax.faces.webapp.UIComponentELTag;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.event.ValueChangeListener;
+import javax.faces.validator.Validator;
import ${component.classname};
import javax.faces.application.Application;
-import javax.faces.el.ValueBinding;
+import javax.el.ValueExpression;
+import javax.el.MethodExpression;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -26,11 +34,13 @@
import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.VariableResolver;
import javax.servlet.jsp.tagext.Tag;
+import org.ajax4jsf.tests.MockMethodExpression;
import java.io.IOException;
import java.util.Enumeration;
+import java.util.List;
+import java.util.ArrayList;
+import org.ajax4jsf.tests.Condition;
-
-
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.2 $ $Date: 2007/01/03 21:05:14 $
@@ -38,6 +48,16 @@
*/
public class $tag.test.simpleClassName extends $tag.test.superclassname {
+ public static final class MyConverter implements Converter {
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+ return null;
+ }
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+ return null;
+ }
+ }
private $tag.simpleClassName tag;
@@ -51,8 +71,10 @@
public void setUp() throws Exception {
super.setUp();
+ application.addConverter(this.getClass().getName(), MyConverter.class.getName());
tag = new ${tag.simpleClassName}();
- tag.setParent(new UIComponentTag(){
+ tag.setPageContext(pageContext);
+ tag.setParent(new UIComponentELTag(){
public String getComponentType() {
// TODO Auto-generated method stub
@@ -84,67 +106,289 @@
}
- public void testSetPropertiesUIComponent() {
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag && !$prop.hidden)
+ public void ${generator.getSetterTestName($prop)}() {
${component.simpleClassName} component = new ${component.simpleClassName}();
- // create binding
- Application application = null;
- ValueBinding binding = null;
+ #if($prop.name == 'actionListener')
+ final Condition condition0 = new Condition("Expecting addActionListener call");
+ final List<ActionListener> listeners = new ArrayList<ActionListener>();
+ component = new ${component.simpleClassName}() {
+ @Override
+ public void addActionListener(ActionListener listener) {
+ condition0.setTrue();
+ listeners.add(listener);
+ super.addActionListener(listener);
+ }
+ };
+
+ String expression = "#{bean.actionListener}";
+ MockMethodExpression _actionListener = new MockMethodExpression(expression, null, null);
+ tag.setActionListener(_actionListener);
+ tag.setProperties(component);
+ //Check addListener method is called
+ evaluate(condition0);
+ //Check listener was really added
+ assertFalse(listeners.isEmpty());
+ //Now try to invoke listener to see that underlying method expression is triggered
+ ActionEvent event = new ActionEvent(component);
+ for (ActionListener actionListener : listeners) {
+ try {
+ actionListener.processAction(event);
+ } catch(Exception e) {
+ //ignore any exceptions in listeners
+ }
+ }
+ List<Object[]> invocationArgs = _actionListener.getInvocationArgs();
+ assertNotNull(invocationArgs);
+ assertFalse(invocationArgs.isEmpty());
+ assertEquals(1, invocationArgs.size());
+ Object[] objects = invocationArgs.get(0);
+ assertEquals(1, objects.length);
+ assertEquals(event, objects[0]);
+
+ #elseif($prop.name == 'action')
+ final String expression = "#{bean.action}";
+ final MockMethodExpression action = new MockMethodExpression(expression, null, null);
+ final Condition conditionA = new Condition("expecting setActionExpression to be called");
+ component = new ${component.simpleClassName}(){
+ @Override
+ public void setActionExpression(MethodExpression actionExpression) {
+ assertNotNull(actionExpression);
+ assertEquals(expression, actionExpression.getExpressionString());
+ conditionA.setTrue();
+ super.setActionExpression(actionExpression);
+ }
+ };
+ tag.setAction(action);
+ tag.setProperties(component);
+ evaluate(conditionA);
+
+ #elseif($prop.name == 'valueChangeListener')
+ final Condition condition0 = new Condition("Expecting addValueChangeListener call");
+ final List<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();
+ component = new ${component.simpleClassName}() {
+ @Override
+ public void addValueChangeListener(ValueChangeListener listener) {
+ condition0.setTrue();
+ listeners.add(listener);
+ super.addValueChangeListener(listener);
+ }
+ };
+
+ String expression = "#{bean.actionListener}";
+ MockMethodExpression valueChangeListener = new MockMethodExpression(expression, null, null);
+ tag.setValueChangeListener(valueChangeListener);
+ tag.setProperties(component);
+ //Check addListener method is called
+ evaluate(condition0);
+ //Check listener was really added
+ assertFalse(listeners.isEmpty());
+ //Now try to invoke listener to see that underlying method expression is triggered
+ ValueChangeEvent event = new ValueChangeEvent(component, new Object(), new Object());
+ for (ValueChangeListener listener : listeners) {
+ try {
+ listener.processValueChange(event);
+ } catch(Exception e) {
+ //ignore any exceptions in listeners
+ }
+ }
+ List<Object[]> invocationArgs = valueChangeListener.getInvocationArgs();
+ assertNotNull(invocationArgs);
+ assertFalse(invocationArgs.isEmpty());
+ assertEquals(1, invocationArgs.size());
+ Object[] objects = invocationArgs.get(0);
+ assertEquals(1, objects.length);
+ assertEquals(event, objects[0]);
+
+ #elseif($prop.name == 'validator')
+ final Condition condition0 = new Condition(
+ "Expecting addValidator call");
+ final List<Validator> validators = new ArrayList<Validator>();
+ component = new ${component.simpleClassName}() {
+ @Override
+ public void addValidator(Validator validator) {
+ condition0.setTrue();
+ validators.add(validator);
+ super.addValidator(validator);
+ }
+ };
- #foreach( $prop in $tag.properties )
- #if($prop.el)
- application = facesContext.getApplication();
- binding = application.createValueBinding(component.getOnclick());
- component.setValueBinding("${prop.name}", binding);
- #if($prop.classname == "java.lang.String")
- component.${prop.setterName}( " __$prop.name" );
- #elseif($prop.classname == "java.lang.Boolean")
- component.${prop.setterName}( new Boolean(true) );
- #end
- #end
- //tag.${prop.setterName}("__${prop.name}");
- #end
-
+ String expression = "#{bean.validate}";
+ MockMethodExpression validator = new MockMethodExpression(
+ expression, null, null);
+ tag.setValidator(validator);
tag.setProperties(component);
+ // Check addValidator method is called
+ evaluate(condition0);
+ // Check validator was really added
+ assertFalse(validators.isEmpty());
+ // Now try to invoke validator to see that underlying method expression
+ // is triggered
+ Object value = new Object();
+
+ for (Validator validatorItem : validators) {
+ try {
+ validatorItem.validate(facesContext, component, value);
+ } catch (Exception e) {
+ //Ignore
+ }
+ }
+
+ List<Object[]> invocationArgs = validator.getInvocationArgs();
+ assertNotNull(invocationArgs);
+ assertFalse(invocationArgs.isEmpty());
+ assertEquals(1, invocationArgs.size());
+ Object[] objects = invocationArgs.get(0);
+ assertEquals(3, objects.length);
+ assertEquals(facesContext, objects[0]);
+ assertEquals(component, objects[1]);
+ assertEquals(value, objects[2]);
+
+ #elseif($prop.isInstanceof("javax.el.MethodExpression") || $prop.isInstanceof("javax.faces.el.MethodBinding"))
+ final String expression = "#{bean.${prop.name}}";
+ final MockMethodExpression _${prop.name} = new MockMethodExpression(expression, null, null);
+ final Condition conditionMB = new Condition("expecting ${prop.setterName} to be called");
+ component = new ${component.simpleClassName}(){
+ @Override
+ public void ${prop.setterName}(${prop.classname} __${prop.name}) {
+ assertNotNull(__${prop.name});
+ assertEquals(expression, __${prop.name}.getExpressionString());
+ conditionMB.setTrue();
+ super.${prop.setterName}(__${prop.name});
+ }
+ };
+ tag.${prop.setterName}(_${prop.name});
+ tag.setProperties(component);
+ evaluate(conditionMB);
+
+ #elseif($prop.isInstanceof("javax.el.ValueExpression"))
+ final ValueExpression expression = expressionFactory.createValueExpression(elContext, "#{bean.${prop.name}}", Object.class);
+ final Condition conditionVE = new Condition("expecting ${prop.setterName} to be called");
+ component = new ${component.simpleClassName}(){
+ @Override
+ public void ${prop.setterName}(ValueExpression ve) {
+ assertNotNull(ve);
+ if (ve.equals(expression)) {
+ conditionVE.setTrue();
+ }
+ super.${prop.setterName}(ve);
+ }
+ };
+ //Then test literal one
+ tag.${prop.setterName}(expression);
+ tag.setProperties(component);
+ evaluate(conditionVE);
+ #elseif($prop.isInstanceof("javax.faces.el.ValueBinding"))
+ final ValueExpression expression = expressionFactory.createValueExpression(elContext, "#{bean.${prop.name}}", Object.class);
+ final Condition conditionVB = new Condition("expecting ${prop.setterName} to be called");
+ component = new ${component.simpleClassName}(){
+ @Override
+ public void ${prop.setterName}(javax.faces.el.ValueBinding vb) {
+ assertNotNull(vb);
+ if (vb.getExpressionString().equals(expression.getExpressionString())) {
+ conditionVB.setTrue();
+ }
+ super.${prop.setterName}(vb);
+ }
+ };
+ //Then test literal one
+ tag.${prop.setterName}(expression);
+ tag.setProperties(component);
+ evaluate(conditionVB);
+ #elseif($prop.el)
+ //el=true
+ final Condition condition = new Condition("expecting setValueExpression(\"${prop.name}\") to be called");
+ component = new ${component.simpleClassName}() {
+ @Override
+ public void setValueExpression(String name, ValueExpression binding) {
+ if (name.equals("${prop.name}")) {
+ condition.setTrue();
+ }
+ super.setValueExpression(name, binding);
+ }
+ };
+ ValueExpression expression = expressionFactory.createValueExpression(elContext, "#{bean.${prop.name}}", ${prop.classname}.class);
+ tag.${prop.setterName}(expression);
+ tag.setProperties(component);
+ evaluate(condition);
+ #if($prop.name == 'converter')
+ String converterType = this.getClass().getName();
+ final Condition conditionC = new Condition("expecting call to setConverter");
+ component = new ${component.simpleClassName}(){
+ @Override
+ public void setConverter(Converter converter) {
+ assertTrue(converter instanceof MyConverter);
+ conditionC.setTrue();
+ super.setConverter(converter);
+ }
+ };
+ expression = expressionFactory.createValueExpression(elContext, converterType, String.class);
+ tag.setConverter(expression);
+ tag.setProperties(component);
+ evaluate(conditionC);
+
+ #elseif(!$prop.elonly && ${testDataGenerator.isNativelySupported($prop)})
+ //In case of literal VE
+ final Condition condition2 = new Condition("expecting ${prop.setterName} to be called");
+ final ${prop.classname} _${prop.name} = ${testDataGenerator.getTestVeData($prop)};
+ component = new ${component.simpleClassName}(){
+ @Override
+ public void ${prop.setterName}(${prop.classname} __${prop.name}) {
+ assertEquals(__${prop.name}, _${prop.name});
+ condition2.setTrue();
+ super.${prop.setterName}(__${prop.name});
+ }
+ };
+ expression = expressionFactory.createValueExpression(elContext, String.valueOf(_${prop.name}), ${prop.classname}.class);
+ tag.${prop.setterName}(expression);
+ tag.setProperties(component);
+ evaluate(condition2);
+ //Then test literal one
+ #end
+
+ #else
+ //Case of el="false"
+ final Condition condition3 = new Condition("expecting ${prop.setterName} to be called");
+ final ${prop.classname} _${prop.name} = ${testDataGenerator.getTestVeData($prop)};
+ component = new ${component.simpleClassName}(){
+ @Override
+ public void ${prop.setterName}(${prop.classname} __${prop.name}) {
+ condition3.setTrue();
+ assertEquals(__${prop.name},_${prop.name});
+ super.${prop.setterName}(__${prop.name});
+ }
+ };
+ //Then test literal one
+ tag.${prop.setterName}(String.valueOf(_${prop.name}));
+ tag.setProperties(component);
+ evaluate(condition3);
+ #end
+ }
+ #end
+#end
-/*
- #foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- #if(!$prop.el)
- if(isValueReference(this._${prop.name})){
- throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext() +" not allowed EL expression for property ${prop.name}")
- }
- #end
+
+
+
+/**
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag && !$prop.hidden)
#if($prop.name == "action")
-
- setActionProperty(component, tag._${prop.name});
+ setActionProperty(comp, this._${prop.name});
#elseif($prop.name == "actionListener")
- setActionListenerProperty(component, this._${prop.name});
+ setActionListenerProperty(comp, this._${prop.name});
#elseif($prop.name == "converter")
- setConverterProperty(component, this._${prop.name});
+ setConverterProperty(comp, this._${prop.name});
#elseif($prop.name == "validator")
- setValidatorProperty(component, this._${prop.name});
+ setValidatorProperty(comp, this._${prop.name});
#elseif($prop.name == "valueChangeListener")
- setValueChangeListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "value")
- setValueProperty(component, this._${prop.name});
- #elseif($prop.elonly || $prop.isInstanceof("javax.faces.el.ValueBinding") )
- setValueBinding(component, "${prop.name}",this._${prop.name});
- #elseif(${prop.simpleType})
- // Simple type - ${prop.simpleClassName}
- set${prop.boxingClass}Property(component, "${prop.name}",this._${prop.name});
- #elseif($prop.classname == "java.lang.Boolean" || $prop.classname == "java.lang.Integer" || $prop.classname == "java.lang.Long")
- set${prop.simpleClassName}Property(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.String")
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.Object")
- // TODO - handle object
- setStringProperty(component, "${prop.name}",this._${prop.name});
+ setValueChangeListenerProperty(comp, this._${prop.name});
#elseif( $prop.isInstanceof("javax.faces.el.MethodBinding") )
if(null != this._${prop.name}){
- if (isValueReference(this._${prop.name}))
+ if (!this._${prop.name}.isLiteralText())
{
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(this._${prop.name},
- new Class[]{${prop.methodArgsClasses}});
+ MethodBinding mb = new MethodBindingMethodExpressionAdaptor(this._${prop.name});
((${component.simpleClassName})component).${prop.setterName}(mb);
}
else
@@ -152,17 +396,68 @@
getFacesContext().getExternalContext().log("Component " + component.getClientId(getFacesContext()) + " has invalid ${prop.name} value: " + this._${prop.name});
}
}
+ #elseif($prop.isInstanceof("javax.faces.el.ValueBinding") )
+ if(null != this._${prop.name}){
+ ValueBinding vb = new ValueBindingValueExpressionAdaptor(this._${prop.name});
+ ((${component.simpleClassName})component).${prop.setterName}(vb);
+ }
+ #elseif($prop.isInstanceof("javax.el.MethodExpression") )
+ if(null != this._${prop.name}){
+ ((${component.simpleClassName})component).${prop.setterName}(this._${prop.name});
+ }
#else
- // TODO - setup properties for other cases.
- // name ${prop.name} with type $prop.classname
+ #if($prop.elonly)
+ if(null != this._${prop.name} && this._${prop.name}.isLiteralText()){
+ throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext()) +" allows only EL expressions for property ${prop.name}");
+ }
+ #end
+
+ #if ($prop.el)
+ if (this._${prop.name} != null) {
+ if (this._${prop.name}.isLiteralText()) {
+ try {
+ #if (${prop.simpleType})
+ #set ($propertyClass = ${prop.boxingClass})
+ #else
+ #set ($propertyClass = ${prop.classname})
+ #end
+
+ $propertyClass __${prop.name} = ($propertyClass) getFacesContext().
+ getApplication().
+ getExpressionFactory().
+ coerceToType(this._${prop.name}.getExpressionString(),
+ ${propertyClass}.class);
+
+ #if (${prop.simpleType})
+ comp.${prop.setterName}(__${prop.name}.${prop.classname}Value());
+ #else
+ comp.${prop.setterName}(__${prop.name});
+ #end
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+ } else {
+ component.setValueExpression("${prop.name}", this._${prop.name});
+ }
+ }
+ #else
+ #if (!${prop.simpleType})
+ if (this._${prop.name} != null) {
+ #end
+
+ comp.${prop.setterName}(this._${prop.name});
+
+ #if (!${prop.simpleType})
+ }
+ #end
+ #end
#end
- #end
- #end
+ #end
+#end
*/
- }
-
+
public void testGetRendererType(){
- assertNotNull(tag.getRendererType());
+ //assertEquals(tag.getRendererType(), $);
}
public void testGetComponentType(){
16 years, 10 months
JBoss Rich Faces SVN: r6733 - trunk/ui/tooltip/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-12 05:50:18 -0400 (Wed, 12 Mar 2008)
New Revision: 6733
Modified:
trunk/ui/tooltip/src/main/config/component/toolTip.xml
Log:
added more sophisticated tests
Modified: trunk/ui/tooltip/src/main/config/component/toolTip.xml
===================================================================
--- trunk/ui/tooltip/src/main/config/component/toolTip.xml 2008-03-12 09:50:05 UTC (rev 6732)
+++ trunk/ui/tooltip/src/main/config/component/toolTip.xml 2008-03-12 09:50:18 UTC (rev 6733)
@@ -31,7 +31,7 @@
<superclass>org.richfaces.taglib.ToolTipTagBase</superclass>
<test>
<classname>org.richfaces.taglib.HtmlToolTipTagTest</classname>
- <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname>
</test>
</tag>
<taghandler generate="true">
16 years, 10 months
JBoss Rich Faces SVN: r6732 - trunk/ui/inputnumber-spinner/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-12 05:50:05 -0400 (Wed, 12 Mar 2008)
New Revision: 6732
Modified:
trunk/ui/inputnumber-spinner/src/main/config/component/inputNumberSpinner.xml
Log:
added more sophisticated tests
Modified: trunk/ui/inputnumber-spinner/src/main/config/component/inputNumberSpinner.xml
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/config/component/inputNumberSpinner.xml 2008-03-12 07:44:56 UTC (rev 6731)
+++ trunk/ui/inputnumber-spinner/src/main/config/component/inputNumberSpinner.xml 2008-03-12 09:50:05 UTC (rev 6732)
@@ -33,7 +33,7 @@
</superclass>
<test>
<classname>org.richfaces.taglib.HtmlInputNumberSpinnerTagTest</classname>
- <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname>
</test>
</tag>
16 years, 10 months
JBoss Rich Faces SVN: r6731 - Plan/3.2.0 and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: tkuprevich
Date: 2008-03-12 03:44:56 -0400 (Wed, 12 Mar 2008)
New Revision: 6731
Modified:
trunk/test-applications/qa/Test Plan/3.2.0/TestPlan-RF-3.2.0.doc
Log:
Modified: trunk/test-applications/qa/Test Plan/3.2.0/TestPlan-RF-3.2.0.doc
===================================================================
(Binary files differ)
16 years, 10 months
JBoss Rich Faces SVN: r6730 - trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-11 22:45:45 -0400 (Tue, 11 Mar 2008)
New Revision: 6730
Modified:
trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js
Log:
http://jira.jboss.com/jira/browse/RF-2424
Modified: trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js
===================================================================
--- trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js 2008-03-12 01:55:27 UTC (rev 6729)
+++ trunk/ui/componentControl/src/main/resources/org/richfaces/renderkit/html/script/controlUtils.js 2008-03-12 02:45:45 UTC (rev 6730)
@@ -41,7 +41,12 @@
Richfaces.componentControl.performOperation = function( cevent, forAttr, operation, params, disableDefault) {
Richfaces.componentControl.eachComponent(forAttr, function(component) {
- component[operation](cevent, params());
+ var paramsValue = params;
+ if (typeof params == "function") {
+ paramsValue = params();
+ }
+
+ component[operation](cevent, paramsValue);
});
if (disableDefault) {
Event.stop(cevent);
16 years, 10 months
JBoss Rich Faces SVN: r6729 - trunk/framework/impl/src/main/javascript/ajaxjsf.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-11 21:55:27 -0400 (Tue, 11 Mar 2008)
New Revision: 6729
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
http://jira.jboss.com/jira/browse/RF-1487
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-03-12 00:07:21 UTC (rev 6728)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-03-12 01:55:27 UTC (rev 6729)
@@ -295,8 +295,8 @@
var newscripts = this.getElementsByTagName("script",node);
LOG.debug("Scripts in updated part count : " + newscripts.length);
if( newscripts.length > 0 ){
- var _this = this;
- window.setTimeout(function() {
+ var _this = this;
+ window.setTimeout(function() {
for (var i = 0; i < newscripts.length; i++){
var newscript = Sarissa.getText( newscripts[i],true ) ; // TODO - Mozilla disable innerHTML in XML page ..."";
try {
@@ -313,23 +313,17 @@
newscripts = null;
if (isLast)
{
- if(_this.onfinish){
- _this.onfinish(_this);
- _this=undefined;
- }
+ _this.doFinish();
+ _this = undefined;
}
- },50);
+ }, 50);
} else
{
if (isLast)
{
- if(this.onfinish){
- this.onfinish(this);
- }
+ this.doFinish();
}
}
-
-
},
beforeUpdatePagePart: function (id)
@@ -385,13 +379,17 @@
if (A4J.AJAX._scriptEvaluated && isLast)
{
- if(this.onfinish){
- this.onfinish(this);
- }
+ this.doFinish()
}
},
+ doFinish: function() {
+ if(this.onfinish){
+ this.onfinish(this);
+ }
+ },
+
appendNewHeadElements : function(){
// Append scripts and styles to head, if not presented in page before.
this._appendNewElements("script","src",null,null,["type","language","charset"]);
@@ -838,6 +836,7 @@
// if none of above - error ?
// A4J.AJAX.replace(form.id,A4J.AJAX.findElement(form.id,xmlDoc));
LOG.warn("No information in response about elements to replace");
+ req.doFinish();
}
// Replace client-side hidden inputs for JSF View state.
var idsSpan = req.getElementById("ajax-view-state");
16 years, 10 months