Author: nbelaevski
Date: 2007-04-30 16:58:02 -0400 (Mon, 30 Apr 2007)
New Revision: 142
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm
Log:
componenttest.vm template updated for JSF 1.2
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm
===================================================================
---
trunk/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm 2007-04-30
20:08:17 UTC (rev 141)
+++
trunk/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm 2007-04-30
20:58:02 UTC (rev 142)
@@ -17,6 +17,9 @@
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.component.UIViewRoot;
+
+import org.ajax4jsf.tests.MockValueBinding;
+
//import ${component.classname};
#if(${generator.key})
@@ -88,13 +91,16 @@
}
public void testComponent() throws Exception {
-
+ #if(${component.renderer})
+ assertEquals("${component.renderer.name}", component.getRendererType());
+ #end
+/*
HtmlPage renderedView = renderView();
assertNotNull(renderedView);
System.out.println(renderedView.getWebResponse().getContentAsString());
HtmlElement element = renderedView.getHtmlElementById(form.getId() + ":" +
component.getId());
assertNotNull(element);
-
+*/
// values[0] = component.saveState(facesContext);
}
@@ -106,16 +112,31 @@
public void testContext(){
Object state = component.saveState(facesContext);
-
+/*
UIViewRoot root = facesContext.getViewRoot();
root.processDecodes(facesContext);
root.processValidators(facesContext);
root.processUpdates(facesContext);
root.processApplication(facesContext);
-
+*/
testRestoreState(state);
}
+ public void testGetters() {
+ ${component.simpleClassName} component = new ${component.simpleClassName}();
+
+#foreach( $prop in $component.properties )
+ #if(!$prop.exist && !$prop.elonly &&
!$prop.classname.startsWith("javax.faces."))
+ component.setValueBinding("${prop.name}", new
MockValueBinding($testDataGenerator.getTestVeData(${prop}),
${testDataGenerator.getTestVeClass(${prop})}.class));
+ assertEquals($testDataGenerator.getTestData(${prop}), component.${prop.getterName}());
+ component.${prop.setterName}($testDataGenerator.getTestData1(${prop}) );
+ assertEquals($testDataGenerator.getTestData1(${prop}),
component.${prop.getterName}());
+ #end
+#end
+
+
+ }
+
private void testRestoreState(Object state){
${component.simpleClassName} restoredComponent = new ${component.simpleClassName}();
restoredComponent.restoreState(facesContext, state);
@@ -128,4 +149,11 @@
}
+ private void assertEquals(double d1, double d2) {
+ assertEquals(d1, d2, 0);
+ }
+
+ private void assertEquals(float d1, float d2) {
+ assertEquals(d1, d2, 0);
+ }
}
\ No newline at end of file
Show replies by date