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 public class TerminalTypeOptionHandlerTest extends AbstractTelnetOptionHandlerTest {
20
21
22
23 protected boolean equalInts(final int a1[], final int a2[]) {
24 if (a1.length != a2.length) {
25 return false;
26 }
27 boolean result = true;
28 for (int ii = 0; ii < a1.length; ii++) {
29 if (a1[ii] != a2[ii]) {
30 result = false;
31 }
32 }
33 return result;
34 }
35
36 @Override
37 protected void setUp() {
38 opthand1 = new TerminalTypeOptionHandler("VT100");
39 opthand2 = new TerminalTypeOptionHandler("ANSI", true, true, true, true);
40 opthand3 = new TerminalTypeOptionHandler("ANSI", false, false, false, false);
41 }
42
43
44
45
46 @Override
47 public void testAnswerSubnegotiation() {
48 final int[] subn = { TelnetOption.TERMINAL_TYPE, 1 };
49
50 final int[] expected1 = { TelnetOption.TERMINAL_TYPE, 0, 'V', 'T', '1', '0', '0' };
51
52 final int[] expected2 = { TelnetOption.TERMINAL_TYPE, 0, 'A', 'N', 'S', 'I' };
53
54 final int[] resp1 = opthand1.answerSubnegotiation(subn, subn.length);
55 final int[] resp2 = opthand2.answerSubnegotiation(subn, subn.length);
56
57 assertTrue(equalInts(resp1, expected1));
58 assertTrue(equalInts(resp2, expected2));
59 }
60
61 @Override
62 public void testConstructors() {
63 assertEquals(opthand1.getOptionCode(), TelnetOption.TERMINAL_TYPE);
64 super.testConstructors();
65 }
66
67
68
69
70 @Override
71 public void testStartSubnegotiation() {
72
73 final int[] resp1 = opthand1.startSubnegotiationLocal();
74 final int[] resp2 = opthand1.startSubnegotiationRemote();
75
76 assertNull(resp1);
77 assertNull(resp2);
78 }
79 }