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.services;
16:
17: import org.apache.tapestry.Link;
18: import org.apache.tapestry.MarkupWriter;
19: import org.apache.tapestry.dom.Document;
20: import org.apache.tapestry.dom.Element;
21: import org.apache.tapestry.test.PageTester;
22:
23: /**
24: * Used by the {@link PageTester} to map {@link Element}s (pulled from the rendered
25: * {@link Document}) into {@link ComponentInvocation}s, that can be used to to trigger further
26: * (simulated) requests. In this way, a unit test can have the
27: * {@link PageTester#clickLink(Element) click a link} or
28: * {@link PageTester#submitForm(Element, java.util.Map) submit a form}.
29: * <p>
30: * The information needed is generated in slightly disparate places, so the {@link LinkFactory}
31: * tells the map about Links and ComponentInvocations, and the {@link MarkupWriter} will link
32: * Elements to Link instance.
33: */
34: public interface ComponentInvocationMap {
35: /** Stores a connection between a particular link and an invocation of a component. */
36: void store(Link link, ComponentInvocation invocation);
37:
38: /** Stores a connection between an element and the link associated with that element. */
39: void store(Element element, Link link);
40:
41: /**
42: * Returns the invocation associated with a link.
43: *
44: * @param link
45: * previously create link
46: * @return associcated component invocation, or null
47: */
48: ComponentInvocation get(Link link);
49:
50: /**
51: * Returns the invocation associated with a rendered element.
52: *
53: * @param element
54: * extracted from the rendered {@link Document}
55: * @return the corresponding invocation
56: */
57: ComponentInvocation get(Element element);
58:
59: void clear();
60: }
|