org.apache.commons.net.telnet.EchoOptionHandler Java Examples

The following examples show how to use org.apache.commons.net.telnet.EchoOptionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TelnetHandlerTest.java    From termd with Apache License 2.0 6 votes vote down vote up
@Test
public void testRejectEcho() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<Boolean>();
  EchoOptionHandler optionHandler = new EchoOptionHandler(false, false, false, false);
  testOptionValue(new Supplier<TelnetHandler>() {
    @Override
    public TelnetHandler get() {
      return new TelnetHandler() {
        @Override
        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());
}
 
Example #2
Source File: TelnetHandlerTest.java    From termd with Apache License 2.0 6 votes vote down vote up
@Test
public void testAcceptEcho() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<Boolean>();
  EchoOptionHandler optionHandler = new EchoOptionHandler(false, false, false, true);
  testOptionValue(new Supplier<TelnetHandler>() {
    @Override
    public TelnetHandler get() {
      return new TelnetHandler() {
        @Override
        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());
}
 
Example #3
Source File: TelnetHandlerTest.java    From aesh-readline with Apache License 2.0 6 votes vote down vote up
@Test
public void testRejectEcho() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  EchoOptionHandler optionHandler = new EchoOptionHandler(false, false, false, false);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    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());
}
 
Example #4
Source File: TelnetHandlerTest.java    From aesh-readline with Apache License 2.0 6 votes vote down vote up
@Test
public void testAcceptEcho() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  EchoOptionHandler optionHandler = new EchoOptionHandler(false, false, false, true);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    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());
}
 
Example #5
Source File: TelnetHandlerTest.java    From termd with Apache License 2.0 6 votes vote down vote up
@Test
public void testRejectEcho() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  EchoOptionHandler optionHandler = new EchoOptionHandler(false, false, false, false);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    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());
}
 
Example #6
Source File: TelnetHandlerTest.java    From termd with Apache License 2.0 6 votes vote down vote up
@Test
public void testAcceptEcho() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  EchoOptionHandler optionHandler = new EchoOptionHandler(false, false, false, true);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    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());
}
 
Example #7
Source File: TelnetTtyTestBase.java    From termd with Apache License 2.0 5 votes vote down vote up
@Override
protected void assertConnect(String term) throws Exception {
  client.setOptionHandler(new EchoOptionHandler(false, false, true, true));
  if (binary) {
    client.setOptionHandler(new SimpleOptionHandler(0, false, false, true, true));
  }
  if (term != null) {
    client.setOptionHandler(new TerminalTypeOptionHandler(term, false, false, true, false));
  }
  client.connect("localhost", 4000);
}
 
Example #8
Source File: TelnetTtyTestBase.java    From aesh-readline with Apache License 2.0 5 votes vote down vote up
@Override
protected void assertConnect(String term) throws Exception {
  client.setOptionHandler(new EchoOptionHandler(false, false, true, true));
  if (binary) {
    client.setOptionHandler(new SimpleOptionHandler(0, false, false, true, true));
  }
  if (term != null) {
    client.setOptionHandler(new TerminalTypeOptionHandler(term, false, false, true, false));
  }
  client.connect("localhost", 4000);
}
 
Example #9
Source File: TelnetTermServerTest.java    From vertx-shell with Apache License 2.0 5 votes vote down vote up
@Before
public void before() throws Exception {
  vertx = Vertx.vertx();
  client = new TelnetClient();
  client.addOptionHandler(new EchoOptionHandler(false, false, true, true));
  client.addOptionHandler(new SimpleOptionHandler(0, false, false, true, true));
  client.addOptionHandler(new TerminalTypeOptionHandler("xterm-color", false, false, true, false));
}
 
Example #10
Source File: TelnetTtyTestBase.java    From termd with Apache License 2.0 5 votes vote down vote up
@Override
protected void assertConnect(String term) throws Exception {
  client.setOptionHandler(new EchoOptionHandler(false, false, true, true));
  if (binary) {
    client.setOptionHandler(new SimpleOptionHandler(0, false, false, true, true));
  }
  if (term != null) {
    client.setOptionHandler(new TerminalTypeOptionHandler(term, false, false, true, false));
  }
  client.connect("localhost", 4000);
}