Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractMyFacesFaceletsTestCase |
|
| 1.0;1 |
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.mc.test.core; | |
20 | ||
21 | import org.apache.myfaces.mc.test.core.mock.MockMyFacesFaceletViewDeclarationLanguage; | |
22 | import javax.faces.FactoryFinder; | |
23 | import javax.faces.component.UIViewRoot; | |
24 | import javax.faces.event.PhaseId; | |
25 | import javax.faces.view.ViewDeclarationLanguageFactory; | |
26 | ||
27 | /** | |
28 | * <p>Abstract JUnit test case base class, which provide a var called vdl, that | |
29 | * can be used to build facelet views calling for example:</p> | |
30 | * <p>vdl.buildView(facesContext, facesContext.getViewRoot(), "/hello.xhtml");</p> | |
31 | * <p>It already initalize a request, and keep in mind there is no any lifecycle | |
32 | * execution. This test case is used to check the view structure.</p> | |
33 | * | |
34 | * @author Leonardo Uribe | |
35 | * | |
36 | */ | |
37 | 0 | public abstract class AbstractMyFacesFaceletsTestCase extends AbstractMyFacesRequestTestCase |
38 | { | |
39 | @Override | |
40 | public void setUp() throws Exception | |
41 | { | |
42 | 0 | super.setUp(); |
43 | ||
44 | 0 | setUpVDL(); |
45 | ||
46 | 0 | startFaceletRequest(); |
47 | 0 | } |
48 | ||
49 | protected void setUpVDL() | |
50 | { | |
51 | 0 | ViewDeclarationLanguageFactory vdlFactory = (ViewDeclarationLanguageFactory) |
52 | FactoryFinder.getFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY); | |
53 | 0 | vdl = (MockMyFacesFaceletViewDeclarationLanguage) |
54 | vdlFactory.getViewDeclarationLanguage("/a.xhtml"); | |
55 | 0 | } |
56 | ||
57 | /** | |
58 | * Initialize a request providing an empty UIViewRoot without enter into the | |
59 | * lifecycle. | |
60 | */ | |
61 | public void startFaceletRequest() | |
62 | { | |
63 | 0 | startRequest(); |
64 | // Create a new UIViewRoot to work with it later | |
65 | 0 | UIViewRoot root = new UIViewRoot(); |
66 | 0 | root.setViewId("/test"); |
67 | 0 | root.setRenderKitId("HTML_BASIC"); |
68 | 0 | facesContext.setViewRoot(root); |
69 | // Set the current phase to render response. | |
70 | 0 | facesContext.setCurrentPhaseId(PhaseId.RENDER_RESPONSE); |
71 | 0 | } |
72 | ||
73 | @Override | |
74 | public void tearDown() throws Exception | |
75 | { | |
76 | 0 | endRequest(); |
77 | ||
78 | 0 | super.tearDown(); |
79 | 0 | } |
80 | ||
81 | protected MockMyFacesFaceletViewDeclarationLanguage vdl; | |
82 | } |