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 SimpleOptionHandler
021     * <p>
022     * @author Bruno D'Avanzo
023     ***/
024    public class SimpleOptionHandlerTest extends TelnetOptionHandlerTestAbstract
025    {
026        /***
027         * main for running the test.
028         ***/
029        public static void main(String args[])
030        {
031            junit.textui.TestRunner.run(SimpleOptionHandlerTest.class);
032        }
033    
034        /***
035         * setUp for the test.
036         ***/
037        @Override
038        protected void setUp()
039        {
040            opthand1 = new SimpleOptionHandler(4);
041            opthand2 = new SimpleOptionHandler(8, true, true, true, true);
042            opthand3 = new SimpleOptionHandler(91, false, false, false, false);
043        }
044    
045        /***
046         * test of the constructors.
047         ***/
048        @Override
049        public void testConstructors()
050        {
051            assertEquals(opthand1.getOptionCode(), 4);
052            assertEquals(opthand2.getOptionCode(), 8);
053            assertEquals(opthand3.getOptionCode(), 91);
054            super.testConstructors();
055        }
056    
057        /***
058         * test of client-driven subnegotiation.
059         * Checks that no subnegotiation is made.
060         ***/
061        @Override
062        public void testStartSubnegotiation()
063        {
064    
065            int resp1[] = opthand1.startSubnegotiationLocal();
066            int resp2[] = opthand1.startSubnegotiationRemote();
067    
068            assertEquals(resp1, null);
069            assertEquals(resp2, null);
070        }
071    
072        /***
073         * test of server-driven subnegotiation.
074         * Checks that no subnegotiation is made.
075         ***/
076        @Override
077        public void testAnswerSubnegotiation()
078        {
079            int subn[] =
080            {
081                TelnetCommand.IAC, TelnetCommand.SB, 4,
082                1, TelnetCommand.IAC, TelnetCommand.SE,
083            };
084    
085            int resp1[] = opthand1.answerSubnegotiation(subn, subn.length);
086    
087            assertEquals(resp1, null);
088        }
089    }