Author: abelevich
Date: 2007-06-27 10:50:52 -0400 (Wed, 27 Jun 2007)
New Revision: 1341
Added:
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridColumnComponentTest.java
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java
Log:
Junit for grid and columns
Added:
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridColumnComponentTest.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridColumnComponentTest.java
(rev 0)
+++
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridColumnComponentTest.java 2007-06-27
14:50:52 UTC (rev 1341)
@@ -0,0 +1,161 @@
+/**
+ * GENERATED FILE - DO NOT EDIT
+ *
+ */
+
+package org.richfaces.component.html;
+
+import java.lang.String ;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase ;
+
+import com.gargoylesoftware.htmlunit.Page;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.component.UIViewRoot;
+
+import org.ajax4jsf.tests.MockValueBinding;
+
+//import org.richfaces.component.html.HtmlScrollableGridColumn;
+
+public class HtmlScrollableGridColumnComponentTest extends
org.ajax4jsf.tests.AbstractAjax4JsfTestCase {
+
+// public static final String COMPONENT_TYPE =
"org.richfaces.component.ScrollableGridColumn";
+
+
+ private boolean _breakBeforeSet = false;
+ private boolean _sortableSet = false;
+
+ private HtmlScrollableGridColumn component;
+ private UIForm form;
+// private FacesContext context;
+
+ /**
+ * Constructor to init default renderers
+ */
+ public HtmlScrollableGridColumnComponentTest (String name){
+ super(name);
+ }
+
+ /*
+ * setup the tets
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ component = new HtmlScrollableGridColumn();
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ component.setId("component");
+ component.setWidth("width" );
+ component.setHeaderClass("headerClass" );
+ component.setFooterClass("footerClass" );
+ component.setStyleClass("styleClass" );
+ component.setBreakBefore(true );
+ component.setStyle("style" );
+ component.setSortable(true );
+
+ form.getChildren().add(component);
+
+ }
+
+ /*
+ * setup the tets
+ */
+ public void tearDown() throws Exception{
+ super.tearDown();
+ component = null;
+ form = null;
+ }
+
+ public void testComponent() throws Exception {
+
+/*
+ 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);
+
+ }
+/*
+ public void testDefaultValues(){
+
+ }
+*/
+ 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() {
+ HtmlScrollableGridColumn component = new HtmlScrollableGridColumn();
+
+ component.setValueBinding("width", new MockValueBinding("width",
java.lang.String.class));
+ assertEquals("width", component.getWidth());
+ component.setWidth("width_width" );
+ assertEquals("width_width", component.getWidth());
+ component.setValueBinding("headerClass", new
MockValueBinding("headerClass", java.lang.String.class));
+ assertEquals("headerClass", component.getHeaderClass());
+ component.setHeaderClass("headerClass_headerClass" );
+ assertEquals("headerClass_headerClass", component.getHeaderClass());
+ component.setValueBinding("footerClass", new
MockValueBinding("footerClass", java.lang.String.class));
+ assertEquals("footerClass", component.getFooterClass());
+ component.setFooterClass("footerClass_footerClass" );
+ assertEquals("footerClass_footerClass", component.getFooterClass());
+ component.setValueBinding("styleClass", new
MockValueBinding("styleClass", java.lang.String.class));
+ assertEquals("styleClass", component.getStyleClass());
+ component.setStyleClass("styleClass_styleClass" );
+ assertEquals("styleClass_styleClass", component.getStyleClass());
+ component.setValueBinding("breakBefore", new MockValueBinding(new
Boolean(true), java.lang.Boolean.class));
+ assertEquals(true, component.isBreakBefore());
+ component.setBreakBefore(false );
+ assertEquals(false, component.isBreakBefore());
+ component.setValueBinding("style", new MockValueBinding("style",
java.lang.String.class));
+ assertEquals("style", component.getStyle());
+ component.setStyle("style_style" );
+ assertEquals("style_style", component.getStyle());
+ component.setValueBinding("sortable", new MockValueBinding(new
Boolean(true), java.lang.Boolean.class));
+ assertEquals(true, component.isSortable());
+ component.setSortable(false );
+ assertEquals(false, component.isSortable());
+
+
+ }
+
+ private void testRestoreState(Object state){
+ HtmlScrollableGridColumn restoredComponent = new HtmlScrollableGridColumn();
+ restoredComponent.restoreState(facesContext, state);
+
+ assertEquals(component.getWidth(), restoredComponent.getWidth());
+ assertEquals(component.getHeaderClass(), restoredComponent.getHeaderClass());
+ assertEquals(component.getFooterClass(), restoredComponent.getFooterClass());
+ assertEquals(component.getStyleClass(), restoredComponent.getStyleClass());
+ assertEquals(component.isBreakBefore(), restoredComponent.isBreakBefore());
+ assertEquals(component.getStyle(), restoredComponent.getStyle());
+ assertEquals(component.isSortable(), restoredComponent.isSortable());
+
+ }
+
+ private void assertEquals(double d1, double d2) {
+ assertEquals(d1, d2, 0);
+ }
+
+ private void assertEquals(float d1, float d2) {
+ assertEquals(d1, d2, 0);
+ }
+}
Added:
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java
===================================================================
---
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java
(rev 0)
+++
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java 2007-06-27
14:50:52 UTC (rev 1341)
@@ -0,0 +1,290 @@
+/**
+ * GENERATED FILE - DO NOT EDIT
+ *
+ */
+
+package org.richfaces.component.html;
+
+import java.lang.String ;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase ;
+import org.richfaces.model.SortOrder ;
+import java.lang.Object ;
+import org.richfaces.model.selection.Selection ;
+import org.richfaces.model.selection.SimpleSelection;
+
+import com.gargoylesoftware.htmlunit.Page;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.component.UIViewRoot;
+
+import org.ajax4jsf.tests.MockValueBinding;
+
+//import org.richfaces.component.html.HtmlScrollableGrid;
+
+public class HtmlScrollableGridComponentTest extends
org.ajax4jsf.tests.AbstractAjax4JsfTestCase {
+
+// public static final String COMPONENT_TYPE =
"org.richfaces.component.ScrollableGrid";
+
+
+ private boolean _bypassUpdatesSet = false;
+ private boolean _limitToListSet = false;
+ private boolean _timeoutSet = false;
+ private
boolean _ajaxSingleSet = false;
+ private boolean _frozenColCountSet = false;
+ private boolean _requestDelaySet = false;
+ private boolean _ignoreDupResponsesSet = false;
+
+ private HtmlScrollableGrid component;
+ private UIForm form;
+// private FacesContext context;
+
+ /**
+ * Constructor to init default renderers
+ */
+ public HtmlScrollableGridComponentTest (String name){
+ super(name);
+ }
+
+ /*
+ * setup the tets
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ component = new HtmlScrollableGrid();
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ component.setId("component");
+ component.setOnselectionchange("onselectionchange" );
+ component.setWidth("width" );
+ component.setFocus("focus" );
+ component.setBypassUpdates(true );
+ component.setLimitToList(true );
+ component.setTimeout(20 );
+ component.setColumnClasses("columnClasses" );
+// component.setSelection("selection" );
+ component.setHeaderClass("headerClass" );
+ component.setRowClasses("rowClasses" );
+ component.setOncomplete("oncomplete" );
+// component.setSortOrder("sortOrder" );
+ component.setFooterClass("footerClass" );
+ component.setReRender("reRender" );
+ component.setActiveClass("activeClass" );
+ component.setStyleClass("styleClass" );
+ component.setHeight("height" );
+ component.setCaptionClass("captionClass" );
+ component.setAjaxSingle(true );
+ component.setSelectedClass("selectedClass" );
+ component.setFrozenColCount(20 );
+ component.setStatus("status" );
+ component.setRequestDelay(20 );
+ component.setEventsQueue("eventsQueue" );
+ component.setData("data" );
+ component.setIgnoreDupResponses(true );
+
+ form.getChildren().add(component);
+
+ }
+
+ /*
+ * setup the tets
+ */
+ public void tearDown() throws Exception{
+ super.tearDown();
+ component = null;
+ form = null;
+ }
+
+ public void testComponent() throws Exception {
+ assertEquals("org.richfaces.renderkit.html.ScrollableGridRenderer",
component.getRendererType());
+
+/*
+ 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);
+
+ }
+/*
+ public void testDefaultValues(){
+
+ }
+*/
+ 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() {
+ HtmlScrollableGrid component = new HtmlScrollableGrid();
+
+ component.setValueBinding("onselectionchange", new
MockValueBinding("onselectionchange", java.lang.String.class));
+ assertEquals("onselectionchange", component.getOnselectionchange());
+ component.setOnselectionchange("onselectionchange_onselectionchange" );
+ assertEquals("onselectionchange_onselectionchange",
component.getOnselectionchange());
+ component.setValueBinding("width", new
MockValueBinding("width", java.lang.String.class));
+ assertEquals("width", component.getWidth());
+ component.setWidth("width_width" );
+ assertEquals("width_width", component.getWidth());
+ component.setValueBinding("focus", new
MockValueBinding("focus", java.lang.String.class));
+ assertEquals("focus", component.getFocus());
+ component.setFocus("focus_focus" );
+ assertEquals("focus_focus", component.getFocus());
+ component.setValueBinding("bypassUpdates", new MockValueBinding(new
Boolean(true), java.lang.Boolean.class));
+ assertEquals(true, component.isBypassUpdates());
+ component.setBypassUpdates(false );
+ assertEquals(false, component.isBypassUpdates());
+ component.setValueBinding("limitToList", new MockValueBinding(new
Boolean(true), java.lang.Boolean.class));
+ assertEquals(true, component.isLimitToList());
+ component.setLimitToList(false );
+ assertEquals(false, component.isLimitToList());
+ component.setValueBinding("timeout", new MockValueBinding(new
Integer(20), java.lang.Integer.class));
+ assertEquals(20, component.getTimeout());
+ component.setTimeout(15 );
+ assertEquals(15, component.getTimeout());
+ component.setValueBinding("columnClasses", new
MockValueBinding("columnClasses", java.lang.String.class));
+ assertEquals("columnClasses", component.getColumnClasses());
+ component.setColumnClasses("columnClasses_columnClasses" );
+ assertEquals("columnClasses_columnClasses", component.getColumnClasses());
+ component.setValueBinding("selection", new
MockValueBinding("selection", org.richfaces.model.selection.Selection.class));
+
+ SimpleSelection selection = new SimpleSelection();
+ selection.addKey("key");
+ component.setSelection(selection);
+ assertEquals(selection, component.getSelection());
+
+ component.setValueBinding("headerClass", new
MockValueBinding("headerClass", java.lang.String.class));
+ assertEquals("headerClass", component.getHeaderClass());
+ component.setHeaderClass("headerClass_headerClass" );
+ assertEquals("headerClass_headerClass", component.getHeaderClass());
+ component.setValueBinding("rowClasses", new
MockValueBinding("rowClasses", java.lang.String.class));
+ assertEquals("rowClasses", component.getRowClasses());
+ component.setRowClasses("rowClasses_rowClasses" );
+ assertEquals("rowClasses_rowClasses", component.getRowClasses());
+ component.setValueBinding("oncomplete", new
MockValueBinding("oncomplete", java.lang.String.class));
+ assertEquals("oncomplete", component.getOncomplete());
+ component.setOncomplete("oncomplete_oncomplete" );
+ assertEquals("oncomplete_oncomplete", component.getOncomplete());
+ component.setValueBinding("sortOrder", new
MockValueBinding("sortOrder", org.richfaces.model.SortOrder.class));
+ SortOrder sortOrder = new SortOrder();
+ sortOrder.setSortColumn(2);
+ sortOrder.setAscending(true);
+ component.setSortOrder(sortOrder);
+ assertEquals(sortOrder, component.getSortOrder());
+ component.setValueBinding("footerClass", new
MockValueBinding("footerClass", java.lang.String.class));
+ assertEquals("footerClass", component.getFooterClass());
+ component.setFooterClass("footerClass_footerClass" );
+ assertEquals("footerClass_footerClass", component.getFooterClass());
+ component.setValueBinding("reRender", new
MockValueBinding("reRender", java.lang.Object.class));
+ assertEquals("reRender", component.getReRender());
+ component.setReRender("reRender_reRender" );
+ assertEquals("reRender_reRender", component.getReRender());
+ component.setValueBinding("activeClass", new
MockValueBinding("activeClass", java.lang.String.class));
+ assertEquals("activeClass", component.getActiveClass());
+ component.setActiveClass("activeClass_activeClass" );
+ assertEquals("activeClass_activeClass", component.getActiveClass());
+ component.setValueBinding("styleClass", new
MockValueBinding("styleClass", java.lang.String.class));
+ assertEquals("styleClass", component.getStyleClass());
+ component.setStyleClass("styleClass_styleClass" );
+ assertEquals("styleClass_styleClass", component.getStyleClass());
+ component.setValueBinding("height", new
MockValueBinding("height", java.lang.String.class));
+ assertEquals("height", component.getHeight());
+ component.setHeight("height_height" );
+ assertEquals("height_height", component.getHeight());
+ component.setValueBinding("captionClass", new
MockValueBinding("captionClass", java.lang.String.class));
+ assertEquals("captionClass", component.getCaptionClass());
+ component.setCaptionClass("captionClass_captionClass" );
+ assertEquals("captionClass_captionClass", component.getCaptionClass());
+ component.setValueBinding("ajaxSingle", new MockValueBinding(new
Boolean(true), java.lang.Boolean.class));
+ assertEquals(true, component.isAjaxSingle());
+ component.setAjaxSingle(false );
+ assertEquals(false, component.isAjaxSingle());
+ component.setValueBinding("selectedClass", new
MockValueBinding("selectedClass", java.lang.String.class));
+ assertEquals("selectedClass", component.getSelectedClass());
+ component.setSelectedClass("selectedClass_selectedClass" );
+ assertEquals("selectedClass_selectedClass", component.getSelectedClass());
+ component.setValueBinding("frozenColCount", new MockValueBinding(new
Integer(20), java.lang.Integer.class));
+ assertEquals(20, component.getFrozenColCount());
+ component.setFrozenColCount(15 );
+ assertEquals(15, component.getFrozenColCount());
+ component.setValueBinding("status", new
MockValueBinding("status", java.lang.String.class));
+ assertEquals("status", component.getStatus());
+ component.setStatus("status_status" );
+ assertEquals("status_status", component.getStatus());
+ component.setValueBinding("requestDelay", new MockValueBinding(new
Integer(20), java.lang.Integer.class));
+ assertEquals(20, component.getRequestDelay());
+ component.setRequestDelay(15 );
+ assertEquals(15, component.getRequestDelay());
+ component.setValueBinding("eventsQueue", new
MockValueBinding("eventsQueue", java.lang.String.class));
+ assertEquals("eventsQueue", component.getEventsQueue());
+ component.setEventsQueue("eventsQueue_eventsQueue" );
+ assertEquals("eventsQueue_eventsQueue", component.getEventsQueue());
+ component.setValueBinding("data", new MockValueBinding("data",
java.lang.Object.class));
+ assertEquals("data", component.getData());
+ component.setData("data_data" );
+ assertEquals("data_data", component.getData());
+ component.setValueBinding("ignoreDupResponses", new MockValueBinding(new
Boolean(true), java.lang.Boolean.class));
+ assertEquals(true, component.isIgnoreDupResponses());
+ component.setIgnoreDupResponses(false );
+ assertEquals(false, component.isIgnoreDupResponses());
+
+
+ }
+
+ private void testRestoreState(Object state){
+ HtmlScrollableGrid restoredComponent = new HtmlScrollableGrid();
+ restoredComponent.restoreState(facesContext, state);
+
+ assertEquals(component.getOnselectionchange(),
restoredComponent.getOnselectionchange());
+ assertEquals(component.getWidth(), restoredComponent.getWidth());
+ assertEquals(component.getFocus(), restoredComponent.getFocus());
+ assertEquals(component.isBypassUpdates(), restoredComponent.isBypassUpdates());
+ assertEquals(component.isLimitToList(), restoredComponent.isLimitToList());
+ assertEquals(component.getTimeout(), restoredComponent.getTimeout());
+ assertEquals(component.getColumnClasses(), restoredComponent.getColumnClasses());
+ assertEquals(component.getSelection(), restoredComponent.getSelection());
+ assertEquals(component.getHeaderClass(), restoredComponent.getHeaderClass());
+ assertEquals(component.getRowClasses(), restoredComponent.getRowClasses());
+ assertEquals(component.getOncomplete(), restoredComponent.getOncomplete());
+ assertEquals(component.getSortOrder(), restoredComponent.getSortOrder());
+ assertEquals(component.getFooterClass(), restoredComponent.getFooterClass());
+ assertEquals(component.getReRender(), restoredComponent.getReRender());
+ assertEquals(component.getActiveClass(), restoredComponent.getActiveClass());
+ assertEquals(component.getStyleClass(), restoredComponent.getStyleClass());
+ assertEquals(component.getHeight(), restoredComponent.getHeight());
+ assertEquals(component.getCaptionClass(), restoredComponent.getCaptionClass());
+ assertEquals(component.isAjaxSingle(), restoredComponent.isAjaxSingle());
+ assertEquals(component.getSelectedClass(), restoredComponent.getSelectedClass());
+ assertEquals(component.getFrozenColCount(), restoredComponent.getFrozenColCount());
+ assertEquals(component.getStatus(), restoredComponent.getStatus());
+ assertEquals(component.getRequestDelay(), restoredComponent.getRequestDelay());
+ assertEquals(component.getEventsQueue(), restoredComponent.getEventsQueue());
+ assertEquals(component.getData(), restoredComponent.getData());
+ assertEquals(component.isIgnoreDupResponses(),
restoredComponent.isIgnoreDupResponses());
+
+ }
+
+ private void assertEquals(double d1, double d2) {
+ assertEquals(d1, d2, 0);
+ }
+
+ private void assertEquals(float d1, float d2) {
+ assertEquals(d1, d2, 0);
+ }
+}