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