[richfaces-svn-commits] JBoss Rich Faces SVN: r2801 - in trunk/ui/scrollableDataTable/src: main/java/org/richfaces/renderkit/html and 8 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Sep 6 14:16:01 EDT 2007


Author: maksimkaszynski
Date: 2007-09-06 14:16:01 -0400 (Thu, 06 Sep 2007)
New Revision: 2801

Added:
   trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/GridScrollSettings.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/AbstractScrollableDataTableTestCase.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/html/MockColumns.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/MultiColumnSortListenerTest.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/SingleColumnSortListenerTest.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ColumnWalkerTest.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/GridScrollSettingsTest.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableOptionsTest.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableScrollDataTest.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/SortIconRendererTest.java
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/utils/
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/utils/TemplateLoaderTest.java
Removed:
   trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnIterator.java
   trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ContextualColumnVisitor.java
   trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/response/
   trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/html/AbstractScrollableDataTableTestCase.java
Modified:
   trunk/ui/scrollableDataTable/src/main/config/component/scrollable-data-table.xml
   trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
   trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java
   trunk/ui/scrollableDataTable/src/main/java/org/richfaces/utils/TemplateLoader.java
Log:
added some unit tests for scrollable data table

Modified: trunk/ui/scrollableDataTable/src/main/config/component/scrollable-data-table.xml
===================================================================
--- trunk/ui/scrollableDataTable/src/main/config/component/scrollable-data-table.xml	2007-09-06 18:14:06 UTC (rev 2800)
+++ trunk/ui/scrollableDataTable/src/main/config/component/scrollable-data-table.xml	2007-09-06 18:16:01 UTC (rev 2801)
@@ -22,7 +22,7 @@
    		</description>
 		<test>
 			<classname>org.richfaces.component.html.HtmlScrollableDataTableComponentTest</classname>
-			<superclassname>org.richfaces.component.html.AbstractScrollableDataTableTestCase</superclassname>
+			<superclassname>org.richfaces.component.AbstractScrollableDataTableTestCase</superclassname>
 		</test>
 
 		<renderer generate="true" override="true">
@@ -35,10 +35,10 @@
 			<superclass>
 				org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
 			</superclass>
-			<!--test>
+			<test>
 				<classname>org.richfaces.taglib.ScrollableDataTableTagTest</classname>
 				<superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
-			</test-->
+			</test>
 		</tag>
 		
 		<property>

Deleted: trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnIterator.java
===================================================================
--- trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnIterator.java	2007-09-06 18:14:06 UTC (rev 2800)
+++ trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnIterator.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -1,81 +0,0 @@
-/**
- * 
- */
-package org.richfaces.renderkit.html;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.richfaces.component.Column;
-import org.richfaces.component.UIScrollableDataTable;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ColumnIterator implements Iterator {
-
-	
-	public static ColumnIterator frozen(UIScrollableDataTable grid, ScrollableDataTableRendererState state) {
-		return new ColumnIterator(0, ScrollableDataTableUtils.getFrozenColumnsCount(grid), grid, state) {
-			public Object next() {
-				this.state.setFrozenPart(true);
-				return super.next();
-			}
-		};
-	}
-	
-	public static ColumnIterator normal(UIScrollableDataTable grid, ScrollableDataTableRendererState state) {
-		return new ColumnIterator(ScrollableDataTableUtils.getFrozenColumnsCount(grid), grid.getChildCount(), grid, state) {
-			public Object next() {
-				this.state.setFrozenPart(false);
-				return super.next();
-			}
-		};
-	}
-	
-	public static ColumnIterator all(UIScrollableDataTable grid, ScrollableDataTableRendererState state) {
-		return new ColumnIterator(0, grid.getChildCount(), grid, state);
-	}
-	
-	ScrollableDataTableRendererState state;
-	private int index = 0;
-	private int start;
-	private int end;
-	private List kids;
-	
-	private ColumnIterator(int start, int end, UIScrollableDataTable grid, ScrollableDataTableRendererState state) {
-		this.start = start; 
-		this.end = end;
-		this.state = state;
-		this.kids = grid.getChildren();
-		rewind();
-	}
-	
-	public boolean hasNext() {
-		return index < end;
-	}
-	
-	public Object next() {
-		state.setCellIndex(index);
-		Object o = kids.get(index);
-
-		index++;
-		
-		return o;
-	}
-	
-	public Column nextColumn() {
-		return (Column) next();
-	}
-	
-	public void remove() {
-		throw new UnsupportedOperationException("remove");
-	}
-	
-	public void rewind() {
-		index = start;
-		state.setCellIndex(index);
-	}
-
-}

Modified: trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
===================================================================
--- trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java	2007-09-06 18:14:06 UTC (rev 2800)
+++ trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -32,12 +32,6 @@
 			return 0;
 		}
 
-		if (visitor instanceof ContextualColumnVisitor) {
-			ContextualColumnVisitor contextualColumnVisitor = 
-				(ContextualColumnVisitor) visitor;
-
-			contextualColumnVisitor.setUp(context, state);
-		}
 		try {
 			
 			if(component instanceof UIScrollableDataTable){
@@ -54,12 +48,6 @@
 			}
 
 		} finally {
-			if (visitor instanceof ContextualColumnVisitor) {
-				ContextualColumnVisitor contextualColumnVisitor = 
-					(ContextualColumnVisitor) visitor;
-
-				contextualColumnVisitor.tearDown(context, state);
-			}
 		}
 		
 

Deleted: trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ContextualColumnVisitor.java
===================================================================
--- trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ContextualColumnVisitor.java	2007-09-06 18:14:06 UTC (rev 2800)
+++ trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ContextualColumnVisitor.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -1,17 +0,0 @@
-/**
- * 
- */
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface ContextualColumnVisitor extends ColumnVisitor {
-	public void setUp(FacesContext context, ScrollableDataTableRendererState state) throws IOException;
-	public void tearDown(FacesContext context, ScrollableDataTableRendererState state) throws IOException;
-}

Added: trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/GridScrollSettings.java
===================================================================
--- trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/GridScrollSettings.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/GridScrollSettings.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,52 @@
+/**
+ * 
+ */
+package org.richfaces.renderkit.html;
+
+/**
+ * @author Anton Belevich
+ * Class for storing response options  
+ */
+public class GridScrollSettings {
+	
+	private int index;
+	
+	private int startRow;
+	
+	private int count;
+
+	
+	
+	public GridScrollSettings(int index, int startRow, int count) {
+		
+		this.index = index;
+		
+		this.startRow = startRow;
+		
+		this.count = count;
+	}
+
+	public int getCount() {
+		return count;
+	}
+
+	public void setCount(int count) {
+		this.count = count;
+	}
+
+	public int getIndex() {
+		return index;
+	}
+
+	public void setIndex(int index) {
+		this.index = index;
+	}
+
+	public int getStartRow() {
+		return startRow;
+	}
+
+	public void setStartRow(int startRow) {
+		this.startRow = startRow;
+	}
+}

Modified: trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java
===================================================================
--- trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java	2007-09-06 18:14:06 UTC (rev 2800)
+++ trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableRendererState.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -6,7 +6,6 @@
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Map;
 
 import javax.faces.FacesException;
 import javax.faces.component.NamingContainer;
@@ -14,7 +13,6 @@
 import javax.faces.context.ResponseWriter;
 
 import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
 import org.richfaces.component.UIScrollableDataTable;
 
 /**

Modified: trunk/ui/scrollableDataTable/src/main/java/org/richfaces/utils/TemplateLoader.java
===================================================================
--- trunk/ui/scrollableDataTable/src/main/java/org/richfaces/utils/TemplateLoader.java	2007-09-06 18:14:06 UTC (rev 2800)
+++ trunk/ui/scrollableDataTable/src/main/java/org/richfaces/utils/TemplateLoader.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -3,6 +3,8 @@
  */
 package org.richfaces.utils;
 
+import javax.faces.FacesException;
+
 import org.ajax4jsf.renderkit.RendererBase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -21,10 +23,10 @@
 			template = (RendererBase)Class.forName(className).newInstance();
 		} catch (ClassNotFoundException e) {
 			log.error("class not found: " + className );
-			throw new RuntimeException(e);
+			throw new FacesException(e);
 		} catch (Exception e) {
 			log.error("exception in loading class : " + className);
-			throw new RuntimeException(e);
+			throw new FacesException(e);
 		}
 		return template;
 	}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/AbstractScrollableDataTableTestCase.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/AbstractScrollableDataTableTestCase.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/AbstractScrollableDataTableTestCase.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,210 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.component;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.html.MockColumns;
+import org.richfaces.event.ScrollableGridViewEvent;
+import org.richfaces.event.scroll.ScrollEvent;
+import org.richfaces.event.sort.MultiColumnSortListener;
+import org.richfaces.event.sort.SingleColumnSortListener;
+import org.richfaces.event.sort.SortEvent;
+import org.richfaces.event.sort.SortListener;
+import org.richfaces.model.DataModelCache;
+import org.richfaces.model.SortOrder;
+import org.richfaces.model.internal.ComponentSortableDataModel;
+import org.richfaces.model.selection.Selection;
+import org.richfaces.model.selection.SimpleSelection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class AbstractScrollableDataTableTestCase extends AbstractAjax4JsfTestCase {
+
+
+	private UIScrollableDataTable table;
+	/**
+	 * @param name
+	 */
+	public AbstractScrollableDataTableTestCase(String name) {
+		super(name);
+		
+	}
+
+	public void setUp() throws Exception {
+		// TODO Auto-generated method stub
+		super.setUp();
+		table = (UIScrollableDataTable) application.createComponent(UIScrollableDataTable.COMPONENT_TYPE);
+		facesContext.getViewRoot().getChildren().add(table);
+		table.setId("zzz");
+		
+		for(int i = 0; i < 10; i++) {
+			UIComponent column = MockColumns.newColumn("zzz" + i);
+			UIOutput output = new UIOutput();
+			output.setId("h" + i);
+			column.getFacets().put("header", output);
+			table.getChildren().add(column);
+		}
+		
+	}
+	
+	protected SortOrder createTestData_sortOrder() {
+		return new SortOrder();
+	}
+
+	protected Selection createTestData_selection() {
+		return new SimpleSelection();
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+	 */
+	public void tearDown() throws Exception {
+		table = null;
+		super.tearDown();
+	}
+	
+	private class SortListener1 implements SortListener {
+		private boolean triggered = false;
+		public void processSort(SortEvent e) {
+			assertNotNull(e);
+			triggered = true;
+		}
+	}
+	
+	public void testBroadCast() {
+		ScrollableGridViewEvent event = new ScrollEvent(table, 20, 30);
+		event.setAttribute("attr", "value0");
+		table.broadcast(event);
+		assertEquals("value0", table.getAttributes().get("attr"));
+		
+		AjaxEvent ajaxEvent = new AjaxEvent(table);
+		String id = AjaxRendererUtils.getAbsoluteId(table);
+		table.broadcast(ajaxEvent);
+		assertTrue(ajaxContext.getAjaxAreasToRender().contains(id));
+		
+		SortListener1 sortListener = new SortListener1();
+		table.setSortListener(sortListener);
+		table.broadcast(new SortEvent(table, 0, 20, 30));
+		assertTrue(sortListener.triggered);
+		
+	}
+	
+	
+	public void testFixedChildren() {
+		Iterator iterator = table.fixedChildren();
+		assertTrue(iterator.hasNext());
+		int i = 0;
+		while(iterator.hasNext()) {
+			UIComponent kid = (UIComponent) iterator.next();
+			assertEquals("h" + i, kid.getId());
+			i++;
+		}
+	}
+	
+	public void testSortListener() {
+		table.setSortMode(UIScrollableDataTable.SORT_MULTI);
+		assertSame(MultiColumnSortListener.INSTANCE, table.getSortListener());
+		
+		table.setSortMode(UIScrollableDataTable.SORT_SINGLE);
+		assertSame(SingleColumnSortListener.INSTANCE, table.getSortListener());
+		
+		SortListener1 sortListener1 = new SortListener1();
+		
+		table.setSortListener(sortListener1);
+		
+		assertSame(sortListener1, table.getSortListener());
+		
+	}
+	
+	public void testProcessSortingChange() {
+		SortListener1 sortListener1 = new SortListener1();
+		
+		table.setSortListener(sortListener1);
+		
+		SortEvent sortEvent = new SortEvent(table, 0, 20, 30);
+		
+		table.processSortingChange(sortEvent);
+		
+		assertTrue(sortListener1.triggered);
+		
+		assertTrue(facesContext.getRenderResponse());
+		
+		assertEquals(30, table.getFirst());
+		
+	}
+	
+	public void testProcessScrolling() {
+		ScrollableGridViewEvent event = new ScrollEvent(table, 20, 440);
+		table.processScrolling(event);
+
+		assertTrue(facesContext.getRenderResponse());
+		assertEquals(440, table.getFirst());
+		
+	}
+	
+	public void testCreateDataModel() {
+		
+		
+		
+		
+		List l = Collections.singletonList("aaaa");
+		table.setValue(l);
+		ExtendedDataModel model = table.createDataModel();
+		
+		assertTrue(model instanceof DataModelCache);
+		
+		assertEquals(1, model.getRowCount());
+		//assertTrue(model instanceof ComponentSortableDataModel);
+		
+		//table.isCacheable()
+		
+		table.setValue(null);
+		model = table.createDataModel();
+		
+		assertTrue(model instanceof DataModelCache);
+		
+		assertEquals(0, model.getRowCount());
+		
+		
+	}
+	
+	
+	public void testGetResponseData() {
+		List data = new ArrayList();
+		table.setResponseData(data);
+		assertSame(data, table.getResponseData());
+	}
+	
+}

Deleted: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/html/AbstractScrollableDataTableTestCase.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/html/AbstractScrollableDataTableTestCase.java	2007-09-06 18:14:06 UTC (rev 2800)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/html/AbstractScrollableDataTableTestCase.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -1,51 +0,0 @@
-/**
- * License Agreement.
- *
- *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007  Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- */
-
-package org.richfaces.component.html;
-
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.model.SortOrder;
-import org.richfaces.model.selection.Selection;
-import org.richfaces.model.selection.SimpleSelection;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class AbstractScrollableDataTableTestCase extends AbstractAjax4JsfTestCase {
-
-	/**
-	 * @param name
-	 */
-	public AbstractScrollableDataTableTestCase(String name) {
-		super(name);
-		
-	}
-
-	
-	protected SortOrder createTestData_sortOrder() {
-		return new SortOrder();
-	}
-
-	protected Selection createTestData_selection() {
-		return new SimpleSelection();
-	}
-}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/html/MockColumns.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/html/MockColumns.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/component/html/MockColumns.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,77 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.component.html;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.component.Column;
+
+/**
+ * @author Maksim Kaszynski
+ * 
+ */
+public class MockColumns extends UIComponentBase implements Column {
+
+	private MockColumns(){
+		
+	}
+	
+	private String sortExpression;
+	private boolean sortable;
+	private boolean breakbefore;
+
+	public String getSortExpression() {
+		return sortExpression;
+	}
+
+	public void setSortExpression(String sortExpression) {
+		this.sortExpression = sortExpression;
+	}
+
+	public boolean isSortable() {
+		return sortable;
+	}
+
+	public void setSortable(boolean sortable) {
+		this.sortable = sortable;
+	}
+
+	public boolean isBreakBefore() {
+		return breakbefore;
+	}
+
+	public void setBreakBefore(boolean breakbefore) {
+		this.breakbefore = breakbefore;
+	}
+
+	public String getFamily() {
+		return UIColumn.COMPONENT_FAMILY;
+	}
+
+	public static UIComponent newColumn(String id) {
+		MockColumns column = new MockColumns();
+		column.setId(id);
+		return column;
+	}
+}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/MultiColumnSortListenerTest.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/MultiColumnSortListenerTest.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/MultiColumnSortListenerTest.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,140 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.event.sort;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIScrollableDataTable;
+import org.richfaces.component.html.MockColumns;
+import org.richfaces.model.SortField;
+import org.richfaces.model.SortOrder;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class MultiColumnSortListenerTest extends AbstractAjax4JsfTestCase {
+
+	/**
+	 * @param name
+	 */
+	public MultiColumnSortListenerTest(String name) {
+		super(name);
+	}
+
+	private SortListener listener;
+	private UIScrollableDataTable table;
+	
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+	 */
+	public void setUp() throws Exception {
+		super.setUp();
+		listener = MultiColumnSortListener.INSTANCE;
+		
+		table = (UIScrollableDataTable) 
+			application.createComponent(UIScrollableDataTable.COMPONENT_TYPE);
+		
+		facesContext.getViewRoot().getChildren().add(table);
+		
+			
+		table.getChildren().add(MockColumns.newColumn("col1"));
+		table.getChildren().add(MockColumns.newColumn("col2"));
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+	 */
+	public void tearDown() throws Exception {
+		super.tearDown();
+		table = null;
+		listener = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.event.sort.SingleColumnSortListener#processSort(org.richfaces.event.sort.SortEvent)}.
+	 */
+	public final void testProcessSort() {
+		SortEvent event = new SortEvent(table, 0, 0, 0);
+		
+		listener.processSort(event);
+		
+		SortOrder sortOrder = table.getSortOrder();
+		
+		assertNotNull(sortOrder);
+		
+		SortField[] fields = sortOrder.getFields();
+		
+		assertNotNull(fields);
+		assertEquals(1, fields.length);
+		
+		SortField field = fields[0];
+		
+		assertEquals("col1", field.getName());
+		assertEquals(Boolean.TRUE, field.getAscending());
+		assertEquals(0, field.getIndex());
+		
+		listener.processSort(event);
+		
+		sortOrder = table.getSortOrder();
+		
+		assertNotNull(sortOrder);
+		
+		fields = sortOrder.getFields();
+		
+		assertNotNull(fields);
+		assertEquals(1, fields.length);
+		
+		field = fields[0];
+		
+		assertEquals("col1", field.getName());
+		assertEquals(Boolean.FALSE, field.getAscending());
+		assertEquals(0, field.getIndex());
+		
+		event = new SortEvent(table, 1, 0, 0);
+		
+		listener.processSort(event);
+		
+		sortOrder = table.getSortOrder();
+		
+		assertNotNull(sortOrder);
+		
+		fields = sortOrder.getFields();
+		
+		assertNotNull(fields);
+		assertEquals(2, fields.length);
+		
+		field = fields[0];
+		
+		assertEquals("col1", field.getName());
+		assertEquals(Boolean.FALSE, field.getAscending());
+		assertEquals(0, field.getIndex());
+		
+		field = fields[1];
+		
+		assertEquals("col2", field.getName());
+		assertEquals(Boolean.TRUE, field.getAscending());
+		assertEquals(1, field.getIndex());
+	}
+
+}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/SingleColumnSortListenerTest.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/SingleColumnSortListenerTest.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/event/sort/SingleColumnSortListenerTest.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,132 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.event.sort;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIScrollableDataTable;
+import org.richfaces.component.html.MockColumns;
+import org.richfaces.model.SortField;
+import org.richfaces.model.SortOrder;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SingleColumnSortListenerTest extends AbstractAjax4JsfTestCase {
+
+	
+	private SortListener listener;
+	private UIScrollableDataTable table;
+	
+	public SingleColumnSortListenerTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+	 */
+	public void setUp() throws Exception {
+		super.setUp();
+		listener = SingleColumnSortListener.INSTANCE;
+		
+		table = (UIScrollableDataTable) 
+			application.createComponent(UIScrollableDataTable.COMPONENT_TYPE);
+		
+		facesContext.getViewRoot().getChildren().add(table);
+		
+			
+		table.getChildren().add(MockColumns.newColumn("col1"));
+		table.getChildren().add(MockColumns.newColumn("col2"));
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+	 */
+	public void tearDown() throws Exception {
+		super.tearDown();
+		table = null;
+		listener = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.event.sort.SingleColumnSortListener#processSort(org.richfaces.event.sort.SortEvent)}.
+	 */
+	public final void testProcessSort() {
+		SortEvent event = new SortEvent(table, 0, 0, 0);
+		
+		listener.processSort(event);
+		
+		SortOrder sortOrder = table.getSortOrder();
+		
+		assertNotNull(sortOrder);
+		
+		SortField[] fields = sortOrder.getFields();
+		
+		assertNotNull(fields);
+		assertEquals(1, fields.length);
+		
+		SortField field = fields[0];
+		
+		assertEquals("col1", field.getName());
+		assertEquals(Boolean.TRUE, field.getAscending());
+		assertEquals(0, field.getIndex());
+		
+		listener.processSort(event);
+		
+		sortOrder = table.getSortOrder();
+		
+		assertNotNull(sortOrder);
+		
+		fields = sortOrder.getFields();
+		
+		assertNotNull(fields);
+		assertEquals(1, fields.length);
+		
+		field = fields[0];
+		
+		assertEquals("col1", field.getName());
+		assertEquals(Boolean.FALSE, field.getAscending());
+		assertEquals(0, field.getIndex());
+		
+		event = new SortEvent(table, 1, 0, 0);
+		
+		listener.processSort(event);
+		
+		sortOrder = table.getSortOrder();
+		
+		assertNotNull(sortOrder);
+		
+		fields = sortOrder.getFields();
+		
+		assertNotNull(fields);
+		assertEquals(1, fields.length);
+		
+		field = fields[0];
+		
+		assertEquals("col2", field.getName());
+		assertEquals(Boolean.TRUE, field.getAscending());
+		assertEquals(1, field.getIndex());
+		
+	}
+
+}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ColumnWalkerTest.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ColumnWalkerTest.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ColumnWalkerTest.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,99 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIScrollableDataTable;
+import org.richfaces.component.html.MockColumns;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ColumnWalkerTest extends AbstractAjax4JsfTestCase {
+
+	private	UIScrollableDataTable table;
+	private ScrollableDataTableRendererState state;
+	/**
+	 * @param name
+	 */
+	public ColumnWalkerTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+	 */
+	public void setUp() throws Exception {
+		super.setUp();
+		table = 
+			(UIScrollableDataTable) application.createComponent(UIScrollableDataTable.COMPONENT_TYPE);
+		state = ScrollableDataTableRendererState.createState(facesContext, table);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+	 */
+	public void tearDown() throws Exception {
+		ScrollableDataTableRendererState.restoreState(facesContext);
+		state = null;
+		table = null;
+		super.tearDown();
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ColumnWalker#iterateOverColumns(javax.faces.context.FacesContext, javax.faces.component.UIComponent, org.richfaces.renderkit.html.ColumnVisitor, javax.faces.context.ResponseWriter, org.richfaces.renderkit.html.ScrollableDataTableRendererState)}.
+	 */
+	public final void testIterateOverColumns() {
+		
+		for(int i = 0; i < 10; i++ ) {
+			table.getChildren().add(MockColumns.newColumn("col" + i));
+		}
+		
+		ColumnVisitor visitor = new ColumnVisitor() {
+			
+			public int visit(FacesContext context, UIComponent column,
+					ResponseWriter writer,
+					ScrollableDataTableRendererState state) throws IOException {
+				
+				assertEquals("col" + state.getCellIndex(), column.getId());
+				
+				return 0;
+			}
+		};
+		
+		
+		try {
+			ColumnWalker.iterateOverColumns(facesContext, table, visitor, writer, state);
+		} catch (IOException e) {
+			fail(e.getMessage());
+		}
+		
+	}
+
+}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/GridScrollSettingsTest.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/GridScrollSettingsTest.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/GridScrollSettingsTest.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,109 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class GridScrollSettingsTest extends TestCase {
+
+	final int count = 100;
+	final int index = 12;
+	final int startRow = 30;
+	
+	private GridScrollSettings data;
+	
+	/**
+	 * @param name
+	 */
+	public GridScrollSettingsTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		data = new GridScrollSettings(index, startRow, count);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		data = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#getCount()}.
+	 */
+	public final void testGetCount() {
+		assertEquals(count, data.getCount());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#setCount(int)}.
+	 */
+	public final void testSetCount() {
+		int i = 22;
+		data.setCount(i);
+		assertEquals(i, data.getCount());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#getIndex()}.
+	 */
+	public final void testGetIndex() {
+		assertEquals(index, data.getIndex());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#setIndex(int)}.
+	 */
+	public final void testSetIndex() {
+		int i = 11112;
+		data.setIndex(i);
+		assertEquals(i, data.getIndex());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#getStartRow()}.
+	 */
+	public final void testGetStartRow() {
+		assertEquals(startRow, data.getStartRow());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#setStartRow(int)}.
+	 */
+	public final void testSetStartRow() {
+		int i = 23;
+		data.setStartRow(i);
+		assertEquals(i, data.getStartRow());
+	}
+
+}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableOptionsTest.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableOptionsTest.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableOptionsTest.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,120 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.util.Map;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIOutput;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIScrollableDataTable;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ScrollableDataTableOptionsTest extends AbstractAjax4JsfTestCase {
+
+	
+	private ScrollableDataTableOptions options;
+	private UIScrollableDataTable table;
+	private ScrollableDataTableRendererState state;
+	
+	
+	public ScrollableDataTableOptionsTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	public void setUp() throws Exception {
+		super.setUp();
+		table = (UIScrollableDataTable) application.createComponent(UIScrollableDataTable.COMPONENT_TYPE);
+		table.setId("table");
+		state = ScrollableDataTableRendererState.createState(facesContext, table);
+		
+		
+		
+		facesContext.getViewRoot().getChildren().add(table);
+
+		UIOutput output = new UIOutput();
+		output.setId("splash");
+		table.getFacets().put("splash", output);
+		
+		for(int i = 0; i < 10; i++) {
+			table.getChildren().add(new UIColumn());
+		}
+
+		options = new ScrollableDataTableOptions(table);
+
+		
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	public void tearDown() throws Exception {
+		ScrollableDataTableRendererState.restoreState(facesContext);
+		
+		super.tearDown();
+		options = null;
+		state = null;
+		table = null;
+		
+	}
+
+	
+	
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableOptions#ScrollableDataTableOptions(org.richfaces.component.UIScrollableDataTable)}.
+	 */
+	public final void testScrollableDataTableOptions() {
+		
+		Map map = options.getMap();
+		assertNotNull(map);
+		assertEquals(new Integer(10), map.get("columnsCount"));
+		assertEquals(new Integer(table.getRows()), map.get("rowsCount"));
+		assertEquals(table.getBaseClientId(facesContext), map.get("client_id"));
+		assertEquals("table:splash", map.get("splash_id"));
+		assertTrue(map.containsKey("onSortAjaxUpdate"));
+		
+		
+		//options.getMap().containsKey(key);
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableOptions#onSortAjaxUpdate(javax.faces.context.FacesContext, org.richfaces.component.UIScrollableDataTable)}.
+	 */
+	public final void testOnSortAjaxUpdate() {
+		String ajaxUpdate = options.onSortAjaxUpdate(facesContext, table);
+		assertNotNull(ajaxUpdate);
+		assertTrue(ajaxUpdate.contains("table:sortColumn"));
+		assertTrue(ajaxUpdate.contains("table:sortOrder"));
+		assertTrue(ajaxUpdate.contains("table:sortIndex"));
+		assertTrue(ajaxUpdate.endsWith("return false;"));
+		
+	}
+
+}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableScrollDataTest.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableScrollDataTest.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/ScrollableDataTableScrollDataTest.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,109 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ScrollableDataTableScrollDataTest extends TestCase {
+
+	final int count = 100;
+	final int index = 12;
+	final int startRow = 30;
+	
+	private ScrollableDataTableScrollData data;
+	
+	/**
+	 * @param name
+	 */
+	public ScrollableDataTableScrollDataTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		data = new ScrollableDataTableScrollData(index, startRow, count);
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		data = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#getCount()}.
+	 */
+	public final void testGetCount() {
+		assertEquals(count, data.getCount());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#setCount(int)}.
+	 */
+	public final void testSetCount() {
+		int i = 22;
+		data.setCount(i);
+		assertEquals(i, data.getCount());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#getIndex()}.
+	 */
+	public final void testGetIndex() {
+		assertEquals(index, data.getIndex());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#setIndex(int)}.
+	 */
+	public final void testSetIndex() {
+		int i = 11112;
+		data.setIndex(i);
+		assertEquals(i, data.getIndex());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#getStartRow()}.
+	 */
+	public final void testGetStartRow() {
+		assertEquals(startRow, data.getStartRow());
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.ScrollableDataTableScrollData#setStartRow(int)}.
+	 */
+	public final void testSetStartRow() {
+		int i = 23;
+		data.setStartRow(i);
+		assertEquals(i, data.getStartRow());
+	}
+
+}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/SortIconRendererTest.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/SortIconRendererTest.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/renderkit/html/SortIconRendererTest.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,187 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Maksim Kaszynski
+ * 
+ */
+public class SortIconRendererTest extends AbstractAjax4JsfTestCase {
+
+	private SortIconRenderer renderer;
+	
+	/**
+	 * @param name
+	 */
+	public SortIconRendererTest(String name) {
+		super(name);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+	 */
+	public void setUp() throws Exception {
+		super.setUp();
+		renderer = new SortIconRenderer() {
+
+			protected Class getComponentClass() {
+				return UIComponent.class;
+			}
+		};
+		
+		
+		
+		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+	 */
+	public void tearDown() throws Exception {
+		super.tearDown();
+		renderer = null;
+	}
+
+	/**
+	 * Test method for
+	 * {@link org.richfaces.renderkit.html.SortIconRenderer#renderAscIcon(javax.faces.context.FacesContext, javax.faces.component.UIComponent)}.
+	 */
+	public final void testRenderAscIcon() {
+		UIComponent component = new UIColumn();
+		try {
+			setupResponseWriter();
+			renderer.renderAscIcon(facesContext, component);
+			HtmlPage page = processResponseWriter();
+			
+			Iterator elementIterator = page.getAllHtmlChildElements();
+			
+			HtmlElement div = null;
+			
+			while(elementIterator.hasNext()) {
+				HtmlElement node = (HtmlElement) elementIterator.next();
+				if (node.getNodeName().equalsIgnoreCase("div")) {
+					div = node;
+				}
+			}
+			
+			assertNotNull(div);
+			
+			String className = div.getAttributeValue("class");
+			
+			assertNotNull(className);
+			
+			assertEquals("dr-sdt-sort-asc", className);
+			
+		} catch (Exception e) {
+			fail(e.getMessage());
+		}
+		
+	}
+
+	
+	public void testRenderFacet() {
+		UIComponent component = new UIColumn();
+		UIOutput output = new UIOutput() {
+			public String getRendererType() {
+				return null;
+			}
+			public void encodeEnd(FacesContext context) throws IOException {
+				ResponseWriter writer = context.getResponseWriter();
+				writer.startElement("div", this);
+				writer.writeAttribute("id", "test_div_0", "id");
+				writer.endElement("div");
+			}
+		};
+		
+		component.getFacets().put("ascIcon", output);
+		
+		
+		try {
+			setupResponseWriter();
+			renderer.renderAscIcon(facesContext, component);
+			HtmlPage htmlPage = processResponseWriter();
+			
+			HtmlElement element = htmlPage.getHtmlElementById("test_div_0");
+			assertNotNull(element);
+			assertEquals("div", element.getNodeName());
+			
+		} catch (Exception e) {
+			fail(e.getMessage());
+		}
+		
+		
+	}
+	
+	/**
+	 * Test method for
+	 * {@link org.richfaces.renderkit.html.SortIconRenderer#renderDescIcon(javax.faces.context.FacesContext, javax.faces.component.UIComponent)}.
+	 */
+	public final void testRenderDescIcon() {
+		UIComponent component = new UIColumn();
+		try {
+			setupResponseWriter();
+			renderer.renderDescIcon(facesContext, component);
+			HtmlPage page = processResponseWriter();
+			
+			Iterator elementIterator = page.getAllHtmlChildElements();
+			
+			HtmlElement div = null;
+			
+			while(elementIterator.hasNext()) {
+				HtmlElement node = (HtmlElement) elementIterator.next();
+				if (node.getNodeName().equalsIgnoreCase("div")) {
+					div = node;
+				}
+			}
+			
+			assertNotNull(div);
+			
+			String className = div.getAttributeValue("class");
+			
+			assertNotNull(className);
+			
+			assertEquals("dr-sdt-sort-desc", className);
+			
+		} catch (Exception e) {
+			fail(e.getMessage());
+		}
+	}
+
+}

Added: trunk/ui/scrollableDataTable/src/test/java/org/richfaces/utils/TemplateLoaderTest.java
===================================================================
--- trunk/ui/scrollableDataTable/src/test/java/org/richfaces/utils/TemplateLoaderTest.java	                        (rev 0)
+++ trunk/ui/scrollableDataTable/src/test/java/org/richfaces/utils/TemplateLoaderTest.java	2007-09-06 18:16:01 UTC (rev 2801)
@@ -0,0 +1,94 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.utils;
+
+import javax.faces.FacesException;
+
+import org.ajax4jsf.renderkit.RendererBase;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ * 
+ */
+public class TemplateLoaderTest extends TestCase {
+
+	/**
+	 * @param name
+	 */
+	public TemplateLoaderTest(String name) {
+		super(name);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+
+	/**
+	 * Test method for
+	 * {@link org.richfaces.utils.TemplateLoader#loadTemplate(java.lang.String)}.
+	 */
+	public final void testLoadTemplate() {
+		boolean exception = false;
+		try {
+			TemplateLoader.loadTemplate("xxx.xxx.xx.TestClass");
+		} catch (FacesException e) {
+			exception = true;
+			assertTrue(e.getCause() instanceof ClassNotFoundException);
+		}
+
+		assertTrue(exception);
+
+		exception = false;
+
+		try {
+			TemplateLoader.loadTemplate(RendererBase.class.getName());
+		} catch (FacesException e) {
+			exception = true;
+			assertTrue(e.getCause() instanceof InstantiationException);
+		}
+
+		assertTrue(exception);
+
+		RendererBase template = TemplateLoader
+				.loadTemplate("org.richfaces.renderkit.html.ScrollableDataTableFooterCellRenderer");
+
+		assertNotNull(template);
+
+	}
+
+}




More information about the richfaces-svn-commits mailing list