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.easymock.EasyMock.expect;
18: import static org.easymock.classextension.EasyMock.createStrictMock;
19: import static org.easymock.classextension.EasyMock.replay;
20: import static org.easymock.classextension.EasyMock.verify;
21:
22: import java.lang.reflect.Method;
23:
24: import org.apache.struts.action.ActionMapping;
25: import org.strecks.action.navigable.impl.SimpleDispatchAction;
26: import org.strecks.exceptions.ApplicationConfigurationException;
27: import org.testng.Assert;
28: import org.testng.annotations.Test;
29:
30: /**
31: * @author Phil Zoio
32: */
33: public final class TestDispatchControllerHelper {
34:
35: @Test
36: public void testGetMethod() {
37: DispatchControllerHelper helper = new DispatchControllerHelper();
38: SimpleDispatchAction action = new SimpleDispatchAction();
39: Method method1 = helper.getMethod(action, "insert");
40: Method method2 = helper.getMethod(action, "insert");
41: assert method1 == method2;
42: }
43:
44: @Test
45: public void testCheckParamter() {
46:
47: ActionMapping actionMapping = createStrictMock(ActionMapping.class);
48: expect(actionMapping.getPath()).andReturn("/path");
49:
50: replay(actionMapping);
51:
52: DispatchControllerHelper helper = new DispatchControllerHelper();
53: try {
54: helper.checkParameterName(actionMapping, null);
55: } catch (ApplicationConfigurationException e) {
56: Assert
57: .assertEquals(
58: e.getMessage(),
59: "The element 'parameter' is required to determine the method name, "
60: + "and is required in required in path /path");
61: }
62:
63: verify(actionMapping);
64: }
65:
66: }
|