1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.net.telnet;
18
19
20
21
22
23
24 public class WindowSizeOptionHandlerTest extends TelnetOptionHandlerTestAbstract
25 {
26
27
28
29 @Override
30 protected void setUp()
31 {
32 opthand1 = new WindowSizeOptionHandler(80, 24);
33 opthand2 = new WindowSizeOptionHandler(255, 255, true, true, true, true);
34 opthand3 = new WindowSizeOptionHandler(0xFFFF, 0x00FF, false, false, false, false);
35 }
36
37
38
39
40 @Override
41 public void testConstructors()
42 {
43 assertEquals(TelnetOption.WINDOW_SIZE, opthand1.getOptionCode());
44 super.testConstructors();
45 }
46
47
48
49
50
51 @Override
52 public void testStartSubnegotiation()
53 {
54 assertNull(opthand1.startSubnegotiationRemote());
55 assertNull(opthand2.startSubnegotiationRemote());
56 assertNull(opthand3.startSubnegotiationRemote());
57 }
58
59
60
61
62
63 public void testStartSubnegotiationLocal()
64 {
65 int[] exp1 = {31, 0, 80, 0, 24};
66 int[] start1 = opthand1.startSubnegotiationLocal();
67 assertEquals(5, start1.length);
68 equalInts(exp1, start1);
69
70 int[] exp2 = {31, 0, 255, 255, 0, 255, 255};
71 int[] start2 = opthand2.startSubnegotiationLocal();
72 equalInts(exp2, start2);
73
74 int[] exp3 = {31, 255, 255, 255, 255, 0, 255, 255};
75 int[] start3 = opthand3.startSubnegotiationLocal();
76 equalInts(exp3, start3);
77 }
78
79
80
81
82
83
84
85 @Override
86 public void testAnswerSubnegotiation()
87 {
88 int subn[] =
89 {
90 TelnetOption.WINDOW_SIZE, 24, 80
91 };
92
93 int resp1[] = opthand1.answerSubnegotiation(subn, subn.length);
94 int resp2[] = opthand2.answerSubnegotiation(subn, subn.length);
95 int resp3[] = opthand3.answerSubnegotiation(subn, subn.length);
96
97 assertNull(resp1);
98 assertNull(resp2);
99 assertNull(resp3);
100 }
101
102
103
104
105 private void equalInts(int a1[], int a2[])
106 {
107 assertEquals("Arrays should be the same length", a1.length, a2.length);
108 for(int ii=0; ii<a1.length; ii++)
109 {
110 assertEquals("Array entry "+ii+" should match",a1[ii], a2[ii]);
111 }
112 }
113 }