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: * Copyright 2005-2006 the original author or authors.
16: *
17: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
18: * in compliance with the License. You may obtain a copy of the License at
19: *
20: * http://www.apache.org/licenses/LICENSE-2.0
21: *
22: * Unless required by applicable law or agreed to in writing, software distributed under the License
23: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
24: * or implied. See the License for the specific language governing permissions and limitations under
25: * the License.
26: */
27:
28: package org.strecks.injection.handler;
29:
30: import static org.easymock.classextension.EasyMock.createStrictMock;
31:
32: import java.util.Map;
33:
34: import javax.servlet.ServletContext;
35: import javax.servlet.http.HttpServletRequest;
36:
37: import org.strecks.context.ActionContext;
38: import org.strecks.context.impl.TestContextImpl;
39: import org.strecks.injection.handler.impl.ActionWithWebHelper;
40: import org.strecks.injection.internal.InjectionAnnotationReader;
41: import org.strecks.injection.internal.InjectionWrapper;
42: import org.testng.annotations.Test;
43:
44: /**
45: * @author Phil Zoio
46: */
47: public class TestWebContextInjectionHandler {
48:
49: @Test
50: public void test() {
51:
52: HttpServletRequest request = createStrictMock(HttpServletRequest.class);
53: ServletContext context = createStrictMock(ServletContext.class);
54:
55: InjectionAnnotationReader c = new InjectionAnnotationReader();
56: ActionWithWebHelper action = new ActionWithWebHelper();
57:
58: c.readAnnotations(action.getClass());
59: Map<String, InjectionWrapper> inputs = c.getInjectionMap();
60: InjectionWrapper inputWrapper = inputs.get("webHelper");
61:
62: ActionContext injectionContext = new TestContextImpl(request,
63: null, context, null, null);
64:
65: inputWrapper.inject(action, injectionContext);
66:
67: assert action.getWebHelper() != null;
68:
69: }
70:
71: }
|