1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.custom.inputAjax;
20  
21  import junit.framework.Test;
22  import junit.framework.TestSuite;
23  
24  
25  import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
26  import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
27  import org.apache.myfaces.test.utils.HtmlRenderedAttr;
28  import org.apache.shale.test.mock.MockResponseWriter;
29  
30  public class HtmlSelectBooleanCheckboxAjaxRendererTest extends AbstractTomahawkViewControllerTestCase
31  {
32      private MockResponseWriter writer ;
33      private HtmlSelectBooleanCheckboxAjax selectBooleanCheckbox;
34  
35      public HtmlSelectBooleanCheckboxAjaxRendererTest(String name)
36      {
37          super(name);
38      }
39      
40      public static Test suite() {
41          return new TestSuite(HtmlSelectBooleanCheckboxAjaxRendererTest.class);
42      }
43  
44      public void setUp() throws Exception
45      {
46          super.setUp();
47  
48          selectBooleanCheckbox = new HtmlSelectBooleanCheckboxAjax();
49  
50          writer = (MockResponseWriter)facesContext.getResponseWriter();
51      }
52  
53      public void tearDown() throws Exception
54      {
55          super.tearDown();
56          selectBooleanCheckbox = null;
57          writer = null;
58      }
59      
60      public void testSelectBooleanHtmlPropertyPasstru() throws Exception 
61      {
62          HtmlRenderedAttr[] attrs = {
63              //_AccesskeyProperty
64              new HtmlRenderedAttr("accesskey"),
65              //_UniversalProperties
66              new HtmlRenderedAttr("dir"), 
67              new HtmlRenderedAttr("lang"), 
68              new HtmlRenderedAttr("title"),
69              //_FocusBlurProperties
70              new HtmlRenderedAttr("onfocus"), 
71              new HtmlRenderedAttr("onblur"),
72              //_ChangeSelectProperties
73              new HtmlRenderedAttr("onchange"), 
74              new HtmlRenderedAttr("onselect"),
75              //_EventProperties
76              new HtmlRenderedAttr("onclick", "onclick", "onclick=\""), 
77              new HtmlRenderedAttr("ondblclick"), 
78              new HtmlRenderedAttr("onkeydown"), 
79              new HtmlRenderedAttr("onkeypress"),
80              new HtmlRenderedAttr("onkeyup"), 
81              new HtmlRenderedAttr("onmousedown"), 
82              new HtmlRenderedAttr("onmousemove"), 
83              new HtmlRenderedAttr("onmouseout"),
84              new HtmlRenderedAttr("onmouseover"), 
85              new HtmlRenderedAttr("onmouseup"),
86              //_StyleProperties
87              new HtmlRenderedAttr("style"), 
88              new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\""),
89              //_TabindexProperty
90              new HtmlRenderedAttr("tabindex")
91          };
92          
93          selectBooleanCheckbox.setSelected(true);
94  
95          HtmlCheckAttributesUtil.checkRenderedAttributes(
96                  selectBooleanCheckbox, facesContext, writer, attrs);
97          if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) {
98              fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
99          }
100     
101     }   
102 }