01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.internal.test;
16:
17: import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
18: import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
19:
20: import java.util.List;
21: import java.util.Map;
22:
23: import org.apache.tapestry.ioc.internal.util.InternalUtils;
24: import org.apache.tapestry.services.Session;
25:
26: public class PageTesterSession implements Session {
27: private final Map<String, Object> _attributes = newMap();
28:
29: public List<String> getAttributeNames() {
30: return InternalUtils.sortedKeys(_attributes);
31: }
32:
33: public List<String> getAttributeNames(String prefix) {
34: List<String> result = newList();
35:
36: for (String name : getAttributeNames())
37: if (name.startsWith(prefix))
38: result.add(name);
39:
40: return result;
41: }
42:
43: public Object getAttribute(String name) {
44: return _attributes.get(name);
45: }
46:
47: public void setAttribute(String name, Object value) {
48: if (value == null) {
49: _attributes.remove(name);
50: } else {
51: _attributes.put(name, value);
52: }
53:
54: }
55:
56: private void nyi(String name) {
57: throw new IllegalStateException(String.format(
58: "%s.%s() is not yet implemented.",
59: getClass().getName(), name));
60: }
61:
62: public int getMaxInactiveInterval() {
63: nyi("getMaxInativeInterval");
64:
65: return 0;
66: }
67:
68: public void invalidate() {
69: nyi("invalidate");
70: }
71:
72: public void setMaxInactiveInterval(int seconds) {
73: nyi("setMaxInactiveInterval");
74: }
75:
76: }
|