Example usage for org.apache.commons.net.telnet EchoOptionHandler getAcceptRemote

List of usage examples for org.apache.commons.net.telnet EchoOptionHandler getAcceptRemote

Introduction

In this page you can find the example usage for org.apache.commons.net.telnet EchoOptionHandler getAcceptRemote.

Prototype

public boolean getAcceptRemote() 

Source Link

Document

Returns a boolean indicating whether to accept a WILL request coming from the other end.

Usage

From source file:io.termd.core.telnet.TelnetHandlerTest.java

@Test
public void testAcceptEcho() throws Exception {
    final AtomicReference<Boolean> serverValue = new AtomicReference<>();
    EchoOptionHandler optionHandler = new EchoOptionHandler(false, false, false, true);
    testOptionValue(() -> new TelnetHandler() {
        @Override//ww w . jav a 2 s  .c o m
        protected void onOpen(TelnetConnection conn) {
            conn.writeWillOption(Option.ECHO);
        }

        @Override
        protected void onEcho(boolean echo) {
            serverValue.set(echo);
            testComplete();
        }
    }, optionHandler);
    assertEquals(true, serverValue.get());
    assertEquals(true, optionHandler.getAcceptRemote());
}

From source file:io.termd.core.telnet.TelnetHandlerTest.java

@Test
public void testRejectEcho() throws Exception {
    final AtomicReference<Boolean> serverValue = new AtomicReference<>();
    EchoOptionHandler optionHandler = new EchoOptionHandler(false, false, false, false);
    testOptionValue(() -> new TelnetHandler() {
        @Override/*  www .  ja  v a  2  s  .  c  om*/
        protected void onOpen(TelnetConnection conn) {
            conn.writeWillOption(Option.ECHO);
        }

        @Override
        protected void onEcho(boolean echo) {
            serverValue.set(echo);
            testComplete();
        }
    }, optionHandler);
    assertEquals(false, serverValue.get());
    assertEquals(false, optionHandler.getAcceptRemote());
}