View Javadoc

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.renderkit.html.behavior;
20  
21  import javax.faces.component.UIComponent;
22  import javax.faces.component.html.HtmlCommandLink;
23  import javax.faces.component.html.HtmlForm;
24  
25  import org.apache.myfaces.application.NavigationHandlerImpl;
26  import org.apache.myfaces.shared.renderkit.ClientBehaviorEvents;
27  import org.apache.myfaces.shared.renderkit.html.HTML;
28  import org.apache.myfaces.shared.util.ArrayUtils;
29  
30  /**
31   * @author Leonardo Uribe (latest modification by $Author: bommel $)
32   * @version $Revision: 1187701 $ $Date: 2011-10-22 07:21:54 -0500 (Sat, 22 Oct 2011) $
33   */
34  public class HtmlCommandLinkClientBehaviorRendererTest extends AbstractClientBehaviorTestCase
35  {
36      private HtmlRenderedClientEventAttr[] attrs = null;
37      
38      @Override
39      public void setUp() throws Exception
40      {
41          super.setUp();
42          attrs =  (HtmlRenderedClientEventAttr[]) 
43                  ArrayUtils.concat(HtmlClientEventAttributesUtil.generateClientBehaviorEventAttrs(),
44                  new HtmlRenderedClientEventAttr[]{
45                      new HtmlRenderedClientEventAttr(HTML.ONFOCUS_ATTR, ClientBehaviorEvents.FOCUS),
46                      new HtmlRenderedClientEventAttr(HTML.ONBLUR_ATTR, ClientBehaviorEvents.BLUR),
47                      new HtmlRenderedClientEventAttr(HTML.ONCLICK_ATTR, ClientBehaviorEvents.ACTION)
48                  });
49      }
50      
51      
52  
53      @Override
54      protected void setUpApplication() throws Exception
55      {
56          super.setUpApplication();
57          application.setNavigationHandler(new NavigationHandlerImpl());
58      }
59  
60      @Override
61      public void tearDown() throws Exception
62      {
63          super.tearDown();
64          attrs = null;
65      }
66  
67      @Override
68      protected UIComponent createComponentToTest()
69      {
70          UIComponent component = new HtmlCommandLink();
71          UIComponent form = new HtmlForm();
72          form.getChildren().add(component);
73          facesContext.getViewRoot().getChildren().add(form);
74          return component;
75      }
76  
77      @Override
78      protected HtmlRenderedClientEventAttr[] getClientBehaviorHtmlRenderedAttributes()
79      {
80          return attrs;
81      }
82  }