View Javadoc

1   /* Licensed to the Apache Software Foundation (ASF) under one or more
2    * contributor license agreements.  See the NOTICE file distributed with
3    * this work for additional information regarding copyright ownership.
4    * The ASF licenses this file to you under the Apache License, Version 2.0
5    * (the "License"); you may not use this file except in compliance with
6    * the License.  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15  */
16  package org.apache.myfaces.context;
17  
18  import javax.faces.FactoryFinder;
19  import javax.faces.context.FacesContext;
20  import javax.faces.context.PartialViewContext;
21  
22  import org.apache.myfaces.context.servlet.FacesContextImpl;
23  import org.apache.myfaces.test.base.AbstractJsfTestCase;
24  
25  /**
26   * Various tests for the faces context is rendered
27   * util Methods!
28   *
29   * @author Werner Punz(latest modification by $Author: bommel $)
30   * @version $Revision: 954308 $ $Date: 2010-06-13 15:52:08 -0500 (Sun, 13 Jun 2010) $
31   */
32  public class IsRenderedTest extends AbstractJsfTestCase {
33  
34      public IsRenderedTest() {
35          super("IsRenderedTest");
36      }
37  
38      @Override
39      protected void setUp() throws Exception {
40          super.setUp();
41          FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
42          "org.apache.myfaces.context.PartialViewContextFactoryImpl");       
43          FactoryFinder.setFactory (FactoryFinder.EXCEPTION_HANDLER_FACTORY,
44          "org.apache.myfaces.context.ExceptionHandlerFactoryImpl");
45      }
46  
47      /**
48       * tests the basic render all mechanism,
49       * no render all due to defaults
50       * or a renderAll which
51       */
52      public void testRenderAll1() {
53          FacesContext context = new FacesContextImpl(servletContext, request, response);
54          
55          PartialViewContext pprContext = context.getPartialViewContext();
56  
57          pprContext.setRenderAll(true);
58          assertTrue("override should trigger no matter which condition we have", pprContext.isRenderAll());
59  
60          context = new FacesContextImpl(servletContext, request, response);
61          pprContext.setRenderAll(false);
62          assertFalse("override should trigger no matter which condition we have", pprContext.isRenderAll());
63      }
64  
65     
66  }