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 public class ControllerMappingResolverTest extends TestCase {
28
29 static class Foo {
30 int i = 0;
31
32 @IcsVariable(var = { "cmd=login", "cmd=logout" })
33 public void doSomething(final ICS ics) {
34 i++;
35
36 }
37 }
38
39 public void testFindControllerMethod() throws IllegalArgumentException, IllegalAccessException,
40 InvocationTargetException {
41 final ControllerMappingResolver resolver = new ControllerMappingResolver();
42 final Foo foo = new Foo();
43 final ICS ics = new MockICS() {
44
45
46
47
48
49
50
51
52 @Override
53 public String GetVar(final String name) {
54 if ("cmd".equals(name)) {
55 return "login";
56 }
57 return null;
58 }
59
60 };
61 final Method m = resolver.findControllerMethod(ics, foo);
62 m.invoke(foo, new Object[] { ics });
63 assertEquals(1, foo.i);
64 }
65
66 }