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 TerminalTypeOptionHandlerTest extends TelnetOptionHandlerTestAbstract
25 {
26
27
28
29 @Override
30 protected void setUp()
31 {
32 opthand1 = new TerminalTypeOptionHandler("VT100");
33 opthand2 = new TerminalTypeOptionHandler("ANSI", true, true, true, true);
34 opthand3 = new TerminalTypeOptionHandler("ANSI", false, false, false, false);
35 }
36
37
38
39
40 @Override
41 public void testConstructors()
42 {
43 assertEquals(opthand1.getOptionCode(), TelnetOption.TERMINAL_TYPE);
44 super.testConstructors();
45 }
46
47
48
49
50
51 @Override
52 public void testStartSubnegotiation()
53 {
54
55 int resp1[] = opthand1.startSubnegotiationLocal();
56 int resp2[] = opthand1.startSubnegotiationRemote();
57
58 assertEquals(resp1, null);
59 assertEquals(resp2, null);
60 }
61
62
63
64
65
66
67 @Override
68 public void testAnswerSubnegotiation()
69 {
70 int subn[] =
71 {
72 TelnetOption.TERMINAL_TYPE, 1
73 };
74
75 int expected1[] =
76 {
77 TelnetOption.TERMINAL_TYPE, 0, 'V', 'T', '1', '0', '0'
78 };
79
80 int expected2[] =
81 {
82 TelnetOption.TERMINAL_TYPE, 0, 'A', 'N', 'S', 'I'
83 };
84
85 int resp1[] = opthand1.answerSubnegotiation(subn, subn.length);
86 int resp2[] = opthand2.answerSubnegotiation(subn, subn.length);
87
88 assertTrue(equalInts(resp1, expected1));
89 assertTrue(equalInts(resp2, expected2));
90 }
91
92
93
94
95
96 protected boolean equalInts(int a1[], int a2[])
97 {
98 if(a1.length != a2.length)
99 {
100 return(false);
101 }
102 else
103 {
104 boolean result = true;
105 for(int ii=0; ii<a1.length; ii++)
106 {
107 if(a1[ii]!= a2[ii]) {
108 result = false;
109 }
110 }
111 return(result);
112 }
113 }
114 }