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 */ 012 public class MockVariableResolver implements VariableResolver 013 { 014 private Map variables = new HashMap(); 015 016 /** 017 * Adds a variable that resolves to the specified object. 018 * @param name the variable name 019 * @param value the variable value 020 */ 021 public void addVariable(String name, Object value) 022 { 023 variables.put(name, value); 024 } 025 026 /** 027 * Clears all variables. 028 */ 029 public void clearVariables() 030 { 031 variables.clear(); 032 } 033 034 public Object resolveVariable(String name) throws ELException 035 { 036 return variables.get(name); 037 } 038 }