1 16 package org.apache.commons.net.telnet; 17 18 23 public class TerminalTypeOptionHandlerTest extends TelnetOptionHandlerTestAbstract 24 { 25 28 public static void main(String args[]) 29 { 30 junit.textui.TestRunner.run(TerminalTypeOptionHandlerTest.class); 31 } 32 33 36 protected void setUp() 37 { 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 46 public void testConstructors() 47 { 48 assertEquals(opthand1.getOptionCode(), TelnetOption.TERMINAL_TYPE); 49 super.testConstructors(); 50 } 51 52 56 public void testStartSubnegotiation() 57 { 58 59 int resp1[] = opthand1.startSubnegotiationLocal(); 60 int resp2[] = opthand1.startSubnegotiationRemote(); 61 62 assertEquals(resp1, null); 63 assertEquals(resp2, null); 64 } 65 66 67 71 public void testAnswerSubnegotiation() 72 { 73 int subn[] = 74 { 75 TelnetOption.TERMINAL_TYPE, 1 76 }; 77 78 int expected1[] = 79 { 80 TelnetOption.TERMINAL_TYPE, 0, 'V', 'T', '1', '0', '0' 81 }; 82 83 int expected2[] = 84 { 85 TelnetOption.TERMINAL_TYPE, 0, 'A', 'N', 'S', 'I' 86 }; 87 88 int resp1[] = opthand1.answerSubnegotiation(subn, subn.length); 89 int resp2[] = opthand2.answerSubnegotiation(subn, subn.length); 90 91 assertTrue(equalInts(resp1, expected1)); 92 assertTrue(equalInts(resp2, expected2)); 93 } 94 95 96 99 protected boolean equalInts(int a1[], int a2[]) 100 { 101 if(a1.length != a2.length) 102 { 103 return(false); 104 } 105 else 106 { 107 boolean result = true; 108 for(int ii=0; ii<a1.length; ii++) 109 { 110 if(a1[ii]!= a2[ii]) 111 result = false; 112 } 113 return(result); 114 } 115 } 116 } 117 | Popular Tags |