01: package com.mockrunner.mock.web;
02:
03: import java.lang.reflect.Method;
04:
05: import org.apache.struts.action.ActionForward;
06:
07: /**
08: * Mock implementation of <code>ActionForward</code>.
09: */
10: public class MockActionForward extends MockForwardConfig {
11: public MockActionForward() {
12: this (null, false);
13: }
14:
15: public MockActionForward(String name) {
16: this (name, false);
17: }
18:
19: public MockActionForward(String name, boolean redirect) {
20:
21: super ();
22: setName(name);
23: setPath(null);
24: setRedirect(redirect);
25:
26: }
27:
28: public MockActionForward(String name, String path, boolean redirect) {
29: super ();
30: setName(name);
31: setPath(path);
32: setRedirect(redirect);
33: }
34:
35: public MockActionForward(String name, String path,
36: boolean redirect, boolean contextRelative) {
37: super ();
38: setName(name);
39: setPath(path);
40: setRedirect(redirect);
41: setContextRelative(contextRelative);
42: }
43:
44: public MockActionForward(String name, String path,
45: boolean redirect, String module) {
46: super ();
47: setName(name);
48: setPath(path);
49: setRedirect(redirect);
50: setModule(module);
51: }
52:
53: public MockActionForward(ActionForward copyMe) {
54: setName(copyMe.getName());
55: setPath(copyMe.getPath());
56: setRedirect(copyMe.getRedirect());
57: try {
58: Method getContextRelativeMethod = copyMe.getClass()
59: .getMethod("getContextRelative", null);
60: Boolean value = (Boolean) getContextRelativeMethod.invoke(
61: copyMe, null);
62: if (null != value) {
63: setContextRelative(value.booleanValue());
64: }
65: } catch (Exception exc) {
66: //Struts 1.3 does not define the method "getContextRelative"
67: //this hack is necessary to avoid different versions for Struts 1.2 and 1.3
68: }
69: }
70:
71: public boolean verifyName(String name) {
72: if (null == getName())
73: return false;
74: if (getName().equals(name)) {
75: return true;
76: }
77: return false;
78: }
79:
80: public boolean verifyPath(String path) {
81: if (null == getPath())
82: return false;
83: if (getPath().equals(path)) {
84: return true;
85: }
86: return false;
87: }
88:
89: public boolean verifyRedirect(boolean redirect) {
90: return getRedirect() == redirect;
91: }
92: }
|