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

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

Introduction

In this page you can find the example usage for org.apache.commons.net.telnet SuppressGAOptionHandler 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 testAcceptSGA() throws Exception {
    final AtomicReference<Boolean> serverValue = new AtomicReference<>();
    SuppressGAOptionHandler optionHandler = new SuppressGAOptionHandler(false, false, false, true);
    testOptionValue(() -> new TelnetHandler() {
        @Override//from   w  ww .  j a  v  a 2 s.  c  om
        protected void onOpen(TelnetConnection conn) {
            conn.writeWillOption(Option.SGA);
        }

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

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

@Test
public void testRejectSGA() throws Exception {
    final AtomicReference<Boolean> serverValue = new AtomicReference<>();
    SuppressGAOptionHandler optionHandler = new SuppressGAOptionHandler(false, false, false, false);
    testOptionValue(() -> new TelnetHandler() {
        @Override//from   w ww .  j  a va 2  s  .c  o m
        protected void onOpen(TelnetConnection conn) {
            conn.writeWillOption(Option.SGA);
        }

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