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.injection.handler;
16:
17: import static org.easymock.classextension.EasyMock.createMock;
18: import static org.easymock.classextension.EasyMock.replay;
19: import static org.easymock.classextension.EasyMock.verify;
20:
21: import java.util.Map;
22:
23: import javax.servlet.http.HttpServletResponse;
24:
25: import org.strecks.context.ActionContext;
26: import org.strecks.context.impl.TestContextImpl;
27: import org.strecks.injection.handler.impl.ActionWithResponse;
28: import org.strecks.injection.internal.InjectionAnnotationReader;
29: import org.strecks.injection.internal.InjectionWrapper;
30: import org.testng.annotations.Test;
31:
32: /**
33: * @author Phil Zoio
34: */
35: public class TestResponseInjectionHandler {
36:
37: @Test
38: public void test() {
39: InjectionAnnotationReader c = new InjectionAnnotationReader();
40: ActionWithResponse action = new ActionWithResponse();
41:
42: c.readAnnotations(action.getClass());
43: Map<String, InjectionWrapper> inputs = c.getInjectionMap();
44:
45: HttpServletResponse response = createMock(HttpServletResponse.class);
46:
47: replay(response);
48:
49: InjectionWrapper inputWrapper = inputs.get("response");
50:
51: ActionContext injectionContext = new TestContextImpl(null,
52: response, null, null, null);
53: inputWrapper.inject(action, injectionContext);
54:
55: verify(response);
56:
57: assert action.getResponse() != null;
58: assert action.getResponse() == response;
59: }
60:
61: }
|