1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.scxml.env.jsp;
17
18 import java.util.Enumeration;
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import javax.servlet.jsp.JspContext;
23 import javax.servlet.jsp.JspWriter;
24 import javax.servlet.jsp.el.ExpressionEvaluator;
25 import javax.servlet.jsp.el.VariableResolver;
26
27 /***
28 * A placeholder for a JspContext, to run tests against.
29 */
30 public class MockJspContext extends JspContext
31 implements VariableResolver {
32 private Map vars;
33 public MockJspContext() {
34 super();
35 vars = new HashMap();
36 }
37 public void setAttribute(String name, Object value) {
38 vars.put(name, value);
39 }
40 public void setAttribute(String name, Object value, int scope) {
41 setAttribute(name, value);
42 }
43 public Object getAttribute(String name) {
44 return vars.get(name);
45 }
46 public Object getAttribute(String name, int scope) {
47 return getAttribute(name);
48 }
49 public void removeAttribute(String name) {
50 vars.remove(name);
51 }
52 public void removeAttribute(String name, int scope) {
53 removeAttribute(name);
54 }
55 public Object findAttribute(String name) {
56 return getAttribute(name);
57 }
58 public VariableResolver getVariableResolver() {
59 return this;
60 }
61 public Object resolveVariable(String name) {
62 return getAttribute(name);
63 }
64 public ExpressionEvaluator getExpressionEvaluator() {
65 return null;
66 }
67 public int getAttributesScope(String name) {
68 return 1;
69 }
70 public Enumeration getAttributeNamesInScope(int scope) {
71 return null;
72 }
73 public JspWriter getOut() {
74 return null;
75 }
76 }
77