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 org.apache.struts.action.ActionMapping;
24: import org.strecks.context.ActionContext;
25: import org.strecks.context.impl.TestContextImpl;
26: import org.strecks.injection.handler.impl.ActionWithActionMapping;
27: import org.strecks.injection.internal.InjectionAnnotationReader;
28: import org.strecks.injection.internal.InjectionWrapper;
29: import org.testng.annotations.Test;
30:
31: /**
32: * @author Phil Zoio
33: */
34: public class TestActionMappingInjectionHandler {
35:
36: @Test
37: public void test() {
38: InjectionAnnotationReader c = new InjectionAnnotationReader();
39: ActionWithActionMapping action = new ActionWithActionMapping();
40:
41: c.readAnnotations(action.getClass());
42: Map<String, InjectionWrapper> inputs = c.getInjectionMap();
43:
44: ActionMapping mapping = createMock(ActionMapping.class);
45:
46: replay(mapping);
47:
48: InjectionWrapper inputWrapper = inputs.get("actionMapping");
49:
50: ActionContext injectionContext = new TestContextImpl(null,
51: mapping);
52: inputWrapper.inject(action, injectionContext);
53:
54: verify(mapping);
55:
56: assert action.getActionMapping() != null;
57: assert action.getActionMapping() == mapping;
58: }
59:
60: }
|