1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.fatwire.gst.foundation.controller.action;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNull;
20
21 import org.junit.Test;
22
23 import COM.FutureTense.Interfaces.ICS;
24 import COM.FutureTense.Util.ftMessage;
25
26 import com.fatwire.gst.foundation.controller.annotation.Bind;
27 import com.fatwire.gst.foundation.test.MockICS;
28
29 public class AnnotationBinderTest {
30
31 class MyObject {
32 @Bind
33 String pagename;
34 @Bind
35 long cid;
36 @Bind
37 Long tid;
38 @Bind
39 String c;
40 @Bind("foo")
41 String bar;
42
43 }
44
45 @Test
46 public void testBind_csvar() {
47 MyObject o = new MyObject();
48 ICS ics = new MockICS() {
49
50 @Override
51 public String GetVar(String key) {
52 if (ftMessage.PageName.equals(key)) {
53 return "hello";
54 } else if ("cid".equals(key)) {
55 return "12345678901234";
56 } else if ("tid".equals(key)) {
57 return "22345678901234";
58 } else if ("foo".equals(key)) {
59 return "oof";
60
61 }
62 return null;
63 }
64
65 };
66 AnnotationBinder.bind(o, ics);
67 assertEquals("hello", o.pagename);
68 assertEquals(12345678901234L, o.cid);
69 assertEquals(new Long(22345678901234L), o.tid);
70 assertNull(o.c);
71 assertEquals("oof", o.bar);
72 }
73
74 }