FileDocCategorySizeDatePackage
TerminalTypeOptionHandlerTest.javaAPI DocApache Commons NET 1.4.1 API3063Sat Dec 03 10:05:50 GMT 2005org.apache.commons.net.telnet

TerminalTypeOptionHandlerTest

public class TerminalTypeOptionHandlerTest extends TelnetOptionHandlerTestAbstract
JUnit test class for TerminalTypeOptionHandler

author
Bruno D'Avanzo

Fields Summary
Constructors Summary
Methods Summary
protected booleanequalInts(int[] a1, int[] a2)
compares two arrays of int

        if(a1.length != a2.length)
        {
            return(false);
        }
        else
        {
            boolean result = true;
            for(int ii=0; ii<a1.length; ii++)
            {
                if(a1[ii]!= a2[ii])
                    result = false;
            }
            return(result);
        }
    
public static voidmain(java.lang.String[] args)
main for running the test.

        junit.textui.TestRunner.run(TerminalTypeOptionHandlerTest.class);
    
protected voidsetUp()
setUp for the test.

        opthand1 = new TerminalTypeOptionHandler("VT100");
        opthand2 = new TerminalTypeOptionHandler("ANSI", true, true, true, true);
        opthand3 = new TerminalTypeOptionHandler("ANSI", false, false, false, false);
    
public voidtestAnswerSubnegotiation()
test of client-driven subnegotiation. Checks that the terminal type is sent

        int subn[] =
        {
            TelnetOption.TERMINAL_TYPE, 1
        };

        int expected1[] =
        {
            TelnetOption.TERMINAL_TYPE, 0, 'V", 'T", '1", '0", '0"
        };

        int expected2[] =
        {
            TelnetOption.TERMINAL_TYPE, 0, 'A", 'N", 'S", 'I"
        };

        int resp1[] = opthand1.answerSubnegotiation(subn, subn.length);
        int resp2[] = opthand2.answerSubnegotiation(subn, subn.length);

        assertTrue(equalInts(resp1, expected1));
        assertTrue(equalInts(resp2, expected2));
    
public voidtestConstructors()
test of the constructors.

        assertEquals(opthand1.getOptionCode(), TelnetOption.TERMINAL_TYPE);
        super.testConstructors();
    
public voidtestStartSubnegotiation()
test of client-driven subnegotiation. Checks that no subnegotiation is made.


        int resp1[] = opthand1.startSubnegotiationLocal();
        int resp2[] = opthand1.startSubnegotiationRemote();

        assertEquals(resp1, null);
        assertEquals(resp2, null);