You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/10/01 00:07:55 UTC

svn commit: r700596 [2/2] - in /myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces: renderkit/html/ test/utils/

Modified: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessagesRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessagesRendererTest.java?rev=700596&r1=700595&r2=700596&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessagesRendererTest.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlMessagesRendererTest.java Tue Sep 30 15:07:55 2008
@@ -1,17 +1,20 @@
 /*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.myfaces.renderkit.html;
 
@@ -20,6 +23,11 @@
 import javax.faces.application.FacesMessage;
 import javax.faces.component.html.HtmlMessages;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
 import org.apache.shale.test.base.AbstractJsfTestCase;
 import org.apache.shale.test.mock.MockRenderKitFactory;
 import org.apache.shale.test.mock.MockResponseWriter;
@@ -34,22 +42,22 @@
     private static final String WARN_CLASS = "warnClass";
     private static final String INFO_CLASS = "infoClass";
 
-    private MockResponseWriter writer;
     private HtmlMessages messages;
+    private MockResponseWriter writer;
 
     public HtmlMessagesRendererTest(String name)
     {
         super(name);
     }
+    
+    public static Test suite() {
+        return new TestSuite(HtmlMessagesRendererTest.class);
+    }
 
-    protected void setUp() throws Exception
+    public void setUp() throws Exception
     {
         super.setUp();
-
         messages = new HtmlMessages();
-        messages.setErrorClass(ERROR_CLASS);
-        messages.setWarnClass(WARN_CLASS);
-        messages.setInfoClass(INFO_CLASS);
 
         writer = new MockResponseWriter(new StringWriter(), null, null);
         facesContext.setResponseWriter(writer);
@@ -59,32 +67,64 @@
                 messages.getFamily(),
                 messages.getRendererType(),
                 new HtmlMessagesRenderer());
-
+        
+        messages.setErrorClass(ERROR_CLASS);
+        messages.setWarnClass(WARN_CLASS);
+        messages.setInfoClass(INFO_CLASS);
     }
 
-    protected void tearDown() throws Exception
+    public void tearDown() throws Exception
     {
         super.tearDown();
+        messages = null;
         writer = null;
     }
-
-    public void testLayoutTable_Style() throws Exception
+    
+    public void testHtmlPropertyPassTru() throws Exception
     {
+        HtmlRenderedAttr[] attrs = {
+            //_EventProperties
+            new HtmlRenderedAttr("onclick"), 
+            new HtmlRenderedAttr("ondblclick"), 
+            new HtmlRenderedAttr("onkeydown"), 
+            new HtmlRenderedAttr("onkeypress"),
+            new HtmlRenderedAttr("onkeyup"), 
+            new HtmlRenderedAttr("onmousedown"), 
+            new HtmlRenderedAttr("onmousemove"), 
+            new HtmlRenderedAttr("onmouseout"),
+            new HtmlRenderedAttr("onmouseover"), 
+            new HtmlRenderedAttr("onmouseup"),
+            //_StyleProperties
+            new HtmlRenderedAttr("styleClass", "styleClass", "class=\"warnClass\""),
+        };
+        
         facesContext.addMessage("test1", new FacesMessage(FacesMessage.SEVERITY_WARN, "warnSumary", "detailWarnSummary"));
-        facesContext.addMessage("test2", new FacesMessage(FacesMessage.SEVERITY_ERROR, "errorSumary", "detailErrorSummary"));
 
         messages.setLayout("table");
         messages.setStyle("left: 48px; top: 432px; position: absolute");
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                messages, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
+    }
+    
+    public void testHtmlPropertyPassTruNotRendered() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnly();
+        
+        facesContext.addMessage("test1", new FacesMessage(FacesMessage.SEVERITY_WARN, "warnSumary", "detailWarnSummary"));
 
-        HtmlMessagesRenderer renderer = new HtmlMessagesRenderer();
-        renderer.encodeEnd(facesContext, messages);
-
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
-
-        // TODO: test don't work on different jvms (messages are in different order)
-        // assertEquals("<table style=\"left: 48px; top: 432px; position: absolute\"><tr><td><span class=\"warnClass\">warnSumary</span></td></tr>" +
-        //              "<tr><td><span class=\"errorClass\">errorSumary</span></td></tr></table>", output);
+        messages.setLayout("table");
+        messages.setStyle("left: 48px; top: 432px; position: absolute");
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                messages, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
     }
 }

Modified: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererTest.java?rev=700596&r1=700595&r2=700596&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererTest.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererTest.java Tue Sep 30 15:07:55 2008
@@ -1,30 +1,39 @@
 /*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.myfaces.renderkit.html;
 
-import org.apache.shale.test.base.AbstractJsfTestCase;
-import org.apache.shale.test.mock.MockRenderKitFactory;
-import org.apache.shale.test.mock.MockResponseWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.faces.component.UISelectItems;
 import javax.faces.component.html.HtmlSelectOneRadio;
 import javax.faces.model.SelectItem;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+import org.apache.shale.test.base.AbstractJsfTestCase;
+import org.apache.shale.test.mock.MockRenderKitFactory;
+import org.apache.shale.test.mock.MockResponseWriter;
 
 /**
  * @author Bruno Aranda (latest modification by $Author$)
@@ -39,8 +48,12 @@
     {
         super(name);
     }
+    
+    public static Test suite() {
+        return new TestSuite(HtmlRadioRendererTest.class);
+    }
 
-    protected void setUp() throws Exception
+    public void setUp() throws Exception
     {
         super.setUp();
 
@@ -57,55 +70,59 @@
 
     }
 
-    protected void tearDown() throws Exception
+    public void tearDown() throws Exception
     {
         super.tearDown();
         selectOneRadio = null;
         writer = null;
     }
-
-    public void testDefault() throws Exception
-    {
-        List items = new ArrayList();
-        items.add(new SelectItem("mars"));
-        items.add(new SelectItem("jupiter"));
-
-        UISelectItems selectItems = new UISelectItems();
-        selectItems.setValue(items);
-
-        selectOneRadio.getChildren().add(selectItems);
-
-        selectOneRadio.encodeEnd(facesContext);
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
-
-        assertEquals("<table><tr>\t\t" +
-                "<td><input id=\"j_id0:0\" type=\"radio\" name=\"j_id0\" value=\"mars\"/><label for=\"j_id0:0\">&#160;mars</label></td>\t\t" +
-                "<td><input id=\"j_id0:1\" type=\"radio\" name=\"j_id0\" value=\"jupiter\"/><label for=\"j_id0:1\">&#160;jupiter</label></td>" +
-                "</tr></table>", output);
-    }
-
-    public void testDefaultStylePassthru() throws Exception
+    
+    public void testHtmlPropertyPassTru() throws Exception
     {
+        HtmlRenderedAttr[] attrs = {
+            //_AccesskeyProperty
+            new HtmlRenderedAttr("accesskey"),
+            //_UniversalProperties
+            new HtmlRenderedAttr("dir"), 
+            new HtmlRenderedAttr("lang"), 
+            new HtmlRenderedAttr("title"),
+            //_FocusBlurProperties
+            new HtmlRenderedAttr("onfocus"), 
+            new HtmlRenderedAttr("onblur"),
+            //_ChangeSelectProperties
+            new HtmlRenderedAttr("onchange"), 
+            new HtmlRenderedAttr("onselect"),
+            //_EventProperties
+            new HtmlRenderedAttr("onclick"), 
+            new HtmlRenderedAttr("ondblclick"), 
+            new HtmlRenderedAttr("onkeydown"), 
+            new HtmlRenderedAttr("onkeypress"),
+            new HtmlRenderedAttr("onkeyup"), 
+            new HtmlRenderedAttr("onmousedown"), 
+            new HtmlRenderedAttr("onmousemove"), 
+            new HtmlRenderedAttr("onmouseout"),
+            new HtmlRenderedAttr("onmouseover"), 
+            new HtmlRenderedAttr("onmouseup"),
+            //_StyleProperties
+            new HtmlRenderedAttr("style", 1), 
+            new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\"", 1),
+
+            //_TabindexProperty
+            new HtmlRenderedAttr("tabindex")
+        };
+        
         List items = new ArrayList();
         items.add(new SelectItem("mars"));
-        items.add(new SelectItem("jupiter"));
 
         UISelectItems selectItems = new UISelectItems();
         selectItems.setValue(items);
 
         selectOneRadio.getChildren().add(selectItems);
 
-        selectOneRadio.setStyle("color: red;");
-
-        selectOneRadio.encodeEnd(facesContext);
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
-        assertEquals("<table style=\"color: red;\"><tr>\t\t" +
-                "<td><input id=\"j_id0:0\" type=\"radio\" name=\"j_id0\" value=\"mars\"/><label for=\"j_id0:0\">&#160;mars</label></td>\t\t" +
-                "<td><input id=\"j_id0:1\" type=\"radio\" name=\"j_id0\" value=\"jupiter\"/><label for=\"j_id0:1\">&#160;jupiter</label></td>" +
-                "</tr></table>", output);
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                selectOneRadio, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
     }
 }

Modified: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlSecretRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlSecretRendererTest.java?rev=700596&r1=700595&r2=700596&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlSecretRendererTest.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlSecretRendererTest.java Tue Sep 30 15:07:55 2008
@@ -1,12 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.myfaces.renderkit.html;
 
+import java.io.StringWriter;
+
+import javax.faces.component.html.HtmlInputSecret;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
 import org.apache.shale.test.base.AbstractJsfTestCase;
 import org.apache.shale.test.mock.MockRenderKitFactory;
 import org.apache.shale.test.mock.MockResponseWriter;
 
-import javax.faces.component.html.HtmlInputSecret;
-import java.io.StringWriter;
-
 /**
  * @author Bruno Aranda (latest modification by $Author: baranda $)
  * @version $Revision: 451814 $ $Date: 2006-10-01 22:28:42 +0100 (dom, 01 oct 2006) $
@@ -20,8 +44,12 @@
     {
         super(name);
     }
+    
+    public static Test suite() {
+        return new TestSuite(HtmlSecretRendererTest.class);
+    }
 
-    protected void setUp() throws Exception
+    public void setUp() throws Exception
     {
         super.setUp();
 
@@ -38,7 +66,7 @@
 
     }
 
-    protected void tearDown() throws Exception
+    public void tearDown() throws Exception
     {
         super.tearDown();
         inputText = null;
@@ -54,25 +82,14 @@
         assertEquals("<input type=\"password\" name=\"j_id0\"/>", output);
     }
 
-    public void testInputTextAutocompleteOn() throws Exception
-    {
-        inputText.setAutocomplete("on");
-        inputText.encodeEnd(facesContext);
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
-
-        assertEquals("<input type=\"password\" name=\"j_id0\"/>", output);
-    }
-
-    public void testInputTextAutocompleteOff() throws Exception
+    public void testHtmlPropertyPassTru() throws Exception
     {
-        inputText.setAutocomplete("off");
-        inputText.encodeEnd(facesContext);
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
-        assertEquals("<input type=\"password\" name=\"j_id0\" autocomplete=\"off\"/>", output);
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+        
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                inputText, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
     }
-
-}
\ No newline at end of file
+}

Modified: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTableRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTableRendererTest.java?rev=700596&r1=700595&r2=700596&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTableRendererTest.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTableRendererTest.java Tue Sep 30 15:07:55 2008
@@ -1,39 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.myfaces.renderkit.html;
 
+import java.io.StringWriter;
+
+import javax.faces.component.html.HtmlDataTable;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
 import org.apache.shale.test.base.AbstractJsfTestCase;
 import org.apache.shale.test.mock.MockRenderKitFactory;
 import org.apache.shale.test.mock.MockResponseWriter;
 
-import javax.el.ValueExpression;
-import javax.faces.component.UIColumn;
-import javax.faces.component.html.HtmlDataTable;
-import javax.faces.component.html.HtmlOutputText;
-import java.io.StringWriter;
-
 /**
  * @author Bruno Aranda (latest modification by $Author: baranda $)
  * @version $Revision: 451814 $ $Date: 2006-10-01 22:28:42 +0100 (dom, 01 oct 2006) $
  */
 public class HtmlTableRendererTest extends AbstractJsfTestCase
 {
-    private static final String LINE_SEPARATOR = System.getProperty(
-            "line.separator", "\r\n");
-
     private MockResponseWriter writer ;
     private HtmlDataTable dataTable;
-    private HtmlOutputText colText;
 
     public HtmlTableRendererTest(String name)
     {
         super(name);
     }
+    
+    public static Test suite() {
+        return new TestSuite(HtmlTableRendererTest.class);
+    }
 
-    protected void setUp() throws Exception
+    public void setUp() throws Exception
     {
         super.setUp();
 
         dataTable = new HtmlDataTable();
-        colText = new HtmlOutputText();
 
         writer = new MockResponseWriter(new StringWriter(), null, null);
         facesContext.setResponseWriter(writer);
@@ -43,114 +63,35 @@
                 dataTable.getFamily(),
                 dataTable.getRendererType(),
                 new HtmlTableRenderer());
-        facesContext.getRenderKit().addRenderer(
-                colText.getFamily(),
-                colText.getRendererType(),
-                new HtmlTextRenderer());
 
     }
 
-    protected void tearDown() throws Exception
+    public void tearDown() throws Exception
     {
         super.tearDown();
         dataTable = null;
         writer = null;
     }
 
-    public void testRenderTable() throws Exception
-    {
-        dataTable.setValue(new Integer[] {1,2,3});
-        dataTable.setVar("var");
-
-        UIColumn col = new UIColumn();
-
-        ValueExpression varValueExpression = facesContext.getApplication().getExpressionFactory()
-                .createValueExpression(facesContext.getELContext(), "#{var}", Integer.class);
-        colText.setValueExpression("value", varValueExpression);
-
-        col.getChildren().add(colText);
-        dataTable.getChildren().add(col);
-
-
-
-        dataTable.encodeAll(facesContext);
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
-
-        assertEquals(LINE_SEPARATOR +
-                "<table>" + LINE_SEPARATOR +
-                "<tbody id=\"j_id0:tbody_element\">" + LINE_SEPARATOR +
-                "<tr><td>1</td></tr>" + LINE_SEPARATOR +
-                "<tr><td>2</td></tr>" + LINE_SEPARATOR +
-                "<tr><td>3</td></tr></tbody></table>"+LINE_SEPARATOR, output);
-    }
-
-    public void testRenderTableWithColumnHeader() throws Exception
+    public void testHtmlPropertyPassTru() throws Exception
     {
-        dataTable.setValue(new String[] {"One","Two","Three"});
-        dataTable.setVar("var");
-
-        UIColumn col = new UIColumn();
-        HtmlOutputText headerTest = new HtmlOutputText();
-        headerTest.setValue("colHeader");
-        col.getFacets().put("header", headerTest);
-
-        ValueExpression varValueExpression = facesContext.getApplication().getExpressionFactory()
-                .createValueExpression(facesContext.getELContext(), "#{var}", String.class);
-        colText.setValueExpression("value", varValueExpression);
-
-        col.getChildren().add(colText);
-        dataTable.getChildren().add(col);
-
-
-
-        dataTable.encodeAll(facesContext);
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
-
-        assertEquals(LINE_SEPARATOR +
-                "<table>" + LINE_SEPARATOR +
-                "<thead>" + LINE_SEPARATOR +
-                "<tr><th scope=\"col\">colHeader</th></tr></thead>" + LINE_SEPARATOR +
-                "<tbody id=\"j_id0:tbody_element\">" + LINE_SEPARATOR +
-                "<tr><td>One</td></tr>" + LINE_SEPARATOR +
-                "<tr><td>Two</td></tr>" + LINE_SEPARATOR +
-                "<tr><td>Three</td></tr></tbody></table>"+LINE_SEPARATOR, output);
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+        
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                dataTable, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
+    }
+    
+    public void testHtmlPropertyPassTruNotRendered() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnly();
+        
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                dataTable, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
     }
-
-
-    public void testRenderTableWithHeader() throws Exception
-    {
-        dataTable.setValue(new String[] {"One","Two","Three"});
-        dataTable.setVar("var");
-
-        HtmlOutputText headerTest = new HtmlOutputText();
-        headerTest.setValue("colHeader");
-        dataTable.getFacets().put("header", headerTest);
-
-        UIColumn col = new UIColumn();
-
-        ValueExpression varValueExpression = facesContext.getApplication().getExpressionFactory()
-                .createValueExpression(facesContext.getELContext(), "#{var}", String.class);
-        colText.setValueExpression("value", varValueExpression);
-
-        col.getChildren().add(colText);
-        dataTable.getChildren().add(col);
-
-        dataTable.encodeAll(facesContext);
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
-        assertEquals(LINE_SEPARATOR +
-                "<table>" + LINE_SEPARATOR +
-                "<thead>" + LINE_SEPARATOR +
-                "<tr><th scope=\"colgroup\" colspan=\"1\">colHeader</th></tr></thead>" + LINE_SEPARATOR +
-                "<tbody id=\"j_id0:tbody_element\">" + LINE_SEPARATOR +
-                "<tr><td>One</td></tr>" + LINE_SEPARATOR +
-                "<tr><td>Two</td></tr>" + LINE_SEPARATOR +
-                "<tr><td>Three</td></tr></tbody></table>"+LINE_SEPARATOR, output);
-    }
-
-}
\ No newline at end of file
+}

Modified: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java?rev=700596&r1=700595&r2=700596&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java Tue Sep 30 15:07:55 2008
@@ -1,19 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.myfaces.renderkit.html;
 
+import java.io.IOException;
+import java.io.StringWriter;
+
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.component.html.HtmlOutputText;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
 import org.apache.shale.test.base.AbstractJsfTestCase;
 import org.apache.shale.test.mock.MockRenderKitFactory;
 import org.apache.shale.test.mock.MockResponseWriter;
 
-import javax.faces.component.html.HtmlInputText;
-import java.io.StringWriter;
-
 /**
- * @author Bruno Aranda (latest modification by $Author: baranda $)
- * @version $Revision: 451814 $ $Date: 2006-10-01 22:28:42 +0100 (dom, 01 oct 2006) $
+ * @author Bruno Aranda (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-09 04:06:54 +0800 (Thu, 09 Nov 2006) $
  */
 public class HtmlTextRendererTest extends AbstractJsfTestCase
 {
+
+    public static Test suite()
+    {
+        return new TestSuite(HtmlTextRendererTest.class); // needed in maven
+    }
+
     private MockResponseWriter writer ;
+    private HtmlOutputText outputText;
     private HtmlInputText inputText;
 
     public HtmlTextRendererTest(String name)
@@ -21,59 +54,58 @@
         super(name);
     }
 
-    protected void setUp() throws Exception
+    public void setUp() throws Exception
     {
         super.setUp();
 
+        outputText = new HtmlOutputText();
         inputText = new HtmlInputText();
 
         writer = new MockResponseWriter(new StringWriter(), null, null);
         facesContext.setResponseWriter(writer);
-
+        // TODO remove these two lines once shale-test goes alpha, see MYFACES-1155
         facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
         facesContext.getRenderKit().addRenderer(
+                outputText.getFamily(),
+                outputText.getRendererType(),
+                new HtmlTextRenderer());
+        facesContext.getRenderKit().addRenderer(
                 inputText.getFamily(),
                 inputText.getRendererType(),
                 new HtmlTextRenderer());
-
     }
 
-    protected void tearDown() throws Exception
+    public void tearDown() throws Exception
     {
         super.tearDown();
+        outputText = null;
         inputText = null;
         writer = null;
     }
 
-    public void testInputTextDefault() throws Exception
+    public void testStyleClassAttr() throws IOException
     {
-        inputText.encodeEnd(facesContext);
+        outputText.setValue("Output");
+        outputText.setStyleClass("myStyleClass");
+
+        outputText.encodeEnd(facesContext);
         facesContext.renderResponse();
 
         String output = writer.getWriter().toString();
 
-        assertEquals("<input id=\"j_id0\" name=\"j_id0\" type=\"text\" value=\"\"/>", output);
+        assertEquals("<span class=\"myStyleClass\">Output</span>", output);
+        assertNotSame("Output", output);
     }
 
-    public void testInputTextAutocompleteOn() throws Exception
+    public void testHtmlPropertyPassTru() throws Exception
     {
-        inputText.setAutocomplete("on");
-        inputText.encodeEnd(facesContext);
-        facesContext.renderResponse();
-
-        String output = writer.getWriter().toString();
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
         
-        assertEquals("<input id=\"j_id0\" name=\"j_id0\" type=\"text\" value=\"\"/>", output);
-    }
-
-    public void testInputTextAutocompleteOff() throws Exception
-    {
-        inputText.setAutocomplete("off");
-        inputText.encodeEnd(facesContext);
-        facesContext.renderResponse();
 
-        String output = writer.getWriter().toString();
-        assertEquals("<input id=\"j_id0\" name=\"j_id0\" type=\"text\" value=\"\" autocomplete=\"off\"/>", output);
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                inputText, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
     }
-
 }

Modified: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextareaRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextareaRendererTest.java?rev=700596&r1=700595&r2=700596&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextareaRendererTest.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextareaRendererTest.java Tue Sep 30 15:07:55 2008
@@ -1,12 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.myfaces.renderkit.html;
 
+import java.io.StringWriter;
+
+import javax.faces.component.html.HtmlInputTextarea;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
 import org.apache.shale.test.base.AbstractJsfTestCase;
 import org.apache.shale.test.mock.MockRenderKitFactory;
 import org.apache.shale.test.mock.MockResponseWriter;
 
-import javax.faces.component.html.HtmlInputTextarea;
-import java.io.StringWriter;
-
 /**
  * @author Bruno Aranda (latest modification by $Author: baranda $)
  * @version $Revision: 451814 $ $Date: 2006-10-01 22:28:42 +0100 (dom, 01 oct 2006) $
@@ -20,8 +44,12 @@
     {
         super(name);
     }
+    
+    public static Test suite() {
+        return new TestSuite(HtmlTextareaRendererTest.class);
+    }
 
-    protected void setUp() throws Exception
+    public void setUp() throws Exception
     {
         super.setUp();
 
@@ -38,7 +66,7 @@
 
     }
 
-    protected void tearDown() throws Exception
+    public void tearDown() throws Exception
     {
         super.tearDown();
         inputTextarea = null;
@@ -64,4 +92,15 @@
         String output = writer.getWriter().toString();
         assertEquals("<textarea name=\"j_id0\" cols=\"5\" rows=\"10\"></textarea>", output);
     }
-}
\ No newline at end of file
+    
+    public void testHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+        
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                inputTextarea, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
+    }
+}

Added: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlCheckAttributesUtil.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlCheckAttributesUtil.java?rev=700596&view=auto
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlCheckAttributesUtil.java (added)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlCheckAttributesUtil.java Tue Sep 30 15:07:55 2008
@@ -0,0 +1,228 @@
+package org.apache.myfaces.test.utils;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.apache.shale.test.mock.MockResponseWriter;
+
+/**
+ * This is a utility class used in unit test cases to check if
+ * a component's attributes are rendered properly.
+ */
+public class HtmlCheckAttributesUtil 
+{
+    /**
+     * This method adds all elements of attrs to the attributes map of component.
+     * @param component The component to add the attributes to.
+     * @param attrs     The attributes to be added to the component.
+     */
+    private static void addBaseAttributes(UIComponent component, HtmlRenderedAttr[] attrs) 
+    {
+        Map map = component.getAttributes();
+        for(int i = 0; i < attrs.length; i++) 
+        {
+            HtmlRenderedAttr attr = attrs[i];
+            map.put(attr.getName(), attr.getValue());
+        }
+    }
+    
+    /**
+     * Iterates through all elements of attrs to check if they are only rendered once in output.
+     * @param attrs      The attributes to be checked.
+     * @param output     The html output of the component's renderer.
+     * @throws Exception
+     */
+    private static void checkRenderedAttributes(HtmlRenderedAttr[] attrs, String output) throws Exception 
+    {
+        for(int i = 0; i < attrs.length; i++) 
+        {
+            //assertContainsOnlyOnce(attrs[i], output);
+            checkAttributeOccurrences(attrs[i], output);
+        }
+    }
+    
+    /**
+     * This method adds all attributes from attrs into the component.  After adding the attributes,
+     * it calls the encodeAll() method of the component.  The html generated from the component's
+     * renderer will be checked to see if the attributes have been rendered correctly.
+     * @param component  The component whose attributes will be tested.
+     * @param context    
+     * @param writer     The ResponseWriter used by the renderer to output the html generated.
+     * @param attrs      An array of attributes which will be tested.
+     * @throws Exception
+     */
+    public static void checkRenderedAttributes(
+            UIComponent component, 
+            FacesContext context, 
+            MockResponseWriter writer,
+            HtmlRenderedAttr[] attrs) throws Exception 
+    {
+        
+        addBaseAttributes(component, attrs);
+        component.encodeBegin(context);
+        component.encodeChildren(context);
+        component.encodeEnd(context);
+        context.renderResponse();
+        checkRenderedAttributes(attrs, writer.getWriter().toString());
+    }
+    
+    /**
+     * Checks the attrs array if it has elements which were rendered incorrectly.
+     * @param attrs The attributes to be checked.
+     * @return True if there are attributes not rendered correctly.
+     */
+    public static boolean hasFailedAttrRender(HtmlRenderedAttr[] attrs) 
+    {
+        for(int i = 0; i < attrs.length; i++) 
+        {
+            if(!attrs[i].isRenderSuccessful()) return true;
+        }
+        return false;
+    }
+    
+    /**
+     * Constructs an error message string detailing which attributes were not rendered
+     * and which attributes were rendered more than once.
+     * @param attrs   The attributes to be tested.
+     * @param actual  The html generated by the renderer.
+     * @return The error message.
+     */
+    public static String constructErrorMessage(HtmlRenderedAttr[] attrs, String actual) 
+    {
+        StringBuffer messgBuffer = new StringBuffer();
+        for(int i = 0; i < attrs.length; i++) 
+        {
+            if(attrs[i].getErrorCode() == HtmlRenderedAttr.RENDERED_MORE_TIMES_THAN_EXPECTED) 
+            {
+                messgBuffer.append(attrs[i].getName()).append(" (");
+                messgBuffer.append(attrs[i].getExpectedHtml()).append(") was rendered more times (");
+                messgBuffer.append(attrs[i].getActualOccurrences()).append(") than expected (");
+                messgBuffer.append(attrs[i].getExpectedOccurrences()).append(").");
+                messgBuffer.append(System.getProperty("line.separator"));
+            } 
+            else if(attrs[i].getErrorCode() == HtmlRenderedAttr.RENDERED_LESS_TIMES_THAN_EXPECTED)
+            {
+                messgBuffer.append(attrs[i].getName()).append(" (");
+                messgBuffer.append(attrs[i].getExpectedHtml()).append(") was rendered less times (");
+                messgBuffer.append(attrs[i].getActualOccurrences()).append(") than expected (");
+                messgBuffer.append(attrs[i].getExpectedOccurrences()).append(").");
+                messgBuffer.append(System.getProperty("line.separator"));
+            }
+        }
+        messgBuffer.append("Actual HTML: ").append(actual);
+        return messgBuffer.toString();
+    }
+    
+    /**
+     * Checks if the occurrence of the rendered attribute in the html
+     * generated by the renderer is equal to the number of times expected.
+     * @param attr   The attribute to be tested.
+     * @param actual The html generated by the renderer.
+     */
+    private static void checkAttributeOccurrences(HtmlRenderedAttr attr, String actual)
+    {
+        String expectedHtml = attr.getExpectedHtml();
+        
+        int index;
+        int offset = 0;
+        while((index=actual.indexOf(expectedHtml,offset)) != -1) 
+        {
+            attr.increaseActualOccurrences();
+            if(attr.getActualOccurrences() > attr.getExpectedOccurrences()) 
+            {
+                attr.setErrorCode(HtmlRenderedAttr.RENDERED_MORE_TIMES_THAN_EXPECTED);
+                return;
+            } 
+
+            offset += index + expectedHtml.length();
+        }
+        
+        if(attr.getActualOccurrences() < attr.getExpectedOccurrences()) 
+        {
+            attr.setErrorCode(HtmlRenderedAttr.RENDERED_LESS_TIMES_THAN_EXPECTED);
+        } 
+        else 
+        {
+            attr.setRenderSuccessful(true);
+        }
+    }
+    
+    public static HtmlRenderedAttr[] generateBasicAttrs() {
+        HtmlRenderedAttr[] attrs = {
+            //_AccesskeyProperty
+            new HtmlRenderedAttr("accesskey"),
+            //_UniversalProperties
+            new HtmlRenderedAttr("dir"), 
+            new HtmlRenderedAttr("lang"), 
+            new HtmlRenderedAttr("title"),
+            //_FocusBlurProperties
+            new HtmlRenderedAttr("onfocus"), 
+            new HtmlRenderedAttr("onblur"),
+            //_ChangeSelectProperties
+            new HtmlRenderedAttr("onchange"), 
+            new HtmlRenderedAttr("onselect"),
+            //_EventProperties
+            new HtmlRenderedAttr("onclick"), 
+            new HtmlRenderedAttr("ondblclick"), 
+            new HtmlRenderedAttr("onkeydown"), 
+            new HtmlRenderedAttr("onkeypress"),
+            new HtmlRenderedAttr("onkeyup"), 
+            new HtmlRenderedAttr("onmousedown"), 
+            new HtmlRenderedAttr("onmousemove"), 
+            new HtmlRenderedAttr("onmouseout"),
+            new HtmlRenderedAttr("onmouseover"), 
+            new HtmlRenderedAttr("onmouseup"),
+            //_StyleProperties
+            new HtmlRenderedAttr("style"), 
+            new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\""),
+            //_TabindexProperty
+            new HtmlRenderedAttr("tabindex")
+        };
+        
+        return attrs;
+    }
+    
+    public static HtmlRenderedAttr[] generateAttrsNotRenderedForReadOnly() 
+    {
+        HtmlRenderedAttr[] attrs = {
+            //_AccesskeyProperty
+            new HtmlRenderedAttr("accesskey", 0),
+            //_FocusBlurProperties
+            new HtmlRenderedAttr("onfocus", 0), 
+            new HtmlRenderedAttr("onblur", 0),
+            //_ChangeSelectProperties
+            new HtmlRenderedAttr("onchange", 0), 
+            new HtmlRenderedAttr("onselect", 0),
+            //_TabindexProperty
+            new HtmlRenderedAttr("tabindex", 0)
+        };
+        return attrs;
+    }
+    
+    public static HtmlRenderedAttr[] generateBasicReadOnlyAttrs() {
+        HtmlRenderedAttr[] attrs = {
+            //_UniversalProperties
+            new HtmlRenderedAttr("dir"), 
+            new HtmlRenderedAttr("lang"), 
+            new HtmlRenderedAttr("title"),
+            //_EventProperties
+            new HtmlRenderedAttr("onclick"), 
+            new HtmlRenderedAttr("ondblclick"), 
+            new HtmlRenderedAttr("onkeydown"), 
+            new HtmlRenderedAttr("onkeypress"),
+            new HtmlRenderedAttr("onkeyup"), 
+            new HtmlRenderedAttr("onmousedown"), 
+            new HtmlRenderedAttr("onmousemove"), 
+            new HtmlRenderedAttr("onmouseout"),
+            new HtmlRenderedAttr("onmouseover"), 
+            new HtmlRenderedAttr("onmouseup"),
+            //_StyleProperties
+            new HtmlRenderedAttr("style"), 
+            new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\""),
+        };
+        
+        return attrs;
+    }
+}

Propchange: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlCheckAttributesUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlCheckAttributesUtil.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlRenderedAttr.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlRenderedAttr.java?rev=700596&view=auto
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlRenderedAttr.java (added)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlRenderedAttr.java Tue Sep 30 15:07:55 2008
@@ -0,0 +1,117 @@
+package org.apache.myfaces.test.utils;
+
+public class HtmlRenderedAttr
+{
+    public static final int RENDERED_MORE_TIMES_THAN_EXPECTED = 1;
+    public static final int RENDERED_LESS_TIMES_THAN_EXPECTED = 2;
+    
+    private String name;
+    private String value;
+    private String expectedHtml;
+    private boolean renderSuccessful;
+    private int errorCode;
+    private int expectedOccurrences;
+    private int actualOccurrences;
+    
+    public HtmlRenderedAttr(String name) {
+        this(name, name, name + "=\"" + name + "\"");
+        expectedOccurrences = 1;
+    }
+    
+    public HtmlRenderedAttr(String name, int expectedOccurences) {
+        this(name);
+        this.expectedOccurrences = expectedOccurences;
+    }
+    
+    /**
+     * Represents an attribute of a component that is expected to be
+     * rendered into html
+     * @param name  The name of the attribute.
+     * @param value The value of the attribute.
+     * @param expectedHtml The expected html output for this attribute.  
+     *     E.g. name="value".
+     */
+    public HtmlRenderedAttr(String name, String value, String expectedHtml) {
+        this.name = name;
+        this.value = value;
+        this.expectedHtml = expectedHtml;
+        
+        renderSuccessful = false;
+        expectedOccurrences = 1;
+    }
+    
+    public HtmlRenderedAttr(String name, String value, String expectedHtml, int occurances) {
+        this(name, value, expectedHtml);
+        this.expectedOccurrences = occurances;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+
+    public String getExpectedHtml()
+    {
+        return expectedHtml;
+    }
+
+    public void setExpectedHtml(String expectedHtml)
+    {
+        this.expectedHtml = expectedHtml;
+    }
+
+    /**
+     * This returns the result of the rendering of the attribute.
+     * @return True if the rendered html output of this attribute is
+     * the same as expectedHtml.  False if either the attribute was not
+     * rendered, it was rendered multiple times, or the rendered html
+     * is different from expectedHtml.
+     */
+    public boolean isRenderSuccessful()
+    {
+        return renderSuccessful;
+    }
+
+    public void setRenderSuccessful(boolean renderSuccessful)
+    {
+        this.renderSuccessful = renderSuccessful;
+    }
+
+    public int getErrorCode()
+    {
+        return errorCode;
+    }
+
+    public void setErrorCode(int errorCode)
+    {
+        this.errorCode = errorCode;
+        setRenderSuccessful(false);
+    }
+    
+    public void increaseActualOccurrences() {
+        actualOccurrences++;
+    }
+    
+    public int getActualOccurrences() {
+        return this.actualOccurrences;
+    }
+    
+    public int getExpectedOccurrences() {
+        return this.expectedOccurrences;
+    }
+}

Propchange: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlRenderedAttr.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/HtmlRenderedAttr.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java?rev=700596&view=auto
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java (added)
+++ myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java Tue Sep 30 15:07:55 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.test.utils;
+
+import javax.faces.context.FacesContext;
+
+import org.apache.shale.test.mock.MockViewHandler;
+
+/**
+ * This class is a temporary workaround for test cases
+ * that need a MockViewHandler that doesn't throw an
+ * UnsupportedOperationException inside writeState().
+ * This is not needed anymore once the fix for
+ * SHALE-468 is released.
+ */
+public class MockTestViewHandler extends MockViewHandler
+{
+    public void writeState(FacesContext context)
+    {
+        //do nothing
+    }
+}

Propchange: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk_1.2.x/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL