01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: 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 implements
32: VariableResolver {
33: private Map vars;
34:
35: public MockJspContext() {
36: super ();
37: vars = new HashMap();
38: }
39:
40: public void setAttribute(String name, Object value) {
41: vars.put(name, value);
42: }
43:
44: public void setAttribute(String name, Object value, int scope) {
45: setAttribute(name, value);
46: }
47:
48: public Object getAttribute(String name) {
49: return vars.get(name);
50: }
51:
52: public Object getAttribute(String name, int scope) {
53: return getAttribute(name);
54: }
55:
56: public void removeAttribute(String name) {
57: vars.remove(name);
58: }
59:
60: public void removeAttribute(String name, int scope) {
61: removeAttribute(name);
62: }
63:
64: public Object findAttribute(String name) {
65: return getAttribute(name);
66: }
67:
68: public VariableResolver getVariableResolver() {
69: return this ;
70: }
71:
72: public Object resolveVariable(String name) {
73: return getAttribute(name);
74: }
75:
76: public ExpressionEvaluator getExpressionEvaluator() {
77: return null;
78: }
79:
80: public int getAttributesScope(String name) {
81: return 1;
82: }
83:
84: public Enumeration getAttributeNamesInScope(int scope) {
85: return null;
86: }
87:
88: public JspWriter getOut() {
89: return null;
90: }
91: }
|