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  
20  package org.apache.myfaces.view.facelets.compiler;
21  
22  import javax.faces.component.UIComponent;
23  import javax.faces.component.UIOutput;
24  import javax.faces.component.UIViewRoot;
25  import javax.faces.component.html.HtmlOutputText;
26  import javax.faces.context.ResponseWriter;
27  
28  import org.apache.myfaces.renderkit.html.HtmlTextRenderer;
29  import org.apache.myfaces.view.facelets.FaceletTestCase;
30  import org.apache.myfaces.view.facelets.util.FastWriter;
31  import org.junit.Test;
32  
33  public class ELParserTestCase extends FaceletTestCase {
34  
35      private UIComponent target;
36  
37      @Override
38      protected void setupComponents() throws Exception
39      {
40          application.addComponent(UIViewRoot.COMPONENT_TYPE,
41                  UIViewRoot.class.getName());
42          application.addComponent(HtmlOutputText.COMPONENT_TYPE,
43                  HtmlOutputText.class.getName());
44      }
45  
46      @Override
47      protected void setupConvertersAndValidators() throws Exception
48      {
49      }
50  
51      @Override
52      protected void setupRenderers() throws Exception
53      {
54          renderKit.addRenderer(UIOutput.COMPONENT_FAMILY,
55                  "javax.faces.Text", new HtmlTextRenderer());
56      }    
57      
58      @Test
59      public void testSelectOneMenu() throws Exception {
60          request.setAttribute("test", this);
61  
62          UIViewRoot root = facesContext.getViewRoot();
63          vdl.buildView(facesContext, root, "elparser.xml");
64  
65          FastWriter fw = new FastWriter();
66          ResponseWriter rw = facesContext.getResponseWriter();
67          rw = rw.cloneWithWriter(fw);
68          facesContext.setResponseWriter(rw);
69          root.encodeAll(facesContext);
70          //System.out.println(fw);
71      }
72  
73      public void setUp() throws Exception {
74          super.setUp();
75          this.target = null;
76      }
77  
78      public UIComponent getTarget() {
79          return target;
80      }
81  
82      public void setTarget(UIComponent target) {
83          this.target = target;
84      }
85  
86  }