1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 package com.buckosoft.fibs.net;
43
44 import junit.framework.TestCase;
45
46 import org.junit.Before;
47 import org.junit.Test;
48
49 import com.buckosoft.fibs.net.CookieMonster;
50 import com.buckosoft.fibs.net.FIBSMessages;
51
52
53
54
55
56
57
58 public class TestCookieMonster extends TestCase implements FIBSMessages {
59 private CookieMonster cm;
60
61 private final static String c20a = "WELCOME TO THE FIBS";
62 private final static String c20b = "IT'S A VERY GOOD PLACE TO BE.";
63 private final static String c21 = "login: ";
64 private final static String c20c = "";
65
66 private final static String c1 = "1 BuckoFIBSa 1304778418 75-144-150-169-NewEngland.hfc.comcastbusiness.net";
67 private final static String c2 = "2 BuckoFIBSa 1 1 0 0 0 0 1 1 5013 0 1 0 1 1679.40 0 1 0 1 0 UTC";
68 private final static String c3 = "3";
69 private final static String c3a = "+--------------------------------------------------------------------+";
70 private final static String c3b = "| |";
71 private final static String c4 = "4";
72 private final static String c27 = "";
73 private final static String c5 = "5 vegas_vic - - 1 0 1956.77 22677 1 1304718118 66.108.89.80 ?CHVegas8ic________! -";
74 private final static String c7 = "7 vegas_vic vegas_vic logs in.";
75 private final static String c184 = "GammonBot_VIII wins a 9 point match against Mozart 10-7 .";
76 private final static String c219 = "** You're now ready to invite or join someone.";
77 private final static String c253 = "** Fred wanted to resign. Type 'accept' or 'reject'.";
78
79
80
81 @Before
82 public void setUp() throws Exception {
83 cm = new CookieMonster();
84 }
85
86 @Test
87 public void testSetClientConnection() {
88
89 }
90
91 @Test
92 public void testFIBSCookie() {
93 assertEquals(FIBS_PreLogin, cm.fIBSCookie(c20a));
94 assertEquals(FIBS_PreLogin, cm.fIBSCookie(c20b));
95 assertEquals(FIBS_PreLogin, cm.fIBSCookie(c20c));
96 assertEquals(FIBS_LoginPrompt, cm.fIBSCookie(c21));
97 assertEquals(CLIP_WELCOME, cm.fIBSCookie(c1));
98 assertEquals(CLIP_OWN_INFO, cm.fIBSCookie(c2));
99 assertEquals(CLIP_MOTD_BEGIN, cm.fIBSCookie(c3));
100 assertEquals(CLIP_MOTD_BEGIN, cm.fIBSCookie(c3a));
101 assertEquals(CLIP_MOTD_BEGIN, cm.fIBSCookie(c3b));
102 assertEquals(CLIP_MOTD_END, cm.fIBSCookie(c4));
103 assertEquals(FIBS_Empty, cm.fIBSCookie(c27));
104 assertEquals(CLIP_WHO_INFO, cm.fIBSCookie(c5));
105 assertEquals(CLIP_LOGIN, cm.fIBSCookie(c7));
106 assertEquals(FIBS_MatchResult, cm.fIBSCookie(c184));
107 assertEquals(FIBS_ReadyTrue, cm.fIBSCookie(c219));
108 assertEquals(FIBS_WantedToResign, cm.fIBSCookie(c253));
109
110 }
111
112 @Test
113 public void testReset() {
114 cm.reset();
115 }
116 }