protected void server(final Consumer<TtyConnection> onConnect) { server.start(new Supplier<TelnetHandler>() { @Override public TelnetHandler get() { return new TelnetTtyConnection(binary, binary, charset, onConnect); } }); }
protected void server(Consumer<TtyConnection> onConnect) { server.start(() -> new TelnetTtyConnection(binary, binary, charset, onConnect)); }
protected void server(Consumer<TtyConnection> onConnect) { server.start(() -> new TelnetTtyConnection(binary, binary, charset, onConnect)); }
@Test public void testOpen() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onOpen(TelnetConnection conn) { testComplete(); } }); client.connect("localhost", 4000); await(); }
private void testOptionValue(Supplier<TelnetHandler> factory, TelnetOptionHandler optionHandler) throws Exception { server.start(factory); client.setOptionHandler(optionHandler); client.connect("localhost", 4000); await(); }
@Test public void testOpen() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onOpen(TelnetConnection conn) { testComplete(); } }); client.connect("localhost", 4000); await(); }
private void testOptionValue(Supplier<TelnetHandler> factory, TelnetOptionHandler optionHandler) throws Exception { server.start(factory); client.setOptionHandler(optionHandler); client.connect("localhost", 4000); await(); }
private void testOptionValue(Supplier<TelnetHandler> factory, TelnetOptionHandler optionHandler) throws Exception { server.start(factory); client.setOptionHandler(optionHandler); client.connect("localhost", 4000); await(); }
@Test public void testServerClose() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onOpen(TelnetConnection conn) { conn.close(); } @Override protected void onClose() { testComplete(); } }); client.connect("localhost", 4000); await(); }
@Test public void testServerClose() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onOpen(TelnetConnection conn) { conn.close(); } @Override protected void onClose() { testComplete(); } }); client.connect("localhost", 4000); await(); }
@Test public void testOpen() throws Exception { server.start(new Supplier<TelnetHandler>() { @Override public TelnetHandler get() { return new TelnetHandler() { @Override protected void onOpen(TelnetConnection conn) { testComplete(); } }; } }); client.connect("localhost", 4000); await(); }
@Test public void testClientDisconnect() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onClose() { testComplete(); } }); try { client.connect("localhost", 4000); } finally { client.disconnect(); } await(); }
@Test public void testClientDisconnect() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onClose() { testComplete(); } }); try { client.connect("localhost", 4000); } finally { client.disconnect(); } await(); }
@Test public void testReceive() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onData(byte[] data) { assertEquals(7, data.length); assertEquals((byte) 0, data[0]); assertEquals((byte) 1, data[1]); assertEquals((byte) 2, data[2]); assertEquals((byte) 3, data[3]); assertEquals((byte) 127, data[4]); assertEquals((byte) 0x80, data[5]); assertEquals((byte) 0x81, data[6]); testComplete(); } }); client.connect("localhost", 4000).write(new byte[]{0, 1, 2, 3, 127, (byte) 0x80, (byte) 0x81}).flush(); await(); }
@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(); }
@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(); }
@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(); }
@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(); }
@Test public void testSend() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onOpen(TelnetConnection conn) { conn.write(new byte[]{0, 1, 2, 3, 127, (byte) 0x80, (byte) 0x81, -1}); } }); client.connect("localhost", 4000); byte[] data = client.assertReadBytes(8); assertEquals((byte)0, data[0]); assertEquals((byte)1, data[1]); assertEquals((byte)2, data[2]); assertEquals((byte)3, data[3]); assertEquals((byte)127, data[4]); assertEquals((byte)0, data[5]); assertEquals((byte)1, data[6]); assertEquals((byte)127, data[7]); }
@Test public void testSend() throws Exception { server.start(() -> new TelnetHandler() { @Override protected void onOpen(TelnetConnection conn) { conn.write(new byte[]{0, 1, 2, 3, 127, (byte) 0x80, (byte) 0x81, -1}); } }); client.connect("localhost", 4000); byte[] data = client.assertReadBytes(8); assertEquals((byte)0, data[0]); assertEquals((byte)1, data[1]); assertEquals((byte)2, data[2]); assertEquals((byte)3, data[3]); assertEquals((byte)127, data[4]); assertEquals((byte)0, data[5]); assertEquals((byte)1, data[6]); assertEquals((byte)127, data[7]); }