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 2010/07/14 00:57:42 UTC
svn commit: r963899 [5/7] - in /myfaces/tomahawk/trunk/core20: ./
src/test/java/org/apache/myfaces/component/
src/test/java/org/apache/myfaces/component/html/
src/test/java/org/apache/myfaces/component/html/ext/
src/test/java/org/apache/myfaces/convert...
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,156 @@
+/*
+ * 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.ext;
+
+import javax.faces.component.html.HtmlForm;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlCommandButton;
+import org.apache.myfaces.shared_impl.config.MyfacesConfig;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockExternalContext;
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.myfaces.test.mock.MockHttpServletResponse;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.mock.MockServletContext;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlButtonRendererTest extends AbstractTomahawkViewControllerTestCase {
+
+ private MockResponseWriter writer;
+ private HtmlCommandButton commandButton;
+ private HtmlForm form;
+
+ public HtmlButtonRendererTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlButtonRendererTest.class);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ writer = (MockResponseWriter)facesContext.getResponseWriter();
+ commandButton = new HtmlCommandButton();
+ form = new HtmlForm();
+ commandButton.setParent(form);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ writer = null;
+ form = null;
+ commandButton = null;
+ }
+
+ public void testJSAllowedHtmlPropertyPassTru() 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", "onclick",
+ "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")
+ };
+
+ MockServletContext servletContext = new MockServletContext();
+ servletContext.addInitParameter("org.apache.myfaces.ALLOW_JAVASCRIPT", "true");
+ MockExternalContext mockExtCtx = new MockExternalContext(servletContext,
+ new MockHttpServletRequest(), new MockHttpServletResponse());
+ MyfacesConfig config = MyfacesConfig.getCurrentInstance(mockExtCtx);
+ facesContext.setExternalContext(mockExtCtx);
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ commandButton, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+
+ public void testJSNotAllowedHtmlPropertyPassTru() 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","onclick","var cf = function(){onclick};var oamSF = function(){};return (cf.apply(this, [])==false)? false : oamSF.apply(this, []); "),
+ 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")
+ };
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ commandButton, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,155 @@
+/*
+ * 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.ext;
+
+import javax.faces.component.UISelectItem;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlSelectBooleanCheckbox;
+import org.apache.myfaces.component.html.ext.HtmlSelectManyCheckbox;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+
+public class HtmlCheckboxRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private MockResponseWriter writer ;
+ private HtmlSelectManyCheckbox selectManyCheckbox;
+ private HtmlSelectBooleanCheckbox selectBooleanCheckbox;
+
+ public HtmlCheckboxRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlCheckboxRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ selectManyCheckbox = new HtmlSelectManyCheckbox();
+ selectBooleanCheckbox = new HtmlSelectBooleanCheckbox();
+
+ writer = (MockResponseWriter)facesContext.getResponseWriter();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ selectManyCheckbox = null;
+ selectBooleanCheckbox = null;
+ writer = null;
+ }
+
+ public void testSelectManyHtmlPropertyPassTru() 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"),
+ new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\""),
+ //_TabindexProperty
+ new HtmlRenderedAttr("tabindex")
+ };
+
+ UISelectItem item = new UISelectItem();
+ item.setItemLabel("mars");
+ item.setItemValue("mars");
+ selectManyCheckbox.getChildren().add(item);
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ selectManyCheckbox, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+
+ public void testSelectBooleanHtmlPropertyPasstru() 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"),
+ new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\""),
+ //_TabindexProperty
+ new HtmlRenderedAttr("tabindex")
+ };
+
+ selectBooleanCheckbox.setSelected(true);
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ selectBooleanCheckbox, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+
+ }
+}
Modified: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRendererValueTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRendererValueTest.java?rev=963899&r1=963898&r2=963899&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRendererValueTest.java (original)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRendererValueTest.java Tue Jul 13 22:57:38 2010
@@ -27,9 +27,9 @@ import javax.el.ValueExpression;
import javax.faces.component.UISelectItem;
import org.apache.myfaces.component.html.ext.HtmlSelectManyCheckbox;
-import org.apache.shale.test.base.AbstractJsfTestCase;
-import org.apache.shale.test.el.MockValueExpression;
-import org.apache.shale.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.base.AbstractJsfTestCase;
+import org.apache.myfaces.test.el.MockValueExpression;
+import org.apache.myfaces.test.mock.MockResponseWriter;
/**
* Test cases for HtmlCheckboxRenderer.
@@ -74,7 +74,7 @@ public class HtmlCheckboxRendererValueTe
@SuppressWarnings("unchecked")
public void testValueTypeRender() throws IOException
{
- TestBean bean = new TestBean();
+ MockBean bean = new MockBean();
externalContext.getApplicationMap().put("bean", bean);
ValueExpression beanVE = new MockValueExpression("#{bean.values}", Object.class);
@@ -89,7 +89,7 @@ public class HtmlCheckboxRendererValueTe
selectMany.getChildren().add(item);
// register the converter
- application.addConverter(Integer.class, TestIntegerConverter.class.getName());
+ application.addConverter(Integer.class, MockIntegerConverter.class.getName());
// Render the component (only encodeEnd is used in this renderer)
_renderer.encodeEnd(facesContext, selectMany);
@@ -103,7 +103,7 @@ public class HtmlCheckboxRendererValueTe
@SuppressWarnings({ "unchecked", "serial" })
public void testValueTypeSubmit() throws IOException
{
- TestBean bean = new TestBean();
+ MockBean bean = new MockBean();
externalContext.getApplicationMap().put("bean", bean);
ValueExpression beanVE = new MockValueExpression("#{bean.values}", Object.class)
{
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlGridRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlGridRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlGridRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlGridRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,115 @@
+/*
+ * 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.ext;
+
+import javax.faces.component.UIColumn;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlOutputText;
+import org.apache.myfaces.component.html.ext.HtmlPanelGrid;
+import org.apache.myfaces.shared_tomahawk.util.StringUtils;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlGridRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private MockResponseWriter writer ;
+ private HtmlPanelGrid panelGrid;
+ private HtmlOutputText colText;
+
+ public HtmlGridRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlGridRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ panelGrid = new HtmlPanelGrid();
+ colText = new HtmlOutputText();
+ writer = (MockResponseWriter)facesContext.getResponseWriter();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ panelGrid = null;
+ colText = null;
+ writer = null;
+ }
+
+ public void testRenderTable() throws Exception
+ {
+ UIColumn col1 = new UIColumn();
+ HtmlOutputText col1Text = new HtmlOutputText();
+ col1Text.setValue("col1Text");
+
+ UIColumn col2 = new UIColumn();
+ HtmlOutputText col2Text = new HtmlOutputText();
+ col2Text.setValue("col2Text");
+
+ col1.getChildren().add(col1Text);
+ col2.getChildren().add(col2Text);
+ panelGrid.getChildren().add(col1);
+ panelGrid.getChildren().add(col2);
+
+ panelGrid.encodeBegin(facesContext);
+ panelGrid.encodeChildren(facesContext);
+ panelGrid.encodeEnd(facesContext);
+ facesContext.renderResponse();
+
+ String output = writer.getWriter().toString();
+ output = StringUtils.replace(output, '\n', "");
+ output = StringUtils.replace(output, '\r', "");
+
+ assertEquals("<table><tbody><tr><td>col1Text</td></tr><tr><td>col2Text</td></tr></tbody></table>", output);
+ }
+
+ public void testHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ panelGrid, 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(
+ panelGrid, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlGroupRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlGroupRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlGroupRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlGroupRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,91 @@
+/*
+ * 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.ext;
+
+import javax.faces.component.html.HtmlOutputText;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+
+public class HtmlGroupRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private static String PANEL_CHILD_TEXT = "PANEL";
+ private static String STYLE_CLASS = "myStyleClass";
+
+ private MockResponseWriter writer ;
+ private HtmlPanelGroup panelGroup;
+
+ public HtmlGroupRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlGroupRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ panelGroup = new HtmlPanelGroup();
+
+ HtmlOutputText panelChildOutputText = new HtmlOutputText();
+ panelChildOutputText.setValue(PANEL_CHILD_TEXT);
+ panelGroup.getChildren().add(panelChildOutputText);
+
+ writer = (MockResponseWriter)facesContext.getResponseWriter();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ writer = null;
+ }
+
+ public void testHtmlPropertyPassTruNotRendered() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnly();
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ panelGroup, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+
+ public void testHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ panelGroup, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlImageRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlImageRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlImageRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlImageRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,102 @@
+/*
+ * 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.ext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlGraphicImage;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlImageRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private MockResponseWriter writer ;
+ private HtmlGraphicImage graphicImage;
+
+ public HtmlImageRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlImageRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ graphicImage = new HtmlGraphicImage();
+ writer = (MockResponseWriter)facesContext.getResponseWriter();
+
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ graphicImage = null;
+ writer = null;
+ }
+
+ public void testRenderDefault() throws Exception
+ {
+ graphicImage.setAlt("foo");
+ graphicImage.setId("img1");
+ graphicImage.setValue("http://myfaces.apache.org");
+ graphicImage.encodeBegin(facesContext);
+ graphicImage.encodeChildren(facesContext);
+ graphicImage.encodeEnd(facesContext);
+ facesContext.renderResponse();
+
+ String output = writer.getWriter().toString();
+ assertEquals("<img id=\"img1\" src=\"nullhttp://myfaces.apache.org\" alt=\"foo\"/>", output);
+ }
+
+ public void testHtmlPropertyPassTruNotRendered() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnly();
+
+ graphicImage.setId("img1");
+ graphicImage.setValue("http://myfaces.apache.org");
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ graphicImage, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+
+ public void testHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+
+ graphicImage.setId("img1");
+ graphicImage.setValue("http://myfaces.apache.org");
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ graphicImage, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlLinkRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlLinkRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlLinkRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlLinkRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,155 @@
+/*
+ * 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.ext;
+
+import javax.faces.component.UIForm;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlCommandLink;
+import org.apache.myfaces.shared_impl.config.MyfacesConfig;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockExternalContext;
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.myfaces.test.mock.MockHttpServletResponse;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.mock.MockServletContext;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+
+public class HtmlLinkRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+
+ private MockResponseWriter writer;
+ private HtmlCommandLink link;
+
+ public HtmlLinkRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlLinkRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ link = new HtmlCommandLink();
+ writer = (MockResponseWriter)facesContext.getResponseWriter();
+
+ UIForm form = new UIForm();
+ form.getChildren().add(link);
+
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ writer = null;
+ }
+
+ public void testJSAllowedHtmlPropertyPassTru() 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"),
+ //_EventProperties
+ new HtmlRenderedAttr("onclick", "onclick", "return jsf.util.chain(document.getElementById('j_id0:j_id0'), event,'onclick', 'return oamSubmitForm(\\'j_id0\\',\\'j_id0:j_id0\\');');"),
+ 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")
+ };
+
+ link.setValue("outputdata");
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ link, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+
+ public void testJSNotAllowedHtmlPropertyPassTru() 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"),
+ //_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")
+ };
+
+
+ link.setValue("outputdata");
+
+ MockServletContext servletContext = new MockServletContext();
+ servletContext.addInitParameter("org.apache.myfaces.ALLOW_JAVASCRIPT", "false");
+ MockExternalContext mockExtCtx = new MockExternalContext(servletContext,
+ new MockHttpServletRequest(), new MockHttpServletResponse());
+ MyfacesConfig config = MyfacesConfig.getCurrentInstance(mockExtCtx);
+ facesContext.setExternalContext(mockExtCtx);
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ link, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlListboxRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlListboxRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlListboxRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlListboxRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,106 @@
+/*
+ * 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.ext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.component.UISelectItems;
+import javax.faces.model.SelectItem;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlSelectManyListbox;
+import org.apache.myfaces.component.html.ext.HtmlSelectOneListbox;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlListboxRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private MockResponseWriter writer ;
+ private HtmlSelectOneListbox selectOneListbox;
+ private HtmlSelectManyListbox selectManyListbox;
+
+ public HtmlListboxRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlListboxRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ selectOneListbox = new HtmlSelectOneListbox();
+ selectManyListbox = new HtmlSelectManyListbox();
+
+ writer = (MockResponseWriter) facesContext.getResponseWriter();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ selectOneListbox = null;
+ writer = null;
+ }
+
+ public void testSelectOneHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+
+ List items = new ArrayList();
+ items.add(new SelectItem("mars"));
+
+ UISelectItems selectItems = new UISelectItems();
+ selectItems.setValue(items);
+
+ selectOneListbox.getChildren().add(selectItems);
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ selectOneListbox, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+
+ public void testSelectManyHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+
+ List items = new ArrayList();
+ items.add(new SelectItem("mars"));
+
+ UISelectItems selectItems = new UISelectItems();
+ selectItems.setValue(items);
+
+ selectManyListbox.getChildren().add(selectItems);
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ selectManyListbox, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Modified: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlListboxRendererValueTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlListboxRendererValueTest.java?rev=963899&r1=963898&r2=963899&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlListboxRendererValueTest.java (original)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlListboxRendererValueTest.java Tue Jul 13 22:57:38 2010
@@ -27,9 +27,9 @@ import javax.el.ValueExpression;
import javax.faces.component.UISelectItem;
import org.apache.myfaces.component.html.ext.HtmlSelectManyListbox;
-import org.apache.shale.test.base.AbstractJsfTestCase;
-import org.apache.shale.test.el.MockValueExpression;
-import org.apache.shale.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.base.AbstractJsfTestCase;
+import org.apache.myfaces.test.el.MockValueExpression;
+import org.apache.myfaces.test.mock.MockResponseWriter;
/**
* Test cases for HtmlListboxRenderer.
@@ -74,7 +74,7 @@ public class HtmlListboxRendererValueTes
@SuppressWarnings("unchecked")
public void testValueTypeRender() throws IOException
{
- TestBean bean = new TestBean();
+ MockBean bean = new MockBean();
externalContext.getApplicationMap().put("bean", bean);
ValueExpression beanVE = new MockValueExpression("#{bean.values}", Object.class);
@@ -89,7 +89,7 @@ public class HtmlListboxRendererValueTes
selectMany.getChildren().add(item);
// register the converter
- application.addConverter(Integer.class, TestIntegerConverter.class.getName());
+ application.addConverter(Integer.class, MockIntegerConverter.class.getName());
// Render the component (only encodeEnd is used in this renderer)
_renderer.encodeEnd(facesContext, selectMany);
@@ -103,7 +103,7 @@ public class HtmlListboxRendererValueTes
@SuppressWarnings({ "unchecked", "serial" })
public void testValueTypeSubmit() throws IOException
{
- TestBean bean = new TestBean();
+ MockBean bean = new MockBean();
externalContext.getApplicationMap().put("bean", bean);
ValueExpression beanVE = new MockValueExpression("#{bean.values}", Object.class)
{
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMenuRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMenuRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMenuRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMenuRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,105 @@
+/*
+ * 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.ext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.component.UISelectItems;
+import javax.faces.model.SelectItem;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlSelectManyMenu;
+import org.apache.myfaces.component.html.ext.HtmlSelectOneMenu;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlMenuRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private HtmlSelectOneMenu selectOneMenu;
+ private HtmlSelectManyMenu selectManyMenu;
+ private MockResponseWriter writer;
+
+ public HtmlMenuRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlMenuRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ writer = (MockResponseWriter)facesContext.getResponseWriter();
+ selectOneMenu = new HtmlSelectOneMenu();
+ selectManyMenu = new HtmlSelectManyMenu();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ selectOneMenu = null;
+ selectManyMenu = null;
+ writer = null;
+ }
+
+ public void testSelectOneHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+
+ List items = new ArrayList();
+ items.add(new SelectItem("mars"));
+
+ UISelectItems selectItems = new UISelectItems();
+ selectItems.setValue(items);
+
+ selectOneMenu.getChildren().add(selectItems);
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ selectOneMenu, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+
+ public void testSelectManyHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+
+ List items = new ArrayList();
+ items.add(new SelectItem("mars"));
+
+ UISelectItems selectItems = new UISelectItems();
+ selectItems.setValue(items);
+
+ selectManyMenu.getChildren().add(selectItems);
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ selectManyMenu, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Modified: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMenuRendererValueTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMenuRendererValueTest.java?rev=963899&r1=963898&r2=963899&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMenuRendererValueTest.java (original)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMenuRendererValueTest.java Tue Jul 13 22:57:38 2010
@@ -27,9 +27,9 @@ import javax.el.ValueExpression;
import javax.faces.component.UISelectItem;
import org.apache.myfaces.component.html.ext.HtmlSelectManyMenu;
-import org.apache.shale.test.base.AbstractJsfTestCase;
-import org.apache.shale.test.el.MockValueExpression;
-import org.apache.shale.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.base.AbstractJsfTestCase;
+import org.apache.myfaces.test.el.MockValueExpression;
+import org.apache.myfaces.test.mock.MockResponseWriter;
/**
* Test cases for HtmlMenuRenderer.
@@ -74,7 +74,7 @@ public class HtmlMenuRendererValueTest e
@SuppressWarnings("unchecked")
public void testValueTypeRender() throws IOException
{
- TestBean bean = new TestBean();
+ MockBean bean = new MockBean();
externalContext.getApplicationMap().put("bean", bean);
ValueExpression beanVE = new MockValueExpression("#{bean.values}", Object.class);
@@ -89,7 +89,7 @@ public class HtmlMenuRendererValueTest e
selectMany.getChildren().add(item);
// register the converter
- application.addConverter(Integer.class, TestIntegerConverter.class.getName());
+ application.addConverter(Integer.class, MockIntegerConverter.class.getName());
// Render the component (only encodeEnd is used in this renderer)
_renderer.encodeEnd(facesContext, selectMany);
@@ -103,7 +103,7 @@ public class HtmlMenuRendererValueTest e
@SuppressWarnings({ "unchecked", "serial" })
public void testValueTypeSubmit() throws IOException
{
- TestBean bean = new TestBean();
+ MockBean bean = new MockBean();
externalContext.getApplicationMap().put("bean", bean);
ValueExpression beanVE = new MockValueExpression("#{bean.values}", Object.class)
{
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMessageRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMessageRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMessageRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMessageRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,152 @@
+/*
+ * 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.ext;
+
+import java.io.IOException;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.component.html.HtmlOutputLabel;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlMessage;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlMessageRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private static final String ERROR_CLASS = "errorClass";
+ private static final String WARN_CLASS = "warnClass";
+ private static final String INFO_CLASS = "infoClass";
+
+ private HtmlMessage message;
+ private HtmlForm form;
+ private HtmlInputText inputText;
+
+ public HtmlMessageRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlMessageRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("myFormId");
+ inputText = new HtmlInputText();
+ inputText.setParent(form);
+ inputText.setId("myInputId");
+
+ message = new HtmlMessage();
+ message.setErrorClass(ERROR_CLASS);
+ message.setWarnClass(WARN_CLASS);
+ message.setInfoClass(INFO_CLASS);
+ message.setParent(form);
+
+ form.getChildren().add(inputText);
+ form.getChildren().add(message);
+
+ facesContext.getViewRoot().getChildren().add(form);
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testHtmlPropertyPassTru() throws Exception
+ {
+ facesContext.addMessage(inputText.getClientId(facesContext),
+ new FacesMessage("Validation message here."));
+
+ 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=\"infoClass\""),
+ };
+
+ facesContext.addMessage("test1", new FacesMessage(FacesMessage.SEVERITY_WARN, "warnSumary", "detailWarnSummary"));
+ message.setStyle("left: 48px; top: 432px; position: absolute");
+ message.setFor("myInputId");
+
+ MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ message, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+
+ public void testLabelClientIdSubstitution() throws IOException {
+ final String ERROR_MESSAGE = "Please enter a number.";
+ final String LABEL_TEXT = "My Numeric Input Field";
+
+ // This is the kind of message that will get generated by a JSF 1.2 converter
+ // Note that the full client id is used, instead of just the id
+ //
+ facesContext.addMessage(inputText.getClientId(facesContext), new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ "myFormId:myInputId: " + ERROR_MESSAGE,
+ "myFormId:myInputId: " + ERROR_MESSAGE));
+
+ // This is the label for our text field
+ //
+ HtmlOutputLabel label = new HtmlOutputLabel();
+ label.setValue(LABEL_TEXT);
+ label.setFor("myInputId");
+ form.getChildren().add(label);
+
+ // Render the HTML
+ //
+ message.setFor("myInputId");
+ message.encodeAll(facesContext);
+
+ MockResponseWriter writer = (MockResponseWriter) facesContext.getResponseWriter();
+ String resultingHtml = writer.getWriter().toString();
+
+ // Check that the full client id was properly replaced with the label text
+ //
+ assertTrue(("<span class=\"errorClass\">" + LABEL_TEXT + ": " + ERROR_MESSAGE + "</span>")
+ .equals(resultingHtml));
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMessagesRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMessagesRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMessagesRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlMessagesRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,95 @@
+/*
+ * 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.ext;
+
+import javax.faces.application.FacesMessage;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlMessages;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlMessagesRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private static final String ERROR_CLASS = "errorClass";
+ private static final String WARN_CLASS = "warnClass";
+ private static final String INFO_CLASS = "infoClass";
+
+ private HtmlMessages messages;
+
+ public HtmlMessagesRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlMessagesRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ messages = new HtmlMessages();
+ messages.setErrorClass(ERROR_CLASS);
+ messages.setWarnClass(WARN_CLASS);
+ messages.setInfoClass(INFO_CLASS);
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ messages = null;
+ }
+
+ 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"));
+
+ 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()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlRadioRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlRadioRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlRadioRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlRadioRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,109 @@
+/*
+ * 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.ext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.component.UISelectItems;
+import javax.faces.model.SelectItem;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlSelectOneRadio;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlRadioRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private HtmlSelectOneRadio selectOneRadio;
+
+ public HtmlRadioRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlRadioRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ selectOneRadio = new HtmlSelectOneRadio();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ selectOneRadio = null;
+ }
+
+ 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"));
+
+ UISelectItems selectItems = new UISelectItems();
+ selectItems.setValue(items);
+
+ selectOneRadio.getChildren().add(selectItems);
+
+ MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ selectOneRadio, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlSecretRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlSecretRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlSecretRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlSecretRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,91 @@
+/*
+ * 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.ext;
+
+import java.io.StringWriter;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlInputSecret;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockRenderKitFactory;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+
+public class HtmlSecretRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private MockResponseWriter writer ;
+ private HtmlInputSecret inputText;
+
+ public HtmlSecretRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlSecretRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ inputText = new HtmlInputSecret();
+
+ writer = new MockResponseWriter(new StringWriter(), null, null);
+ facesContext.setResponseWriter(writer);
+
+ facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
+ facesContext.getRenderKit().addRenderer(
+ inputText.getFamily(),
+ inputText.getRendererType(),
+ new HtmlSecretRenderer());
+
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ inputText = null;
+ writer = null;
+ }
+
+ public void testInputTextDefault() throws Exception
+ {
+ inputText.encodeEnd(facesContext);
+ facesContext.renderResponse();
+
+ String output = writer.getWriter().toString();
+ assertEquals("<input type=\"password\" name=\"j_id0\"/>", output);
+ }
+
+ public void testHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ inputText, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,86 @@
+/*
+ * 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.ext;
+
+import java.io.StringWriter;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlDataTable;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlTableRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private MockResponseWriter writer ;
+ private HtmlDataTable dataTable;
+
+ public HtmlTableRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(HtmlTableRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ dataTable = new HtmlDataTable();
+
+ writer = new MockResponseWriter(new StringWriter(), null, null);
+ facesContext.setResponseWriter(writer);
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ dataTable = null;
+ writer = null;
+ }
+
+ public void testHtmlPropertyPassTru() throws Exception
+ {
+ 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();
+
+ MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ dataTable, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTextRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTextRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTextRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTextRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,89 @@
+/*
+ * 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.ext;
+
+import java.io.IOException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlInputText;
+import org.apache.myfaces.component.html.ext.HtmlOutputText;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlTextRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private HtmlOutputText outputText;
+ private HtmlInputText inputText;
+
+ public static Test suite()
+ {
+ return new TestSuite(HtmlTextRendererTest.class);
+ }
+
+ public HtmlTextRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ outputText = new HtmlOutputText();
+ inputText = new HtmlInputText();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ outputText = null;
+ inputText = null;
+ }
+
+ public void testStyleClassAttr() throws IOException
+ {
+ outputText.setValue("Output");
+ outputText.setStyleClass("myStyleClass");
+
+ outputText.encodeEnd(facesContext);
+ facesContext.renderResponse();
+
+ MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+ String output = writer.getWriter().toString();
+
+ assertEquals("<span class=\"myStyleClass\">Output</span>", output);
+ assertNotSame("Output", output);
+ }
+
+ public void testHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+
+ MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ inputText, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,90 @@
+/*
+ * 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.ext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.component.html.ext.HtmlInputTextarea;
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
+import org.apache.myfaces.test.utils.HtmlRenderedAttr;
+
+public class HtmlTextareaRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+ private HtmlInputTextarea inputTextarea;
+
+ public HtmlTextareaRendererTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(HtmlTextareaRendererTest.class);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ inputTextarea = new HtmlInputTextarea();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ inputTextarea = null;
+ }
+
+ public void testRenderDefault() throws Exception
+ {
+ inputTextarea.encodeEnd(facesContext);
+ facesContext.renderResponse();
+
+ MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+ String output = writer.getWriter().toString();
+ assertEquals("<textarea name=\"j_id0\"></textarea>", output);
+ }
+
+ public void testRenderColsRows() throws Exception
+ {
+ inputTextarea.setCols(5);
+ inputTextarea.setRows(10);
+ inputTextarea.encodeEnd(facesContext);
+ facesContext.renderResponse();
+
+ MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+ String output = writer.getWriter().toString();
+ assertEquals("<textarea name=\"j_id0\" cols=\"5\" rows=\"10\"></textarea>", output);
+ }
+
+ public void testHtmlPropertyPassTru() throws Exception
+ {
+ HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+
+ MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+ HtmlCheckAttributesUtil.checkRenderedAttributes(
+ inputTextarea, facesContext, writer, attrs);
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+ }
+ }
+}
Copied: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/MockBean.java (from r957093, myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/TestBean.java)
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/MockBean.java?p2=myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/MockBean.java&p1=myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/TestBean.java&r1=957093&r2=963899&rev=963899&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/TestBean.java (original)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/MockBean.java Tue Jul 13 22:57:38 2010
@@ -27,7 +27,7 @@ import java.util.Collection;
* @author Jakob Korherr (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class TestBean
+public class MockBean
{
private Collection<Integer> values;
Copied: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/MockIntegerConverter.java (from r957093, myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/TestIntegerConverter.java)
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/MockIntegerConverter.java?p2=myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/MockIntegerConverter.java&p1=myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/TestIntegerConverter.java&r1=957093&r2=963899&rev=963899&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/TestIntegerConverter.java (original)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/renderkit/html/ext/MockIntegerConverter.java Tue Jul 13 22:57:38 2010
@@ -30,7 +30,7 @@ import javax.faces.convert.ConverterExce
* @author Jakob Korherr (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class TestIntegerConverter implements Converter
+public class MockIntegerConverter implements Converter
{
public Object getAsObject(FacesContext context, UIComponent component,