01: // Copyright 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 java.util.Arrays;
18: import java.util.List;
19: import java.util.Map;
20:
21: import org.apache.tapestry.ComponentResources;
22: import org.apache.tapestry.ioc.internal.util.TapestryException;
23: import org.apache.tapestry.runtime.Component;
24: import org.apache.tapestry.services.ComponentEventResultProcessor;
25: import org.apache.tapestry.test.TapestryTestCase;
26: import org.testng.annotations.Test;
27:
28: public class ObjectComponentEventResultProcessorTest extends
29: TapestryTestCase {
30: @SuppressWarnings("unchecked")
31: @Test
32: public void invocation_is_failure() {
33: ComponentResources resources = mockComponentResources();
34: Component component = mockComponent();
35: String result = "*INVALID*";
36:
37: train_getComponentResources(component, resources);
38: train_getCompleteId(resources, "foo.Bar:gnip.gnop");
39:
40: List classes = Arrays.asList(String.class, List.class,
41: Map.class);
42:
43: replay();
44:
45: ComponentEventResultProcessor p = new ObjectComponentEventResultProcessor(
46: classes);
47:
48: try {
49: p.processComponentEvent(result, component,
50: "foo.component.Gnop.blip()");
51: unreachable();
52: } catch (TapestryException ex) {
53: assertEquals(
54: ex.getMessage(),
55: "An event handler for component foo.Bar:gnip.gnop returned the value *INVALID* (from method foo.component.Gnop.blip()). "
56: + "Return type java.lang.String can not be handled. "
57: + "Configured return types are java.lang.String, java.util.List, java.util.Map.");
58: }
59: }
60: }
|