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 public class WindowSizeOptionHandlerTest extends AbstractTelnetOptionHandlerTest {
23
24
25
26 private void equalInts(final int a1[], final int a2[]) {
27 assertEquals("Arrays should be the same length", a1.length, a2.length);
28 for (int ii = 0; ii < a1.length; ii++) {
29 assertEquals("Array entry " + ii + " should match", a1[ii], a2[ii]);
30 }
31 }
32
33
34
35
36 @Override
37 protected void setUp() {
38 opthand1 = new WindowSizeOptionHandler(80, 24);
39 opthand2 = new WindowSizeOptionHandler(255, 255, true, true, true, true);
40 opthand3 = new WindowSizeOptionHandler(0xFFFF, 0x00FF, false, false, false, false);
41 }
42
43
44
45
46 @Override
47 public void testAnswerSubnegotiation() {
48 final int[] subn = { TelnetOption.WINDOW_SIZE, 24, 80 };
49
50 final int[] resp1 = opthand1.answerSubnegotiation(subn, subn.length);
51 final int[] resp2 = opthand2.answerSubnegotiation(subn, subn.length);
52 final int[] resp3 = opthand3.answerSubnegotiation(subn, subn.length);
53
54 assertNull(resp1);
55 assertNull(resp2);
56 assertNull(resp3);
57 }
58
59
60
61
62 @Override
63 public void testConstructors() {
64 assertEquals(TelnetOption.WINDOW_SIZE, opthand1.getOptionCode());
65 super.testConstructors();
66 }
67
68
69
70
71 @Override
72 public void testStartSubnegotiation() {
73 assertNull(opthand1.startSubnegotiationRemote());
74 assertNull(opthand2.startSubnegotiationRemote());
75 assertNull(opthand3.startSubnegotiationRemote());
76 }
77
78
79
80
81
82 public void testStartSubnegotiationLocal() {
83 final int[] exp1 = { 31, 0, 80, 0, 24 };
84 final int[] start1 = opthand1.startSubnegotiationLocal();
85 assertEquals(5, start1.length);
86 equalInts(exp1, start1);
87
88 final int[] exp2 = { 31, 0, 255, 255, 0, 255, 255 };
89 final int[] start2 = opthand2.startSubnegotiationLocal();
90 equalInts(exp2, start2);
91
92 final int[] exp3 = { 31, 255, 255, 255, 255, 0, 255, 255 };
93 final int[] start3 = opthand3.startSubnegotiationLocal();
94 equalInts(exp3, start3);
95 }
96 }