Coverage Report - org.seasar.teeda.core.mock.MockFacesContextFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
MockFacesContextFactory
86%
6/7
50%
1/2
1.667
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.mock;
 17  
 
 18  
 import javax.faces.FacesException;
 19  
 import javax.faces.context.FacesContext;
 20  
 import javax.faces.context.FacesContextFactory;
 21  
 import javax.faces.lifecycle.Lifecycle;
 22  
 
 23  
 import org.seasar.framework.mock.servlet.MockHttpServletRequest;
 24  
 import org.seasar.framework.mock.servlet.MockHttpServletResponse;
 25  
 import org.seasar.framework.mock.servlet.MockServletContext;
 26  
 
 27  
 public class MockFacesContextFactory extends FacesContextFactory {
 28  
 
 29  
     private FacesContext context_;
 30  
 
 31  1339
     public MockFacesContextFactory() {
 32  1339
     }
 33  
 
 34  
     public FacesContext getFacesContext(Object context, Object request,
 35  
             Object response, Lifecycle lifecycle) throws FacesException {
 36  1
         if (context_ != null) {
 37  0
             return context_;
 38  
         }
 39  1
         return new MockFacesContextImpl(new MockExternalContextImpl(
 40  
                 (MockServletContext) context, (MockHttpServletRequest) request,
 41  
                 (MockHttpServletResponse) response));
 42  
     }
 43  
 
 44  
     public void setFacesContext(FacesContext context) {
 45  1344
         context_ = context;
 46  1344
     }
 47  
 }