Coverage Report - org.apache.myfaces.mc.test.core.mock.MockMyFacesFaceletViewDeclarationLanguage
 
Classes in this File Line Coverage Branch Coverage Complexity
MockMyFacesFaceletViewDeclarationLanguage
0%
0/47
0%
0/10
1.333
 
 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.mock;
 20  
 
 21  
 import java.io.IOException;
 22  
 import java.util.HashMap;
 23  
 import java.util.Map;
 24  
 
 25  
 import javax.el.ELException;
 26  
 import javax.faces.FacesException;
 27  
 import javax.faces.application.Resource;
 28  
 import javax.faces.component.UIViewRoot;
 29  
 import javax.faces.context.FacesContext;
 30  
 import javax.faces.context.ResponseWriter;
 31  
 
 32  
 import org.apache.myfaces.view.ViewDeclarationLanguageStrategy;
 33  
 import org.apache.myfaces.view.facelets.FaceletFactory;
 34  
 import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage;
 35  
 import org.apache.myfaces.view.facelets.compiler.Compiler;
 36  
 
 37  
 public class MockMyFacesFaceletViewDeclarationLanguage extends FaceletViewDeclarationLanguage
 38  
 {
 39  
     private String _renderedViewId;
 40  
     private Map<Resource, Resource> _scriptComponentResources;
 41  
 
 42  
     public MockMyFacesFaceletViewDeclarationLanguage(FacesContext context)
 43  
     {
 44  0
         super(context);
 45  0
     }
 46  
 
 47  
     public MockMyFacesFaceletViewDeclarationLanguage(FacesContext context,
 48  
             ViewDeclarationLanguageStrategy strategy)
 49  
     {
 50  0
         super(context, strategy);
 51  0
     }
 52  
     
 53  
     @Override
 54  
     public void buildView(FacesContext context, UIViewRoot view)
 55  
             throws IOException
 56  
     {
 57  0
         _renderedViewId = null;
 58  0
         super.buildView(context, view);
 59  0
     }
 60  
 
 61  
     public void buildView(FacesContext context, UIViewRoot view, String xmlFile) throws IOException
 62  
     {
 63  0
         _renderedViewId = xmlFile;
 64  0
         view.setViewId(xmlFile);
 65  0
         super.buildView(context, view);
 66  0
     }
 67  
     
 68  
     @Override
 69  
     public String getRenderedViewId(FacesContext context, String actionId)
 70  
     {
 71  0
         if (_renderedViewId != null)
 72  
         {
 73  0
             return _renderedViewId;//super.getRenderedViewId(context, actionId);
 74  
         }
 75  
         else
 76  
         {
 77  0
             return super.getRenderedViewId(context, actionId);
 78  
         }
 79  
     }    
 80  
 
 81  
     @Override
 82  
     public String calculateViewId(FacesContext context, String viewId)
 83  
     {
 84  0
         String calculatedViewId = super.calculateViewId(context, viewId);
 85  0
         if (calculatedViewId == null)
 86  
         {
 87  
             //can't calculate it, just passthrough the received one
 88  0
             calculatedViewId = viewId;
 89  
         }
 90  0
         return calculatedViewId;
 91  
     }
 92  
 
 93  
     @Override
 94  
     public Compiler createCompiler(FacesContext context)
 95  
     {
 96  0
         return super.createCompiler(context);
 97  
     }
 98  
 
 99  
     @Override
 100  
     public FaceletFactory createFaceletFactory(FacesContext context,
 101  
             Compiler compiler)
 102  
     {
 103  0
         return super.createFaceletFactory(context, compiler);
 104  
     }
 105  
 
 106  
     @Override
 107  
     public ResponseWriter createResponseWriter(FacesContext context)
 108  
             throws IOException, FacesException
 109  
     {
 110  0
         return super.createResponseWriter(context);
 111  
     }
 112  
 
 113  
     @Override
 114  
     public String getDefaultSuffix(FacesContext context)
 115  
             throws FacesException
 116  
     {
 117  0
         return super.getDefaultSuffix(context);
 118  
     }
 119  
 
 120  
     @Override
 121  
     public String getResponseContentType(FacesContext context, String orig)
 122  
     {
 123  0
         return super.getResponseContentType(context, orig);
 124  
     }
 125  
 
 126  
     @Override
 127  
     public String getResponseEncoding(FacesContext context, String orig)
 128  
     {
 129  0
         return super.getResponseEncoding(context, orig);
 130  
     }
 131  
 
 132  
     @Override
 133  
     public void handleFaceletNotFound(FacesContext context, String viewId)
 134  
             throws FacesException, IOException
 135  
     {
 136  0
         super.handleFaceletNotFound(context, viewId);
 137  0
     }
 138  
 
 139  
     @Override
 140  
     public void handleRenderException(FacesContext context, Exception e)
 141  
             throws IOException, ELException, FacesException
 142  
     {
 143  0
         super.handleRenderException(context, e);
 144  0
     }
 145  
 
 146  
     @Override
 147  
     public void initialize(FacesContext context)
 148  
     {
 149  0
         super.initialize(context);
 150  0
     }
 151  
 
 152  
     @Override
 153  
     public void loadDecorators(FacesContext context, Compiler compiler)
 154  
     {
 155  0
         super.loadDecorators(context, compiler);
 156  0
     }
 157  
 
 158  
     @Override
 159  
     public void loadLibraries(FacesContext context, Compiler compiler)
 160  
     {
 161  0
         super.loadLibraries(context, compiler);
 162  0
     }
 163  
 
 164  
     @Override
 165  
     public void loadOptions(FacesContext context, Compiler compiler)
 166  
     {
 167  0
         super.loadOptions(context, compiler);
 168  0
     }
 169  
 
 170  
     @Override
 171  
     public void sendSourceNotFound(FacesContext context, String message)
 172  
     {
 173  0
         super.sendSourceNotFound(context, message);
 174  0
     }
 175  
 
 176  
     @Override
 177  
     public Resource getScriptComponentResource(FacesContext context,
 178  
             Resource componentResource)
 179  
     {
 180  0
         if (_scriptComponentResources != null)
 181  
         {
 182  0
             Resource installedResource = _scriptComponentResources.get(componentResource);
 183  0
             if (installedResource != null)
 184  
             {
 185  
                 // if we have a Resource installed for this componentResource, return it
 186  0
                 return installedResource;
 187  
             }
 188  
         }
 189  0
         return super.getScriptComponentResource(context, componentResource);
 190  
     }
 191  
     
 192  
     /**
 193  
      * This method sets the scriptResource for a given componentResource so that
 194  
      * a call to getScriptComponentResource() with the given componentResource
 195  
      * will return the installed scriptResource.
 196  
      * @param componentResource
 197  
      * @param scriptResource
 198  
      */
 199  
     public void setScriptComponentResource(Resource componentResource, Resource scriptResource)
 200  
     {
 201  0
         if (_scriptComponentResources == null)
 202  
         {
 203  0
             _scriptComponentResources = new HashMap<Resource, Resource>();
 204  
         }
 205  0
         _scriptComponentResources.put(componentResource, scriptResource);
 206  0
     }
 207  
 
 208  
 }