01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. 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 distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.dispatch.internal;
16:
17: import static org.testng.Assert.assertEquals;
18:
19: import java.util.Map;
20:
21: import org.strecks.action.basic.BasicLookupDispatchController;
22: import org.strecks.action.basic.impl.SimpleDispatchAction;
23: import org.strecks.action.basic.impl.SimpleLookupDispatchAction;
24: import org.testng.annotations.BeforeMethod;
25: import org.testng.annotations.Test;
26:
27: /**
28: * @author Phil Zoio
29: */
30: public class TestDispatchMethodLookupReader {
31:
32: private DispatchMethodLookupReader reader;
33:
34: @BeforeMethod
35: public void setUp() {
36: reader = new DispatchMethodLookupReader();
37: }
38:
39: @Test
40: public void testDispatchMethodLookupReader() {
41: assert reader.readAnnotations(SimpleLookupDispatchAction.class);
42:
43: Map<String, String> keyMethodMap = reader.getKeyMethodMap();
44: assertEquals(keyMethodMap.size(), 2);
45:
46: assertEquals(keyMethodMap.get("insert.key"), "insert");
47: assertEquals(keyMethodMap.get("update.key"), "update");
48:
49: TestDispatchController controller = new TestDispatchController();
50: reader.populateController(controller);
51: Map<String, String> controllerKeyMethodMap = controller
52: .internalGetKeyMethodMap();
53:
54: assertEquals(keyMethodMap, controllerKeyMethodMap);
55: }
56:
57: @Test
58: public void testNoAnnotations() {
59: assert !reader.readAnnotations(SimpleDispatchAction.class);
60: }
61:
62: }
63:
64: class TestDispatchController extends BasicLookupDispatchController {
65:
66: @Override
67: protected Map<String, String> internalGetKeyMethodMap() {
68: return super.internalGetKeyMethodMap();
69: }
70:
71: };
|