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.newMap;
18:
19: import java.util.Map;
20:
21: import org.apache.tapestry.Link;
22: import org.apache.tapestry.dom.Element;
23: import org.apache.tapestry.internal.services.ComponentInvocation;
24: import org.apache.tapestry.internal.services.ComponentInvocationMap;
25: import org.apache.tapestry.internal.services.NoOpComponentInvocationMap;
26: import org.apache.tapestry.test.PageTester;
27:
28: /**
29: * This is the real implementation, used by {@link PageTester}. The typical implementation,
30: * {@link NoOpComponentInvocationMap}, is used in production as a place holder.
31: */
32: public class PageTesterComponentInvocationMap implements
33: ComponentInvocationMap {
34: private final Map<Element, Link> _elementToLink = newMap();
35:
36: private final Map<Link, ComponentInvocation> _linkToInvocation = newMap();
37:
38: public void store(Element element, Link link) {
39: _elementToLink.put(element, link);
40: }
41:
42: public void store(Link link, ComponentInvocation invocation) {
43: _linkToInvocation.put(link, invocation);
44: }
45:
46: public void clear() {
47: _elementToLink.clear();
48: _linkToInvocation.clear();
49: }
50:
51: public ComponentInvocation get(Element element) {
52: Link link = _elementToLink.get(element);
53:
54: return get(link);
55: }
56:
57: public ComponentInvocation get(Link link) {
58: return _linkToInvocation.get(link);
59: }
60:
61: }
|