myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pau...@apache.org
Subject svn commit: r491562 - /myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTableTest.java
Date Mon, 01 Jan 2007 12:43:15 GMT
Author: paulsp
Date: Mon Jan  1 04:43:14 2007
New Revision: 491562

URL: http://svn.apache.org/viewvc?view=rev&rev=491562
Log:
Add test to render component using the default renderer

Modified:
    myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTableTest.java

Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTableTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTableTest.java?view=diff&rev=491562&r1=491561&r2=491562
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTableTest.java
(original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTableTest.java
Mon Jan  1 04:43:14 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.myfaces.component.html.ext;
 
+import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -29,6 +30,7 @@
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIData;
 import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlForm;
 import javax.faces.context.FacesContext;
 import javax.faces.el.ValueBinding;
 import javax.faces.model.ListDataModel;
@@ -36,6 +38,7 @@
 import junit.framework.Test;
 
 import org.apache.myfaces.test.AbstractTomahawkJsfTestCase;
+import org.apache.myfaces.test.utils.TestUtils;
 
 /**
  * @author Mathias Br�kelmann (latest modification by $Author$)
@@ -43,28 +46,33 @@
  */
 public class HtmlDataTableTest extends AbstractTomahawkJsfTestCase
 {
-    
+
     private HtmlDataTable _dataTable;
 
-    public HtmlDataTableTest(String name) {
-		super(name);
-	}
-
-	public static Test suite() {
-		return null; // keep this method or maven won't run it
-	}
-    
+    public HtmlDataTableTest(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite()
+    {
+        return null; // keep this method or maven won't run it
+    }
+
     protected void setUp() throws Exception
     {
         super.setUp();
+        servletContext.addInitParameter("org.apache.myfaces.PRETTY_HTML",
+                "false");
+
         _dataTable = new HtmlDataTable();
     }
 
     protected void tearDown() throws Exception
     {
-    	super.tearDown();
-    	// once shale-test is updated in maven, this will not be necessary
-    	FactoryFinder.releaseFactories();
+        super.tearDown();
+        // once shale-test is updated in maven, this will not be necessary
+        FactoryFinder.releaseFactories();
         _dataTable = null;
     }
 
@@ -81,17 +89,17 @@
         for (int i = 0; i < 10; i++)
         {
             _dataTable.setRowIndex(i);
-            assertTrue("Duplicate client id while iterating rows",
-                    rowClientIds.add(_dataTable.getClientId(facesContext)));
+            assertTrue("Duplicate client id while iterating rows", rowClientIds
+                    .add(_dataTable.getClientId(facesContext)));
         }
         _dataTable.setRowIndex(-1);
         assertEquals(baseClientId, _dataTable.getClientId(facesContext));
     }
 
     /*
-    * Test method for
-    * 'org.apache.myfaces.component.html.ext.HtmlDataTable.findComponent(String clientId)'
-    */
+     * Test method for
+     * 'org.apache.myfaces.component.html.ext.HtmlDataTable.findComponent(String clientId)'
+     */
     public void testFindComponent()
     {
         UIInput input = createInputInTree(facesContext);
@@ -104,10 +112,37 @@
 
         UIInput uiInput = (UIInput) comp;
 
-        assertEquals(uiInput.getValue(),"test2");
+        assertEquals(uiInput.getValue(), "test2");
 
     }
 
+    /**
+     * Verify component renders with the default renderer.
+     */
+    public void testDefaultRenderer()
+    {
+        // Define the component
+        UIData dataTable = new HtmlDataTable();
+        dataTable.setParent(new HtmlForm());
+
+        // Add rows to the table
+        List rows = new ArrayList();
+        rows.add(new TestData("test1", "test1"));
+        rows.add(new TestData("test2", "test2"));
+        rows.add(new TestData("test3", "test3"));
+        dataTable.setValue(new ListDataModel(rows));
+
+        // Render the component
+        try
+        {
+            TestUtils.renderComponent(facesContext, dataTable.getParent());
+        }
+        catch (IOException e)
+        {
+            fail(e.getMessage());
+        }
+    }
+
     private UIInput createInputInTree(FacesContext context)
     {
 
@@ -115,9 +150,9 @@
         uiData.setId("data");
 
         List li = new ArrayList();
-        li.add(new TestData("test1","test1"));
-        li.add(new TestData("test2","test2"));
-        li.add(new TestData("test3","test3"));
+        li.add(new TestData("test1", "test1"));
+        li.add(new TestData("test2", "test2"));
+        li.add(new TestData("test3", "test3"));
 
         uiData.setValue(new ListDataModel(li));
         uiData.setVar("detail");
@@ -128,7 +163,8 @@
 
         UIInput input = new UIInput();
         input.setId("input");
-        input.setValueBinding("value",createValueBinding("#{detail.description}"));
+        input.setValueBinding("value",
+                createValueBinding("#{detail.description}"));
 
         column.getChildren().add(input);
 



Mime
View raw message