001    package com.mockrunner.mock.web;
002    
003    import java.util.HashMap;
004    import java.util.Map;
005    
006    import javax.servlet.jsp.el.ELException;
007    import javax.servlet.jsp.el.VariableResolver;
008    
009    /**
010     * Mock implementation of <code>VariableResolver</code>.
011     * This implementation cannot be used for real EL
012     * expressions. Real EL expression support is only
013     * available for the <b>Unified Expression Language</b> API
014     * using the {@link JasperJspFactory}.
015     */
016    public class MockVariableResolver implements VariableResolver
017    {
018        private Map variables = new HashMap();
019        
020        /**
021         * Adds a variable that resolves to the specified object.
022         * @param name the variable name
023         * @param value the variable value
024         */
025        public void addVariable(String name, Object value)
026        {
027            variables.put(name, value);
028        }
029        
030        /**
031         * Clears all variables.
032         */
033        public void clearVariables()
034        {
035            variables.clear();
036        }
037    
038        public Object resolveVariable(String name) throws ELException
039        {
040            return variables.get(name);
041        }
042    }