1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.fatwire.gst.foundation.controller.annotation;
18
19 import java.lang.reflect.InvocationTargetException;
20 import java.lang.reflect.Method;
21
22 import junit.framework.TestCase;
23 import COM.FutureTense.Interfaces.ICS;
24
25 import com.fatwire.gst.foundation.test.MockICS;
26
27
28
29
30 public class ControllerMappingResolverTest extends TestCase {
31
32 static class Foo {
33 int i = 0;
34
35 @IcsVariable(var = { "cmd=login", "cmd=logout" })
36 public void doSomething(final ICS ics) {
37 i++;
38
39 }
40 }
41
42 public void testFindControllerMethod() throws IllegalArgumentException, IllegalAccessException,
43 InvocationTargetException {
44 final ControllerMappingResolver resolver = new ControllerMappingResolver();
45 final Foo foo = new Foo();
46 final ICS ics = new MockICS() {
47
48
49
50
51
52
53
54
55 @Override
56 public String GetVar(final String name) {
57 if ("cmd".equals(name)) {
58 return "login";
59 }
60 return null;
61 }
62
63 };
64 final Method m = resolver.findControllerMethod(ics, foo);
65 m.invoke(foo, new Object[] { ics });
66 assertEquals(1, foo.i);
67 }
68
69 }