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