2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.test.el.MockELContext
 
Classes in this File Line Coverage Branch Coverage Complexity
MockELContext
100%
14/14
N/A
1.4
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.apache.shale.test.el;
 19  
 
 20  
 import java.util.HashMap;
 21  
 import java.util.Locale;
 22  
 import java.util.Map;
 23  
 import javax.el.ELContext;
 24  
 import javax.el.ELResolver;
 25  
 import javax.el.FunctionMapper;
 26  
 import javax.el.VariableMapper;
 27  
 import javax.faces.context.FacesContext;
 28  
 
 29  
 /**
 30  
  * <p>Mock implementation of <code>ELContext</code>.</p>
 31  
  *
 32  
  * @since 1.0.4
 33  
  */
 34  
 
 35  
 public class MockELContext extends ELContext {
 36  
     
 37  
 
 38  
     // ------------------------------------------------------------ Constructors
 39  
 
 40  
 
 41  
     /** Creates a new instance of MockELContext */
 42  4
     public MockELContext() {
 43  4
     }
 44  
     
 45  
 
 46  
     // ------------------------------------------------------ Instance Variables
 47  
 
 48  
 
 49  4
     private Map contexts = new HashMap();
 50  4
     private FunctionMapper functionMapper = new MockFunctionMapper();
 51  4
     private Locale locale = Locale.getDefault();
 52  
     private boolean propertyResolved;
 53  4
     private VariableMapper variableMapper = new MockVariableMapper();
 54  
 
 55  
 
 56  
     // ----------------------------------------------------- Mock Object Methods
 57  
 
 58  
 
 59  
 
 60  
     // ------------------------------------------------------- ELContext Methods
 61  
 
 62  
 
 63  
     /** {@inheritDoc} */
 64  
     public Object getContext(Class key) {
 65  6
         if (key == null) {
 66  
             throw new NullPointerException();
 67  
         }
 68  6
         return contexts.get(key);
 69  
     }
 70  
 
 71  
 
 72  
     /** {@inheritDoc} */
 73  
     public ELResolver getELResolver() {
 74  
         FacesContext context = FacesContext.getCurrentInstance();
 75  
         return context.getApplication().getELResolver();
 76  
     }
 77  
 
 78  
 
 79  
     /** {@inheritDoc} */
 80  
     public FunctionMapper getFunctionMapper() {
 81  
         return this.functionMapper;
 82  
     }
 83  
 
 84  
 
 85  
     /** {@inheritDoc} */
 86  
     public Locale getLocale() {
 87  
         return this.locale;
 88  
     }
 89  
 
 90  
 
 91  
     /** {@inheritDoc} */
 92  
     public boolean isPropertyResolved() {
 93  5
         return this.propertyResolved;
 94  
     }
 95  
 
 96  
 
 97  
     /** {@inheritDoc} */
 98  
     public void putContext(Class key, Object value) {
 99  4
         if ((key == null) || (value == null)) {
 100  
             throw new NullPointerException();
 101  
         }
 102  4
         contexts.put(key, value);
 103  4
     }
 104  
 
 105  
 
 106  
     /** {@inheritDoc} */
 107  
     public void setPropertyResolved(boolean propertyResolved) {
 108  5
         this.propertyResolved = propertyResolved;
 109  5
     }
 110  
 
 111  
 
 112  
     /** {@inheritDoc} */
 113  
     public VariableMapper getVariableMapper() {
 114  
         return this.variableMapper;
 115  
     }
 116  
 
 117  
 
 118  
     /** {@inheritDoc} */
 119  
     public void setLocale(Locale locale) {
 120  
         this.locale = locale;
 121  
     }
 122  
 
 123  
 
 124  
 }