[richfaces-svn-commits] JBoss Rich Faces SVN: r1312 - in trunk/sandbox/scrollable-grid/src/test/java/org/richfaces: renderkit and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Jun 26 05:24:52 EDT 2007


Author: abelevich
Date: 2007-06-26 05:24:52 -0400 (Tue, 26 Jun 2007)
New Revision: 1312

Added:
   trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/
   trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/
   trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/JSFComponentTest.java
   trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/SelectionRendererContributorTest.java
Log:
move SelectioTest to another package

Copied: trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/JSFComponentTest.java (from rev 1270, trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/JSFComponentTest.java)
===================================================================
--- trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/JSFComponentTest.java	                        (rev 0)
+++ trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/JSFComponentTest.java	2007-06-26 09:24:52 UTC (rev 1312)
@@ -0,0 +1,31 @@
+package org.richfaces.renderkit.html;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import javax.faces.component.UIComponent;
+
+/**
+ * Unit test for simple Component.
+ */
+public class JSFComponentTest  extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public JSFComponentTest( String testName )
+    {
+        super( testName );
+    }
+
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testComponent()
+    {
+        assertTrue( true );
+    }
+}

Copied: trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/SelectionRendererContributorTest.java (from rev 1270, trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/renderkit/html/SelectionRendererContributorTest.java)
===================================================================
--- trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/SelectionRendererContributorTest.java	                        (rev 0)
+++ trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/SelectionRendererContributorTest.java	2007-06-26 09:24:52 UTC (rev 1312)
@@ -0,0 +1,197 @@
+/**
+ * 
+ */
+package org.richfaces.renderkit.html;
+
+import java.util.ArrayList;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.shale.test.mock.MockExternalContext;
+import org.richfaces.component.UIScrollableGrid;
+import org.richfaces.model.selection.ClientSelection;
+import org.richfaces.model.selection.SelectionRange;
+import org.richfaces.renderkit.html.ScrollableGridBaseRenderer;
+import org.richfaces.renderkit.html.SelectionRendererContributor;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SelectionRendererContributorTest extends AbstractAjax4JsfTestCase {
+
+	private UIScrollableGrid component;
+	private SelectionRendererContributor contributor;
+	private ScrollableGridBaseRenderer renderer;
+
+	public SelectionRendererContributorTest(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+	 */
+	public void setUp() throws Exception {
+		super.setUp();
+		component = (UIScrollableGrid) application.createComponent(UIScrollableGrid.COMPONENT_TYPE);
+		component.setValue(new ArrayList());
+		facesContext.getViewRoot().getChildren().add(component);
+		contributor = new SelectionRendererContributor();
+		renderer = new ScrollableGridBaseRenderer(){
+			protected Class getComponentClass() {
+			return UIScrollableGrid.class;
+		}};
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+	 */
+	public void tearDown() throws Exception {
+		super.tearDown();
+		this.component = null;
+		this.contributor = null;
+	}
+
+	/**
+	 * Test method for {@link org.richfaces.renderkit.html.SelectionRendererContributor#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent, org.richfaces.renderkit.CompositeRenderer)}.
+	 */
+	public void testDecode() {
+		MockExternalContext mockExternalContext = 
+			(MockExternalContext) facesContext.getExternalContext();
+		String name = 
+			SelectionRendererContributor.getSelectionInputName(facesContext, (UIScrollableGrid) component);
+		
+		String value = "";
+		
+		mockExternalContext.addRequestParameterMap(name, value);
+		
+		contributor.decode(facesContext, component, renderer);
+		
+		Object selection = component.getSelection();
+		
+	}
+	
+	public void testShouldAddToSelection() {
+		
+		ClientSelection oldSelection = new ClientSelection();
+		oldSelection.addRange(new SelectionRange(10, 15));
+		oldSelection.addRange(new SelectionRange(16, 20));
+		
+		ClientSelection newSelection = new ClientSelection();
+		newSelection.addRange(new SelectionRange(20, 40));
+		
+		newSelection.setSelectionFlag(ClientSelection.FLAG_ALL);
+		
+		for(int i = 0; i < 100; i++) {
+			assertTrue(
+					"Contributor was supposed to add " + i,
+					contributor.shouldAddToSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		
+		newSelection.setSelectionFlag(null);
+		
+		for (int i = 0; i < 21; i++) {
+			assertFalse(
+					"Contributor wasn't supposed to add " + i,
+					contributor.shouldAddToSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		for (int i = 21; i < 41; i++) {
+			assertTrue(
+					"Contributor was supposed to add " + i,
+					contributor.shouldAddToSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		for (int i = 41; i < 100; i++) {
+			assertFalse(
+					"Contributor wasn't supposed to add " + i,
+					contributor.shouldAddToSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		
+		newSelection.setSelectionFlag(ClientSelection.FLAG_RESET);
+		
+		
+		for (int i = 0; i < 20; i++) {
+			assertFalse(
+					"Contributor wasn't supposed to add " + i,
+					contributor.shouldAddToSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		for (int i = 21; i < 41; i++) {
+			assertTrue(
+					"Contributor was supposed to add " + i,
+					contributor.shouldAddToSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		for (int i = 41; i < 100; i++) {
+			assertFalse(
+					"Contributor wasn't supposed to add " + i,
+					contributor.shouldAddToSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		
+		
+	}
+	
+	
+	public void testShouldRemoveFromSelection() {
+		ClientSelection oldSelection = new ClientSelection();
+		oldSelection.addRange(new SelectionRange(10, 15));
+		oldSelection.addRange(new SelectionRange(16, 20));
+		
+		ClientSelection newSelection = new ClientSelection();
+		newSelection.addRange(new SelectionRange(20, 40));
+		
+		for (int i = 0; i < 10; i++) {
+			assertFalse(
+					"Contributor wasn't supposed to remove " + i,
+					contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+			);
+		}
+
+		for (int i = 10; i < 20; i++) {
+			assertTrue(
+					"Contributor was supposed to remove " + i,
+					contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		for (int i = 21; i < 100; i++) {
+			assertFalse(
+					"Contributor wasn't supposed to remove " + i,
+					contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+			);
+		}
+
+		
+		newSelection.setSelectionFlag(ClientSelection.FLAG_ALL);
+		
+		for (int i = 0; i < 100; i++) {
+			assertFalse(
+					"Contributor wasn't supposed to remove " + i,
+					contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+			);
+		}
+		
+		newSelection.setSelectionFlag(ClientSelection.FLAG_RESET);
+
+		for (int i = 0; i < 100; i++) {
+			assertFalse(
+					"Contributor wasn't supposed to remove " + i,
+					contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+			);
+		}
+	}
+
+}




More information about the richfaces-svn-commits mailing list