001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.commons.net.telnet; 018 019 /*** 020 * JUnit test class for EchoOptionHandler 021 * <p> 022 * @author Bruno D'Avanzo 023 ***/ 024 public class EchoOptionHandlerTest extends TelnetOptionHandlerTestAbstract 025 { 026 /*** 027 * main for running the test. 028 ***/ 029 public static void main(String args[]) 030 { 031 junit.textui.TestRunner.run(EchoOptionHandlerTest.class); 032 } 033 034 /*** 035 * setUp for the test. 036 ***/ 037 @Override 038 protected void setUp() 039 { 040 opthand1 = new EchoOptionHandler(); 041 opthand2 = new EchoOptionHandler(true, true, true, true); 042 opthand3 = new EchoOptionHandler(false, false, false, false); 043 } 044 045 /*** 046 * test of the constructors. 047 ***/ 048 @Override 049 public void testConstructors() 050 { 051 assertEquals(opthand1.getOptionCode(), TelnetOption.ECHO); 052 super.testConstructors(); 053 } 054 055 /*** 056 * test of client-driven subnegotiation. 057 * Checks that no subnegotiation is made. 058 ***/ 059 @Override 060 public void testStartSubnegotiation() 061 { 062 int resp1[] = opthand1.startSubnegotiationLocal(); 063 int resp2[] = opthand1.startSubnegotiationRemote(); 064 065 assertEquals(resp1, null); 066 assertEquals(resp2, null); 067 } 068 069 /*** 070 * test of server-driven subnegotiation. 071 * Checks that no subnegotiation is made. 072 ***/ 073 @Override 074 public void testAnswerSubnegotiation() 075 { 076 int subn[] = 077 { 078 TelnetCommand.IAC, TelnetCommand.SB, TelnetOption.ECHO, 079 1, TelnetCommand.IAC, TelnetCommand.SE, 080 }; 081 082 int resp1[] = opthand1.answerSubnegotiation(subn, subn.length); 083 084 assertEquals(resp1, null); 085 } 086 }