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

The following examples show how to use org.apache.commons.net.telnet.SimpleOptionHandler. 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 testWillUnknownOption() throws Exception {
  server.start(new Supplier<TelnetHandler>() {
    @Override
    public TelnetHandler get() {
      return new TelnetHandler();
    }
  });
  client.registerNotifHandler(new BiConsumer<Integer, Integer>() {
    @Override
    public void accept(Integer negotiation_code, Integer option_code) {
      if (option_code == 47) {
        assertEquals(TelnetNotificationHandler.RECEIVED_DONT, negotiation_code);
        testComplete();
      }
    }
  });
  client.setOptionHandler(new SimpleOptionHandler(47, true, false, false, false));
  client.connect("localhost", 4000);
  await();
}
 
Example #2
Source File: TelnetHandlerTest.java    From termd with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoUnknownOption() throws Exception {
  server.start(new Supplier<TelnetHandler>() {
    @Override
    public TelnetHandler get() {
      return new TelnetHandler();
    }
  });
  client.registerNotifHandler(new BiConsumer<Integer, Integer>() {
    @Override
    public void accept(Integer negotiation_code, Integer option_code) {
      if (option_code == 47) {
        assertEquals(TelnetNotificationHandler.RECEIVED_WONT, negotiation_code);
        testComplete();
      }
    }
  });
  client.setOptionHandler(new SimpleOptionHandler(47, false, true, false, false));
  client.connect("localhost", 4000);
  await();
}
 
Example #3
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 #4
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 #5
Source File: TelnetHandlerTest.java    From aesh-readline with Apache License 2.0 5 votes vote down vote up
@Test
public void testWillUnknownOption() throws Exception {
  server.start(TelnetHandler::new);
  client.registerNotifHandler((negotiation_code, option_code) -> {
    if (option_code == 47) {
      assertEquals(TelnetNotificationHandler.RECEIVED_DONT, negotiation_code);
      testComplete();
    }
  });
  client.setOptionHandler(new SimpleOptionHandler(47, true, false, false, false));
  client.connect("localhost", 4000);
  await();
}
 
Example #6
Source File: TelnetHandlerTest.java    From aesh-readline with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoUnknownOption() throws Exception {
  server.start(TelnetHandler::new);
  client.registerNotifHandler((negotiation_code, option_code) -> {
    if (option_code == 47) {
      assertEquals(TelnetNotificationHandler.RECEIVED_WONT, negotiation_code);
      testComplete();
    }
  });
  client.setOptionHandler(new SimpleOptionHandler(47, false, true, false, false));
  client.connect("localhost", 4000);
  await();
}
 
Example #7
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 #8
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 #9
Source File: TelnetHandlerTest.java    From termd with Apache License 2.0 5 votes vote down vote up
@Test
public void testWillUnknownOption() throws Exception {
  server.start(TelnetHandler::new);
  client.registerNotifHandler((negotiation_code, option_code) -> {
    if (option_code == 47) {
      assertEquals(TelnetNotificationHandler.RECEIVED_DONT, negotiation_code);
      testComplete();
    }
  });
  client.setOptionHandler(new SimpleOptionHandler(47, true, false, false, false));
  client.connect("localhost", 4000);
  await();
}
 
Example #10
Source File: TelnetHandlerTest.java    From termd with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoUnknownOption() throws Exception {
  server.start(TelnetHandler::new);
  client.registerNotifHandler((negotiation_code, option_code) -> {
    if (option_code == 47) {
      assertEquals(TelnetNotificationHandler.RECEIVED_WONT, negotiation_code);
      testComplete();
    }
  });
  client.setOptionHandler(new SimpleOptionHandler(47, false, true, false, false));
  client.connect("localhost", 4000);
  await();
}