01: package org.vraptor.component;
02:
03: import java.lang.reflect.Method;
04:
05: import junit.framework.TestCase;
06:
07: import org.vraptor.annotations.Out;
08: import org.vraptor.reflection.MethodInvocationException;
09: import org.vraptor.scope.ScopeType;
10:
11: public class GetterOutjecterTest extends TestCase {
12:
13: public static class GetterCustomOut {
14:
15: @Out(scope=ScopeType.SESSION)
16: public String getVal() {
17: return "oi2";
18: }
19:
20: }
21:
22: private Method grabGetter(Class type) throws SecurityException,
23: NoSuchMethodException {
24: return type.getMethod("getVal");
25: }
26:
27: public void testReadsOverridenScope() throws SecurityException,
28: NoSuchMethodException {
29: GetterOutjecter outjecter = new GetterOutjecter("val",
30: grabGetter(GetterCustomOut.class));
31: assertEquals(ScopeType.SESSION, outjecter.getScope());
32: }
33:
34: public void testRetrievesTheObject() throws SecurityException,
35: NoSuchMethodException, MethodInvocationException {
36: GetterOutjecter outjecter = new GetterOutjecter("val",
37: grabGetter(GetterCustomOut.class));
38: GetterCustomOut obj = new GetterCustomOut();
39: assertEquals("oi2", outjecter.getValue(obj));
40: }
41:
42: }
|