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 [2/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/component/html/ext/HtmlSelectOneMenuTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlSelectOneMenuTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlSelectOneMenuTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlSelectOneMenuTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.component.html.ext;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlForm;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.utils.TestUtils;
+
+public class HtmlSelectOneMenuTest extends AbstractTomahawkViewControllerTestCase
+{
+
+    public HtmlSelectOneMenuTest(String name)
+    {
+        super(name);
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * Verify component renders with the default renderer.
+     */
+    public void testDefaultRenderer()
+    {
+        // Define the component
+        UIComponent component = new HtmlSelectOneMenu();
+        component.setId("TestComponent");
+        component.setParent(new HtmlForm());
+
+        // Render the component
+        try
+        {
+            TestUtils.renderComponent(facesContext, component);
+        }
+        catch (IOException e)
+        {
+            fail(e.getMessage());
+        }
+
+        // Verify component was rendered
+        assertIdExists(component.getId());
+    }
+}

Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadioTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadioTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadioTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadioTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.component.html.ext;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlForm;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
+import org.apache.myfaces.test.utils.TestUtils;
+
+public class HtmlSelectOneRadioTest extends AbstractTomahawkViewControllerTestCase
+{
+
+    public HtmlSelectOneRadioTest(String name)
+    {
+        super(name);
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * Verify component renders with the default renderer.
+     */
+    public void testDefaultRenderer()
+    {
+        // Define the component
+        UIComponent component = new HtmlSelectOneRadio();
+        component.setId("TestComponent");
+        component.setParent(new HtmlForm());
+
+        // Render the component
+        try
+        {
+            TestUtils.renderComponent(facesContext, component);
+        }
+        catch (IOException e)
+        {
+            fail(e.getMessage());
+        }
+
+        // Verify component was rendered
+        assertIdExists(component.getId());
+    }
+}

Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/calendar/HtmlCalendarRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/calendar/HtmlCalendarRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/calendar/HtmlCalendarRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/calendar/HtmlCalendarRendererTest.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.custom.calendar;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+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 HtmlCalendarRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+    private HtmlInputCalendar inputCalendar;
+    
+    public HtmlCalendarRendererTest(String name)
+    {
+        super(name);
+    }
+    
+    public static Test suite() {
+        return new TestSuite(HtmlCalendarRendererTest.class);
+    }
+    
+    public void setUp() throws Exception {
+        super.setUp();
+        inputCalendar = new HtmlInputCalendar();
+        facesContext.getApplication().addComponent("org.apache.myfaces.HtmlInputTextHelp", "org.apache.myfaces.custom.inputTextHelp.HtmlInputTextHelp");
+    }
+    
+    public void tearDown() throws Exception {
+        super.tearDown();
+        inputCalendar = null;
+    }
+    
+    public void testRenderedAttributes() throws IOException {
+        System.out.println("Testing rendered attributes");
+        inputCalendar.setOnfocus("onfocusTest()");
+        inputCalendar.setOnmouseover("onMouseOverTest()");
+        inputCalendar.setRenderAsPopup(true);
+        
+        try {
+        inputCalendar.encodeEnd(facesContext);
+        } catch(FacesException fe) {
+            fe.printStackTrace();
+        }
+        facesContext.renderResponse();
+        System.out.println("---------------------------------------");
+        MockResponseWriter writer = (MockResponseWriter) facesContext.getResponseWriter();
+        System.out.println(writer.getWriter().toString());
+        System.out.println("\n---------------------------------------");
+    }
+    
+    public void testHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs(); 
+        
+        inputCalendar.setRenderAsPopup(true);
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                inputCalendar, 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/custom/datalist/HtmlListRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/datalist/HtmlListRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/datalist/HtmlListRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/datalist/HtmlListRendererTest.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.custom.datalist;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+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 HtmlListRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+    private HtmlDataList dataList;
+    
+    public HtmlListRendererTest(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(HtmlListRendererTest.class);
+    }
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        dataList = new HtmlDataList();
+        facesContext.getApplication().addComponent("org.apache.myfaces.HtmlDataList", "org.apache.myfaces.custom.datalist.HtmlDataList");        
+    }
+    
+    public void tearDown() throws Exception 
+    {
+        super.tearDown();
+        dataList = null;
+    }
+    
+    public void testHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+        
+        dataList.setLayout("simple");
+        
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                dataList, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) 
+        {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
+    }
+    
+    public void testHtmlPropertyPassTruNotRendered() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateAttrsNotRenderedForReadOnly();
+        
+        dataList.setLayout("simple");        
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                dataList, 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/custom/date/HtmlDateRenderCactus.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/HtmlDateRenderCactus.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/HtmlDateRenderCactus.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/HtmlDateRenderCactus.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,198 @@
+/*
+ * 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.custom.date;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.cactus.WebRequest;
+import org.apache.myfaces.custom.date.AbstractHtmlInputDate.UserData;
+
+public class HtmlDateRenderCactus extends ServletTestCase {
+  private FacesContext facesContext;
+  private UIViewRoot viewRoot;
+  
+  public void setUp() throws Exception {
+    FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
+        .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+    LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
+        .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+    Lifecycle lifecycle = lifecycleFactory
+        .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+    facesContext = facesContextFactory.getFacesContext(this.config
+        .getServletContext(), request, response, lifecycle);
+    assertNotNull(facesContext);
+    Application application = facesContext.getApplication();
+    ViewHandler viewHandler = application.getViewHandler();
+    String viewId = "/index.jsp";
+    viewRoot = viewHandler.createView(facesContext, viewId);
+    viewRoot.setViewId(viewId);
+    facesContext.setViewRoot(viewRoot);
+  }
+
+  public void beginDecodeDate(WebRequest request) {
+    request.addParameter("test.day", "14");
+    request.addParameter("test.month", "1");
+    request.addParameter("test.year", "2005");
+  }
+  
+  public void testDecodeDate() {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("date");
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("14", data.getDay());
+    assertEquals("1", data.getMonth());
+    assertEquals("2005", data.getYear());
+  }
+  
+  public void beginDecodeWithSubmittedValue(WebRequest request) {
+    request.addParameter("test.day", "14");
+    request.addParameter("test.month", "1");
+    request.addParameter("test.year", "2005");
+  }
+  
+  public void testDecodeWithSubmittedValue() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("date");
+    Date today = new Date();
+    inputDate.setSubmittedValue(new UserData(today, Locale.ENGLISH, null,false, "date"));
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("14", data.getDay());
+    assertEquals("1", data.getMonth());
+    assertEquals("2005", data.getYear());
+  }
+
+  public void beginDecodeTime(WebRequest request) {
+    request.addParameter("test.hours", "12");
+    request.addParameter("test.minutes", "15");
+    request.addParameter("test.seconds", "35");
+  }
+  public void testDecodeTime() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("time");
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("12", data.getHours());
+    assertEquals("15", data.getMinutes());
+    assertEquals("35", data.getSeconds());
+  }
+
+  public void beginDecodeFull(WebRequest request) {
+    request.addParameter("test.day", "14");
+    request.addParameter("test.month", "1");
+    request.addParameter("test.year", "2005");
+    request.addParameter("test.hours", "12");
+    request.addParameter("test.minutes", "15");
+    request.addParameter("test.seconds", "35");
+  }
+
+  public void testDecodeFull() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("full");
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("14", data.getDay());
+    assertEquals("1", data.getMonth());
+    assertEquals("2005", data.getYear());
+    assertEquals("12", data.getHours());
+    assertEquals("15", data.getMinutes());
+    assertEquals("35", data.getSeconds());
+  }
+
+  public void beginDecodeFlorp(WebRequest request) {
+    request.addParameter("test.day", "14");
+    request.addParameter("test.month", "1");
+    request.addParameter("test.year", "2005");
+    request.addParameter("test.hours", "12");
+    request.addParameter("test.minutes", "15");
+  }
+
+  public void testDecodeFlorp() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    // is this correct? Should it parse correctly if the type is not valid?
+    inputDate.setType("florp");
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("14", data.getDay());
+    assertEquals("1", data.getMonth());
+    assertEquals("2005", data.getYear());
+    assertEquals("12", data.getHours());
+    assertEquals("15", data.getMinutes());
+  }
+
+  public void beginDecodeDisabled(WebRequest request) {
+    request.addParameter("test.day", "14");
+    request.addParameter("test.month", "1");
+    request.addParameter("test.year", "2005");
+  }
+
+  public void testDecodeDisabled() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("date");
+    inputDate.setDisabled(true);
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // decode - when disabled currently defaults to today
+    // JIRA Issue #233 requests that the default be null
+    // and the control handle data that is not required
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    Calendar cal = GregorianCalendar.getInstance();
+    assertEquals(cal.get(Calendar.DATE) + "", data.getDay());
+    // different bases - cal starts at 0 in January, UserData starts at 1 in
+    // January
+    assertEquals((cal.get(Calendar.MONTH) + 1) + "", data.getMonth());
+    assertEquals(cal.get(Calendar.YEAR) + "", data.getYear());
+  }
+
+  public void tearDown() {
+    facesContext = null;
+    viewRoot = null;
+  }
+}

Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/HtmlDateRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/HtmlDateRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/HtmlDateRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/HtmlDateRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,537 @@
+/*
+ * 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.custom.date;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.faces.FactoryFinder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.render.RenderKitFactory;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.application.ApplicationFactoryImpl;
+import org.apache.myfaces.custom.date.AbstractHtmlInputDate.UserData;
+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;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
+
+public class HtmlDateRendererTest extends AbstractTomahawkViewControllerTestCase {
+//  public static void main(String[] args) {
+//    junit.textui.TestRunner.run(HtmlDateRendererTest.class);
+//  }
+   
+  public HtmlDateRendererTest(String name) {
+    super(name);
+  }
+  
+  public static Test suite() {
+      return new TestSuite(HtmlDateRendererTest.class);
+  }
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
+        MockHtmlDateRendererTestRenderKitFactory.class.getName());
+    FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
+        ApplicationFactoryImpl.class.getName());
+  }
+
+  protected void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  /*
+   * Test method for
+   * 'org.apache.myfaces.custom.date.HtmlDateRenderer.decode(FacesContext,
+   * UIComponent)'
+   */
+  public void testDecodeDate() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("date");
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // setup the request map
+    Map map = new HashMap();
+    map.put("test.day", "14");
+    map.put("test.month", "1");
+    map.put("test.year", "2005");
+    FacesContext facesContext = mockupForDecodeCall(map);
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("14", data.getDay());
+    assertEquals("1", data.getMonth());
+    assertEquals("2005", data.getYear());
+  }
+
+  public void testDecodeWithSubmittedValue() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("date");
+    Date today = new Date();
+    inputDate.setSubmittedValue(new UserData(today, Locale.ENGLISH, null, true, "date"));
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // setup the request map
+    Map map = new HashMap();
+    map.put("test.day", "14");
+    map.put("test.month", "1");
+    map.put("test.year", "2005");
+    FacesContext facesContext = mockupForDecodeCall(map);
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("14", data.getDay());
+    assertEquals("1", data.getMonth());
+    assertEquals("2005", data.getYear());
+  }
+
+  public void testDecodeTime() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("time");
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // setup the request map
+    Map map = new HashMap();
+    map.put("test.hours", "12");
+    map.put("test.minutes", "15");
+    map.put("test.seconds", "35");
+    FacesContext facesContext = mockupForDecodeCall(map);
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("12", data.getHours());
+    assertEquals("15", data.getMinutes());
+    assertEquals("35", data.getSeconds());
+  }
+
+  public void testDecodeFull() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("full");
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // setup the request map
+    Map map = new HashMap();
+    map.put("test.day", "14");
+    map.put("test.month", "1");
+    map.put("test.year", "2005");
+    map.put("test.hours", "12");
+    map.put("test.minutes", "15");
+    map.put("test.seconds", "3");
+    FacesContext facesContext = mockupForDecodeCall(map);
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("14", data.getDay());
+    assertEquals("1", data.getMonth());
+    assertEquals("2005", data.getYear());
+    assertEquals("12", data.getHours());
+    assertEquals("15", data.getMinutes());
+    assertEquals("03", data.getSeconds());
+  }
+
+  public void testDecodeFlorp() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    // is this correct? Should it parse correctly if the type is not valid?
+    inputDate.setType("florp");
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // setup the request map
+    Map map = new HashMap();
+    map.put("test.day", "14");
+    map.put("test.month", "1");
+    map.put("test.year", "2005");
+    map.put("test.hours", "12");
+    map.put("test.minutes", "15");
+    FacesContext facesContext = mockupForDecodeCall(map);
+    // decode
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    assertEquals("14", data.getDay());
+    assertEquals("1", data.getMonth());
+    assertEquals("2005", data.getYear());
+    assertEquals("12", data.getHours());
+    assertEquals("15", data.getMinutes());
+  }
+
+  public void testDecodeDisabled() throws Exception {
+    HtmlInputDate inputDate = new HtmlInputDate();
+    inputDate.setId("test");
+    inputDate.setType("date");
+    inputDate.setDisabled(true);
+    HtmlDateRenderer subject = new HtmlDateRenderer();
+    // setup the request map
+    Map map = new HashMap();
+    map.put("test.day", "14");
+    map.put("test.month", "1");
+    map.put("test.year", "2005");
+    FacesContext facesContext = mockupForDecodeCall(map);
+    // decode - when disabled currently defaults to today
+    // JIRA Issue #233 requests that the default be null
+    // and the control handle data that is not required
+    subject.decode(facesContext, inputDate);
+    UserData data = inputDate.getUserData(Locale.ENGLISH);
+    Calendar cal = GregorianCalendar.getInstance();
+    assertEquals(cal.get(Calendar.DATE) + "", data.getDay());
+    // different bases - cal starts at 0 in January, UserData starts at 1 in
+    // January
+    assertEquals((cal.get(Calendar.MONTH) + 1) + "", data.getMonth());
+    assertEquals(cal.get(Calendar.YEAR) + "", data.getYear());
+  }
+
+  public static class DateTestConverter implements Converter
+  {
+
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String submittedValue)
+            throws ConverterException
+    {
+        HtmlInputDate inputDate = (HtmlInputDate) uiComponent;
+        String type = inputDate.getType();
+        Properties props = new Properties();
+        try
+        {
+            props.load(new ByteArrayInputStream(submittedValue.getBytes()));
+        }catch(IOException e)
+        {
+        }
+        UserData userData = inputDate.getUserData(facesContext.getViewRoot().getLocale());
+        if( ! (type.equals( "time" ) || type.equals( "short_time" )) )
+        {
+            userData.setYear(props.getProperty("year"));
+            userData.setMonth(props.getProperty("month"));
+            userData.setDay(props.getProperty("day"));
+        }
+        
+        if( ! type.equals( "date" ) ){
+            userData.setHours(props.getProperty("hours"));
+            userData.setMinutes(props.getProperty("minutes"));
+            if (type.equals("full") || type.equals("time"))
+            {
+                userData.setSeconds(props.getProperty("seconds"));
+            }
+            if (inputDate.isAmpm()) {
+                userData.setAmpm(props.getProperty("ampm"));
+            }
+        }
+        try {
+            return userData.parse();
+        } catch (ParseException e) {
+            Object[] args = {uiComponent.getId()};
+            throw new ConverterException("Error Parsing");
+        }  
+    }
+
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object submitValue)
+            throws ConverterException
+    {
+        HtmlInputDate inputDate = (HtmlInputDate) uiComponent;
+        String type = inputDate.getType();
+        UserData value = new UserData((Date) submitValue, 
+                facesContext.getViewRoot().getLocale(), 
+                inputDate.getTimeZone(), inputDate.isAmpm(), inputDate.getType());        
+        
+        StringBuffer submittedValue = new StringBuffer();
+        if( ! (type.equals( "time" ) || type.equals( "short_time" )) )
+        {
+            submittedValue.append("year=");
+            submittedValue.append((String) value.getYear() );
+            submittedValue.append("\n");
+
+            submittedValue.append("month=");
+            submittedValue.append((String) value.getMonth());
+            submittedValue.append("\n");
+            
+            submittedValue.append("day=");
+            submittedValue.append((String) value.getDay() );
+            submittedValue.append("\n");                
+        }
+        
+        if( ! type.equals( "date" ) )
+        {
+            submittedValue.append("hours=");
+            submittedValue.append((String) value.getHours() );
+            submittedValue.append("\n");
+            
+            submittedValue.append("minutes=");
+            submittedValue.append((String) value.getMinutes() );
+            submittedValue.append("\n");
+
+            if (type.equals("full") || type.equals("time"))
+            {
+                submittedValue.append("seconds=");
+                submittedValue.append((String) value.getSeconds() );
+                submittedValue.append("\n");                    
+            }
+            
+            if (inputDate.isAmpm())
+            {
+                submittedValue.append("ampm=");
+                submittedValue.append((String) value.getAmpm() );
+                submittedValue.append("\n");
+            }
+        }
+        if (submittedValue.charAt(submittedValue.length()-1) == '\n' )
+        {
+            submittedValue.deleteCharAt(submittedValue.length()-1);
+        }
+        
+        return submittedValue.toString();
+    }
+      
+  }
+  
+  public void testDecodeConverterDate() throws Exception {
+      HtmlInputDate inputDate = new HtmlInputDate();
+      inputDate.setId("test");
+      inputDate.setType("date");
+      inputDate.setConverter(new DateTestConverter());
+      HtmlDateRenderer subject = new HtmlDateRenderer();
+      // setup the request map
+      Map map = new HashMap();
+      map.put("test.day", "14");
+      map.put("test.month", "1");
+      map.put("test.year", "2005");
+      FacesContext facesContext = mockupForDecodeCall(map);
+      // decode
+      subject.decode(facesContext, inputDate);
+      //With converter, the submitted value is a String
+      assertTrue(inputDate.getSubmittedValue() instanceof String);
+      // converter
+      inputDate.validate(facesContext);
+      
+      UserData data = inputDate.getUserData(Locale.ENGLISH);
+      assertEquals("14", data.getDay());
+      assertEquals("1", data.getMonth());
+      assertEquals("2005", data.getYear());
+    }
+  
+  public void testDecodeConverterWithSubmittedValue() throws Exception {
+      HtmlInputDate inputDate = new HtmlInputDate();
+      inputDate.setId("test");
+      inputDate.setType("date");
+      inputDate.setConverter(new DateTestConverter());
+      Date today = new Date();
+      inputDate.setSubmittedValue(new UserData(today, Locale.ENGLISH, null, true, "date"));
+      HtmlDateRenderer subject = new HtmlDateRenderer();
+      // setup the request map
+      Map map = new HashMap();
+      map.put("test.day", "14");
+      map.put("test.month", "1");
+      map.put("test.year", "2005");
+      FacesContext facesContext = mockupForDecodeCall(map);
+      // decode
+      subject.decode(facesContext, inputDate);
+      //With converter, the submitted value is a String
+      assertTrue(inputDate.getSubmittedValue() instanceof String);
+      // converter
+      inputDate.validate(facesContext);
+      
+      UserData data = inputDate.getUserData(Locale.ENGLISH);
+      assertEquals("14", data.getDay());
+      assertEquals("1", data.getMonth());
+      assertEquals("2005", data.getYear());
+    }
+  
+  public void testDecodeConverterTime() throws Exception {
+      HtmlInputDate inputDate = new HtmlInputDate();
+      inputDate.setId("test");
+      inputDate.setType("time");
+      HtmlDateRenderer subject = new HtmlDateRenderer();
+      // setup the request map
+      Map map = new HashMap();
+      map.put("test.hours", "12");
+      map.put("test.minutes", "15");
+      map.put("test.seconds", "35");
+      FacesContext facesContext = mockupForDecodeCall(map);
+      // decode
+      subject.decode(facesContext, inputDate);
+      //With converter, the submitted value is a String
+      assertTrue(inputDate.getSubmittedValue() instanceof String);
+      // converter
+      inputDate.validate(facesContext);
+      
+      UserData data = inputDate.getUserData(Locale.ENGLISH);
+      assertEquals("12", data.getHours());
+      assertEquals("15", data.getMinutes());
+      assertEquals("35", data.getSeconds());
+    }
+
+  public void testDecodeConverterFull() throws Exception {
+      HtmlInputDate inputDate = new HtmlInputDate();
+      inputDate.setId("test");
+      inputDate.setType("full");
+      HtmlDateRenderer subject = new HtmlDateRenderer();
+      // setup the request map
+      Map map = new HashMap();
+      map.put("test.day", "14");
+      map.put("test.month", "1");
+      map.put("test.year", "2005");
+      map.put("test.hours", "12");
+      map.put("test.minutes", "15");
+      map.put("test.seconds", "3");
+      FacesContext facesContext = mockupForDecodeCall(map);
+      // decode
+      subject.decode(facesContext, inputDate);
+      //With converter, the submitted value is a String
+      assertTrue(inputDate.getSubmittedValue() instanceof String);
+      // converter
+      inputDate.validate(facesContext);
+      UserData data = inputDate.getUserData(Locale.ENGLISH);
+      assertEquals("14", data.getDay());
+      assertEquals("1", data.getMonth());
+      assertEquals("2005", data.getYear());
+      assertEquals("12", data.getHours());
+      assertEquals("15", data.getMinutes());
+      assertEquals("03", data.getSeconds());
+    }
+
+    public void testDecodeConverterFlorp() throws Exception {
+      HtmlInputDate inputDate = new HtmlInputDate();
+      inputDate.setId("test");
+      // is this correct? Should it parse correctly if the type is not valid?
+      inputDate.setType("florp");
+      HtmlDateRenderer subject = new HtmlDateRenderer();
+      // setup the request map
+      Map map = new HashMap();
+      map.put("test.day", "14");
+      map.put("test.month", "1");
+      map.put("test.year", "2005");
+      map.put("test.hours", "12");
+      map.put("test.minutes", "15");
+      FacesContext facesContext = mockupForDecodeCall(map);
+      // decode
+      subject.decode(facesContext, inputDate);
+      //With converter, the submitted value is a String
+      assertTrue(inputDate.getSubmittedValue() instanceof String);
+      // converter
+      inputDate.validate(facesContext);
+      UserData data = inputDate.getUserData(Locale.ENGLISH);
+      assertEquals("14", data.getDay());
+      assertEquals("1", data.getMonth());
+      assertEquals("2005", data.getYear());
+      assertEquals("12", data.getHours());
+      assertEquals("15", data.getMinutes());
+    }
+
+  /*
+   * Test method for
+   * 'org.apache.myfaces.custom.date.HtmlDateRenderer.encodeEnd(FacesContext,
+   * UIComponent)'
+   */
+  public void testEncodeEnd() throws Exception {
+    
+  }
+
+  /*
+   * Test method for
+   * 'org.apache.myfaces.custom.date.HtmlDateRenderer.getConvertedValue(FacesContext,
+   * UIComponent, Object)'
+   */
+  public void testGetConvertedValue() throws Exception {
+  }
+
+  private FacesContext mockupForDecodeCall(Map requestParameterMap) {
+    // mock FacesContext
+    MockControl contextControl = MockClassControl
+        .createControl(FacesContext.class);
+    FacesContext facesContext = (FacesContext) contextControl.getMock();
+    // mock UIViewRoot
+    MockControl viewControl = MockClassControl.createControl(UIViewRoot.class);
+    UIViewRoot viewRoot = (UIViewRoot) viewControl.getMock();
+    // mock ExternalContext
+    MockControl externalContextControl = MockClassControl
+        .createControl(ExternalContext.class);
+    ExternalContext externalContext = (ExternalContext) externalContextControl
+        .getMock();
+    // set the view root
+    facesContext.getViewRoot();
+    contextControl.setReturnValue(viewRoot);
+    // called twice
+    facesContext.getViewRoot();
+    contextControl.setReturnValue(viewRoot);
+    // set the external context
+    facesContext.getExternalContext();
+    contextControl.setReturnValue(externalContext);
+    // set the locale
+    viewRoot.getLocale();
+    viewControl.setReturnValue(Locale.ENGLISH);
+    // set the render kit id
+    viewRoot.getRenderKitId();
+    viewControl.setReturnValue(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+    externalContext.getRequestParameterMap();
+    externalContextControl.setReturnValue(requestParameterMap);
+    // prepare
+    contextControl.replay();
+    viewControl.replay();
+    externalContextControl.replay();
+    return facesContext;
+  }
+
+  public void testHtmlPropertyPassTru() throws Exception
+  {
+      HtmlInputDate inputDate = new HtmlInputDate();
+      
+      HtmlRenderedAttr[] attrs = {
+          //_UniversalProperties
+          new HtmlRenderedAttr("dir", 3), 
+          new HtmlRenderedAttr("lang", 3), 
+          new HtmlRenderedAttr("title", 3),
+          //_EventProperties 
+          new HtmlRenderedAttr("ondblclick", 3), 
+          new HtmlRenderedAttr("onkeydown", 3), 
+          new HtmlRenderedAttr("onkeypress", 3),
+          new HtmlRenderedAttr("onkeyup", 3), 
+          new HtmlRenderedAttr("onmousedown", 3), 
+          new HtmlRenderedAttr("onmousemove", 3), 
+          new HtmlRenderedAttr("onmouseout", 3),
+          new HtmlRenderedAttr("onmouseover", 3), 
+          new HtmlRenderedAttr("onmouseup", 3),
+          //_StyleProperties
+          new HtmlRenderedAttr("style", 3), 
+          new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\"", 3),
+      };
+      
+      
+      MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+      HtmlCheckAttributesUtil.checkRenderedAttributes(
+              inputDate, 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/custom/date/MockBean.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockBean.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockBean.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockBean.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,39 @@
+/*
+ * 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.custom.date;
+
+import java.util.Date;
+
+public class MockBean {
+  private Date date;
+
+  public MockBean() {
+    super();
+  }
+
+  public Date getDate() {
+    return date;
+  }
+
+  public void setDate(Date date) {
+    this.date = date;
+  }
+
+}

Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKit.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKit.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKit.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKit.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,71 @@
+/*
+ * 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.custom.date;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import javax.faces.render.Renderer;
+import javax.faces.render.ResponseStateManager;
+
+public class MockHtmlDateRendererTestRenderKit extends RenderKit {
+  private Map renderers = new HashMap();
+  
+  public MockHtmlDateRendererTestRenderKit() {
+    addRenderer("javax.faces.Input", "org.apache.myfaces.Date", new HtmlDateRenderer());
+  }
+  
+  public void addRenderer(String family, String rendererType, Renderer renderer) {
+    Map sub = (Map)renderers.get(family);
+    if(null == sub) {
+      sub = new HashMap();
+      renderers.put(family, sub);
+    }
+    sub.put(rendererType, renderer);
+  }
+
+  public Renderer getRenderer(String family, String rendererType) {
+    Renderer renderer = null;
+    Map sub = (Map)renderers.get(family);
+    if(null != sub) {
+      renderer = (Renderer)sub.get(rendererType);
+    }
+    return renderer;
+  }
+
+  public ResponseStateManager getResponseStateManager() {
+    return null;
+  }
+
+  public ResponseWriter createResponseWriter(Writer writer,
+      String contentTypeList, String characterEncoding) {
+    return null;
+  }
+
+  public ResponseStream createResponseStream(OutputStream out) {
+    return null;
+  }
+
+}

Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKitFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKitFactory.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKitFactory.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/MockHtmlDateRendererTestRenderKitFactory.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.custom.date;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+public class MockHtmlDateRendererTestRenderKitFactory extends RenderKitFactory {
+  private Map renderKits = new HashMap();
+
+  public MockHtmlDateRendererTestRenderKitFactory() {
+    addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, new MockHtmlDateRendererTestRenderKit());
+  }
+  
+  public void addRenderKit(String renderKitId, RenderKit renderKit) {
+    renderKits.put(renderKitId, renderKit);
+  }
+
+  public RenderKit getRenderKit(FacesContext context, String renderKitId) {
+    return (RenderKit)renderKits.get(renderKitId);
+  }
+
+  public Iterator getRenderKitIds() {
+    List ids = new ArrayList();
+    ids.add(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+    return ids.iterator();
+  }
+
+}

Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/date/UserDataTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,215 @@
+package org.apache.myfaces.custom.date;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.TimeZone;
+import java.util.Date;
+import java.util.Locale;
+
+import org.apache.myfaces.custom.date.AbstractHtmlInputDate.UserData;
+
+import junit.framework.TestCase;
+
+public class UserDataTest extends TestCase {
+    
+    private UserData userData;
+    
+    private String getDefaultTimeZoneId() {
+        return TimeZone.getDefault().getID();
+    }
+    
+    public void testConstructorDoesNotSetDateVariablesWhenTheDateIsNull() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId() , false, "date");
+        assertNull(userData.getYear());
+        assertNull(userData.getDay());
+        assertNull(userData.getHours());
+    }
+    
+    public void testParseReturnsNullWhenTypeIsDateAndComponentNotUsed() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), false, "date");
+        userData.setDay("");
+        userData.setMonth("-1");
+        userData.setYear("");
+        try {
+            Date date = userData.parse();
+            assertNull(date);
+        } catch (ParseException e) {
+            fail();
+        }
+    }
+    
+    public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeDate() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), false, "date");
+        userData.setDay("40");
+        userData.setMonth("-1");
+        userData.setYear("2005");
+        try {
+            userData.parse();
+            fail();
+        } catch (ParseException e) {
+        }
+    }
+    
+    public void testParseGivesCorrectDateWhenValidDataIsEnteredForTypeDate() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), false, "date");
+        userData.setDay("20");
+        userData.setMonth("7");
+        userData.setYear("2006");
+        
+        Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
+        calendar.set(Calendar.DAY_OF_MONTH, 20);
+        calendar.set(Calendar.MONTH, 6);
+        calendar.set(Calendar.YEAR, 2006);
+        
+        //only day, month and year is considered for equality
+        SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");        
+        try {
+            Date date1 = userData.parse();
+            Date date2 = calendar.getTime();
+            assertEquals(formatter.format(date1), formatter.format(date2));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public void testParseReturnsNullWhenTypeIsTimeAndComponentNotUsed() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), false, "time");
+        userData.setHours("");
+        userData.setMinutes("");
+        userData.setSeconds("");
+        
+        try {
+            assertNull(userData.parse());
+        } catch (ParseException e) {
+            fail();
+        }
+    }
+    
+    public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeTime() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), false, "time");
+        userData.setHours("25");
+        userData.setMinutes("");
+        userData.setSeconds("10");
+        
+        try {
+            userData.parse();
+            fail();
+        } catch (ParseException e) {
+        }
+    }
+    
+    public void testParseGivesCorrectDateWhenValidDataIsEnteredForTypeTime() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), false, "time");
+        userData.setHours("10");
+        userData.setMinutes("50");
+        userData.setSeconds("30");
+        
+        Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
+        calendar.set(Calendar.HOUR_OF_DAY, 10);
+        calendar.set(Calendar.MINUTE, 50);
+        calendar.set(Calendar.SECOND, 30);
+        
+        //hour, minute, seconds is considered for equality
+        SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss");        
+        try {
+            Date date1 = userData.parse();
+            Date date2 = calendar.getTime();
+            assertEquals(formatter.format(date1), formatter.format(date2));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public void testParseReturnsNullWhenTypeIsFullAndComponentNotUsed() {
+        userData = new UserData(null, Locale.ENGLISH, "GMT+2:00", true, "full");
+        userData.setDay("");
+        userData.setMonth("-1");
+        userData.setYear("");
+        userData.setHours("");
+        userData.setMinutes("");
+        userData.setSeconds("");
+        userData.setAmpm("-1");
+        
+        try {
+            assertNull(userData.parse());
+        } catch (ParseException e) {
+            fail();
+        }
+    }
+    
+    public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase1() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), true, "full");
+        //date is used, time is not
+        userData.setDay("40");
+        userData.setMonth("-1");
+        userData.setYear("");
+        userData.setHours("");
+        userData.setMinutes("");
+        userData.setSeconds("");
+        userData.setAmpm("-1");
+        
+        try {
+            userData.parse();
+            fail();
+        } catch (ParseException e) {
+        }
+    }
+    
+    public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase2() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), true, "full");
+        //date is used time is not
+        userData.setDay("");
+        userData.setMonth("0");
+        userData.setYear("2005");
+        userData.setHours("");
+        userData.setMinutes("");
+        userData.setSeconds("");
+        userData.setAmpm("-1");
+        
+        try {
+            userData.parse();
+            fail();
+        } catch (ParseException e) {
+        }
+    }
+    
+    public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase3() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), true, "full");
+        //date is used time is not
+        userData.setDay("5");
+        userData.setMonth("10");
+        userData.setYear("2005");
+        userData.setHours("");
+        userData.setMinutes("");
+        userData.setSeconds("");
+        userData.setAmpm("-1");
+        
+        try {
+            userData.parse();
+            fail();
+        } catch (ParseException e) {
+        }
+    }
+    
+    public void testParseThrowsParseExceptionWhenInvalidDataIsEnteredForTypeFullCase4() {
+        userData = new UserData(null, Locale.getDefault(), getDefaultTimeZoneId(), true, "full");
+        //date is not used but time is
+        userData.setDay("");
+        userData.setMonth("-1");
+        userData.setYear("");
+        userData.setHours("");
+        userData.setMinutes("30");
+        userData.setSeconds("");
+        userData.setAmpm("-1");
+        
+        try {
+            userData.parse();
+            fail();
+        } catch (ParseException e) {
+        }
+    }
+    
+    
+
+}

Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/div/DivRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/div/DivRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/div/DivRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/div/DivRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,79 @@
+/*
+ * 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.custom.div;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+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 DivRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+    private Div div;
+    
+    public DivRendererTest(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(DivRendererTest.class);
+    }
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        div = new Div();
+    }
+    
+    public void tearDown() throws Exception 
+    {
+        super.tearDown();
+        div = null;
+    }
+    
+    public void testHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                div, 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(
+                div, 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/custom/fileupload/HtmlFileUploadRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/fileupload/HtmlFileUploadRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/fileupload/HtmlFileUploadRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/fileupload/HtmlFileUploadRendererTest.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.custom.fileupload;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItem;
+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;
+import org.easymock.MockControl;
+
+public class HtmlFileUploadRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+    private HtmlInputFileUpload fileUpload; 
+
+    public HtmlFileUploadRendererTest(String name)
+    {
+        super(name);
+    }
+    
+    public static Test suite() 
+    {
+        return new TestSuite(HtmlFileUploadRendererTest.class);
+    }
+
+    
+ 
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        fileUpload = new HtmlInputFileUpload();       
+    }
+    
+    public void tearDown() throws Exception 
+    {
+        super.tearDown();
+        fileUpload = null;
+    }
+    
+    public void testHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicAttrs();
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                fileUpload, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
+    }
+    
+    public void testUploadedFileDefaultFileImplSerializable() throws Exception
+    {
+        String fieldName = "inputFile";
+        String contentType = "someType";
+        boolean isFormField = true;
+        String fileName = "tempFile";
+        int sizeThreshold = 10000;
+        File repository = new File(System.getProperty("java.io.tmpdir"));
+        DiskFileItem item = new DiskFileItem(fieldName, contentType, isFormField, fileName, sizeThreshold, repository);
+
+        UploadedFileDefaultFileImpl original = new UploadedFileDefaultFileImpl(item);
+        
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(out);
+        oos.writeObject(original);
+        oos.close();
+
+        byte[] serializedArray = out.toByteArray();
+        InputStream in = new ByteArrayInputStream(serializedArray);
+        ObjectInputStream ois = new ObjectInputStream(in);
+        UploadedFileDefaultFileImpl copy = (UploadedFileDefaultFileImpl) ois.readObject();
+        
+        assertEquals(original.getName(), copy.getName());
+        assertEquals(original.getContentType(), copy.getContentType());
+        assertEquals(copy.getSize(),0);
+        
+        copy.getStorageStrategy().deleteFileContents();
+    }
+    
+    public void testUploadedFileDefaultMemoryImplSerializable() throws Exception
+    {
+        String fieldName = "inputFile";
+        String contentType = "someType";
+        
+        MockControl control = MockControl.createControl(FileItem.class);
+        FileItem item = (FileItem) control.getMock();
+        
+        item.getName();
+        control.setReturnValue(fieldName,1);
+        item.getContentType();
+        control.setReturnValue(contentType,1);
+        item.getSize();
+        control.setReturnValue(0,1);
+        item.getInputStream();
+        control.setReturnValue(new InputStream()
+        {
+            public int read() throws IOException
+            {
+                return -1;
+            }
+        },1);
+
+        item.delete();
+        control.setVoidCallable(1);
+        
+        control.replay();
+        
+        UploadedFileDefaultMemoryImpl original = new UploadedFileDefaultMemoryImpl(item);
+        
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(out);
+        oos.writeObject(original);
+        oos.close();
+
+        byte[] serializedArray = out.toByteArray();
+        InputStream in = new ByteArrayInputStream(serializedArray);
+        ObjectInputStream ois = new ObjectInputStream(in);
+        UploadedFileDefaultMemoryImpl copy = (UploadedFileDefaultMemoryImpl) ois.readObject();
+        
+        assertEquals(original.getName(), copy.getName());
+        assertEquals(original.getContentType(), copy.getContentType());
+        assertEquals(copy.getSize(),0);
+        
+        copy.getStorageStrategy().deleteFileContents();
+    }
+
+}

Added: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/htmltag/HtmlTagRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/htmltag/HtmlTagRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/htmltag/HtmlTagRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/htmltag/HtmlTagRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,73 @@
+/*
+ * 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.custom.htmltag;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.custom.htmlTag.HtmlTag;
+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 HtmlTagRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+    private HtmlTag tag;
+
+    public HtmlTagRendererTest(String name)
+    {
+        super(name);
+    }
+    
+    public static Test suite() 
+    {
+        return new TestSuite(HtmlTagRendererTest.class);
+    }
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        tag = new HtmlTag();        
+    }
+    
+    public void tearDown() throws Exception 
+    {
+        super.tearDown();
+        tag = null;
+    }
+    
+    public void testHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = {
+            //_StyleProperties
+            new HtmlRenderedAttr("style"), 
+            new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\""),
+        };
+        
+        tag.setValue("div");
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                tag, 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/custom/inputTextHelp/HtmlTextHelpRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/inputTextHelp/HtmlTextHelpRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,134 @@
+/*
+ * 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.custom.inputTextHelp;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+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 HtmlTextHelpRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+    private MockResponseWriter writer;
+    private HtmlInputTextHelp inputHelp;
+    
+    public HtmlTextHelpRendererTest(String name)
+    {
+        super(name);
+    }
+    
+    public static Test suite() {
+        return new TestSuite(HtmlTextHelpRendererTest.class);
+    }
+    
+    public void setUp() throws Exception {
+        super.setUp();
+        writer = (MockResponseWriter)facesContext.getResponseWriter();
+        inputHelp = new HtmlInputTextHelp();
+    }
+    
+    public void tearDown() {
+        writer = null;
+        inputHelp = null;
+    }    
+
+    public void testSelectTextHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = {
+            //_AccesskeyProperty
+            new HtmlRenderedAttr("accesskey"),
+            //_UniversalProperties
+            new HtmlRenderedAttr("dir"), 
+            new HtmlRenderedAttr("lang"), 
+            new HtmlRenderedAttr("title"),
+            //_FocusBlurProperties
+            new HtmlRenderedAttr("onfocus", "onfocus", "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")
+        };
+        inputHelp.setSelectText(true);
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                inputHelp, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
+    }    
+    
+    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", "onfocus", "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")
+        };
+
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                inputHelp, 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/custom/layout/HtmlLayoutRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/layout/HtmlLayoutRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/layout/HtmlLayoutRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/layout/HtmlLayoutRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,77 @@
+/*
+ * 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.custom.layout;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+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 HtmlLayoutRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+    private HtmlPanelLayout layout;
+    
+    public HtmlLayoutRendererTest(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(HtmlLayoutRendererTest.class);
+    }
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        layout = new HtmlPanelLayout();        
+    }
+    
+    public void tearDown() throws Exception 
+    {
+        super.tearDown();
+        layout = null;
+    }
+    
+    public void testHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                layout, 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(
+                layout, 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/custom/navigation/HtmlNavigationRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/navigation/HtmlNavigationRendererTest.java?rev=963899&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/navigation/HtmlNavigationRendererTest.java (added)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/custom/navigation/HtmlNavigationRendererTest.java Tue Jul 13 22:57:38 2010
@@ -0,0 +1,83 @@
+/*
+ * 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.custom.navigation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.custom.navmenu.UINavigationMenuItem;
+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 HtmlNavigationRendererTest extends AbstractTomahawkViewControllerTestCase
+{
+    private HtmlPanelNavigation navigation;
+    
+    
+    public HtmlNavigationRendererTest(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(HtmlNavigationRendererTest.class);
+    }
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        navigation = new HtmlPanelNavigation();
+        UINavigationMenuItem menuItem = new UINavigationMenuItem();
+        navigation.getChildren().add(menuItem);
+    }
+    
+    public void tearDown() throws Exception 
+    {
+        super.tearDown();
+        navigation = null;
+    }
+    
+    public void testHtmlPropertyPassTru() throws Exception
+    {
+        HtmlRenderedAttr[] attrs = HtmlCheckAttributesUtil.generateBasicReadOnlyAttrs();
+        
+        MockResponseWriter writer = (MockResponseWriter)facesContext.getResponseWriter();
+        HtmlCheckAttributesUtil.checkRenderedAttributes(
+                navigation, 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(
+                navigation, facesContext, writer, attrs);
+        if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) 
+        {
+            fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
+        }
+    }
+}