001: /*
002: * Copyright 2003-2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.net.telnet;
017:
018: import junit.framework.TestCase;
019:
020: /***
021: * The TelnetOptionHandlerTest is the abstract class for
022: * testing TelnetOptionHandler. It can be used to derive
023: * the actual test classes for TelnetOptionHadler derived
024: * classes, by adding creation of three new option handlers
025: * and testing of the specific subnegotiation behaviour.
026: * <p>
027: * @author Bruno D'Avanzo
028: ***/
029: public abstract class TelnetOptionHandlerTestAbstract extends TestCase {
030: TelnetOptionHandler opthand1;
031: TelnetOptionHandler opthand2;
032: TelnetOptionHandler opthand3;
033:
034: /***
035: * setUp for the test. The derived test class must implement
036: * this method by creating opthand1, opthand2, opthand3
037: * like in the following:
038: * opthand1 = new EchoOptionHandler();
039: * opthand2 = new EchoOptionHandler(true, true, true, true);
040: * opthand3 = new EchoOptionHandler(false, false, false, false);
041: ***/
042: protected abstract void setUp();
043:
044: /***
045: * test of the constructors. The derived class may add
046: * test of the option code.
047: ***/
048: public void testConstructors() {
049: // add test of the option code
050: assertTrue(!opthand1.getInitLocal());
051: assertTrue(!opthand1.getInitRemote());
052: assertTrue(!opthand1.getAcceptLocal());
053: assertTrue(!opthand1.getAcceptRemote());
054:
055: assertTrue(opthand2.getInitLocal());
056: assertTrue(opthand2.getInitRemote());
057: assertTrue(opthand2.getAcceptLocal());
058: assertTrue(opthand2.getAcceptRemote());
059:
060: assertTrue(!opthand3.getInitLocal());
061: assertTrue(!opthand3.getInitRemote());
062: assertTrue(!opthand3.getAcceptLocal());
063: assertTrue(!opthand3.getAcceptRemote());
064: }
065:
066: /***
067: * test of setWill/getWill
068: ***/
069: public void testWill() {
070: opthand2.setWill(true);
071: opthand3.setWill(false);
072:
073: assertTrue(!opthand1.getWill());
074: assertTrue(opthand2.getWill());
075: assertTrue(!opthand3.getWill());
076: }
077:
078: /***
079: * test of setDo/getDo
080: ***/
081: public void testDo() {
082: opthand2.setDo(true);
083: opthand3.setDo(false);
084:
085: assertTrue(!opthand1.getDo());
086: assertTrue(opthand2.getDo());
087: assertTrue(!opthand3.getDo());
088: }
089:
090: /***
091: * test of client-driven subnegotiation. Abstract test:
092: * the derived class should implement it.
093: ***/
094: public abstract void testStartSubnegotiation();
095:
096: /***
097: * test of server-driven subnegotiation. Abstract test:
098: * the derived class should implement it.
099: ***/
100: public abstract void testAnswerSubnegotiation();
101: // test subnegotiation
102: }
|