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 javax.faces.component.UISelectItem;
22  
23  import junit.framework.Test;
24  import junit.framework.TestSuite;
25  
26  import org.apache.myfaces.test.AbstractTomahawkViewControllerTestCase;
27  import org.apache.myfaces.test.utils.HtmlCheckAttributesUtil;
28  import org.apache.myfaces.test.utils.HtmlRenderedAttr;
29  import org.apache.shale.test.mock.MockResponseWriter;
30  
31  public class HtmlSelectManyCheckboxAjaxRendererTest extends AbstractTomahawkViewControllerTestCase
32  {
33      private MockResponseWriter writer ;
34      private HtmlSelectManyCheckboxAjax selectManyCheckbox;
35  
36      public HtmlSelectManyCheckboxAjaxRendererTest(String name)
37      {
38          super(name);
39      }
40      
41      public static Test suite() {
42          return new TestSuite(HtmlSelectManyCheckboxAjaxRendererTest.class);
43      }
44  
45      public void setUp() throws Exception
46      {
47          super.setUp();
48  
49          selectManyCheckbox = new HtmlSelectManyCheckboxAjax();
50  
51          writer = (MockResponseWriter)facesContext.getResponseWriter();
52      }
53  
54      public void tearDown() throws Exception
55      {
56          super.tearDown();
57          selectManyCheckbox = null;
58          writer = null;
59      }
60  
61      public void testSelectManyHtmlPropertyPassTru() throws Exception 
62      {
63          HtmlRenderedAttr[] attrs = {
64              //_AccesskeyProperty
65              new HtmlRenderedAttr("accesskey"),
66              //_UniversalProperties
67              new HtmlRenderedAttr("dir"), 
68              new HtmlRenderedAttr("lang"), 
69              new HtmlRenderedAttr("title"),
70              //_FocusBlurProperties
71              new HtmlRenderedAttr("onfocus"), 
72              new HtmlRenderedAttr("onblur"),
73              //_ChangeSelectProperties
74              new HtmlRenderedAttr("onchange"), 
75              new HtmlRenderedAttr("onselect"),
76              //_EventProperties
77              new HtmlRenderedAttr("onclick", "onclick", "onclick=\""), 
78              new HtmlRenderedAttr("ondblclick"), 
79              new HtmlRenderedAttr("onkeydown"), 
80              new HtmlRenderedAttr("onkeypress"),
81              new HtmlRenderedAttr("onkeyup"), 
82              new HtmlRenderedAttr("onmousedown"), 
83              new HtmlRenderedAttr("onmousemove"), 
84              new HtmlRenderedAttr("onmouseout"),
85              new HtmlRenderedAttr("onmouseover"), 
86              new HtmlRenderedAttr("onmouseup"),
87              //_StyleProperties
88              new HtmlRenderedAttr("style"), 
89              new HtmlRenderedAttr("styleClass", "styleClass", "class=\"styleClass\""),
90              //_TabindexProperty
91              new HtmlRenderedAttr("tabindex")
92          };
93          
94          UISelectItem item = new UISelectItem();
95          item.setItemLabel("mars");
96          item.setItemValue("mars");
97          selectManyCheckbox.getChildren().add(item);
98  
99          HtmlCheckAttributesUtil.checkRenderedAttributes(
100                 selectManyCheckbox, facesContext, writer, attrs);
101         if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs)) 
102         {
103             fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, writer.getWriter().toString()));
104         }
105     }
106 }