当前位置: 首页>>代码示例>>Java>>正文


Java WindowSizeOptionHandler类代码示例

本文整理汇总了Java中org.apache.commons.net.telnet.WindowSizeOptionHandler的典型用法代码示例。如果您正苦于以下问题:Java WindowSizeOptionHandler类的具体用法?Java WindowSizeOptionHandler怎么用?Java WindowSizeOptionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WindowSizeOptionHandler类属于org.apache.commons.net.telnet包,在下文中一共展示了WindowSizeOptionHandler类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAcceptNAWS

import org.apache.commons.net.telnet.WindowSizeOptionHandler; //导入依赖的package包/类
@Test
public void testAcceptNAWS() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  final AtomicReference<int[]> size = new AtomicReference<>();
  WindowSizeOptionHandler optionHandler = new WindowSizeOptionHandler(20, 10, false, false, true, false);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    protected void onOpen(TelnetConnection conn) {
      conn.writeDoOption(Option.NAWS);
    }
    @Override
    protected void onNAWS(boolean naws) {
      serverValue.set(naws);
    }
    @Override
    protected void onSize(int width, int height) {
      size.set(new int[]{width, height});
      testComplete();
    }
  }, optionHandler);
  assertEquals(true, serverValue.get());
  assertEquals(true, optionHandler.getAcceptLocal());
  assertEquals(2, size.get().length);
  assertEquals(20, size.get()[0]);
  assertEquals(10, size.get()[1]);
}
 
开发者ID:aeshell,项目名称:aesh-readline,代码行数:27,代码来源:TelnetHandlerTest.java

示例2: testSizeHandler

import org.apache.commons.net.telnet.WindowSizeOptionHandler; //导入依赖的package包/类
@Test
public void testSizeHandler() throws Exception {
  final CountDownLatch latch1 = new CountDownLatch(1);
  final CountDownLatch latch2 = new CountDownLatch(1);
  server.start(() -> {
    final AtomicInteger count = new AtomicInteger();
    return new TelnetTtyConnection(false, false, StandardCharsets.UTF_8, conn -> {
      conn.setSizeHandler(size -> {
        switch (count.getAndIncrement()) {
          case 0:
            assertEquals(20, size.getWidth());
            assertEquals(10, size.getHeight());
            latch1.countDown();
            break;
          case 1:
            assertEquals(80, size.getWidth());
            assertEquals(24, size.getHeight());
            latch2.countDown();
            break;
          case 2:
            assertEquals(180, size.getWidth());
            assertEquals(160, size.getHeight());
            testComplete();
            break;
          default:
            fail("Was not expecting that");
        }
      });
    });
  });
  WindowSizeOptionHandler optionHandler = new WindowSizeOptionHandler(20, 10, false, false, true, false);
  client.setOptionHandler(optionHandler);
  client.connect("localhost", 4000);
  latch1.await(30, TimeUnit.SECONDS);
  client.writeDirectAndFlush(new byte[]{TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SB, 31, 0, 80, 0, 24, TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SE});
  latch2.await(30, TimeUnit.SECONDS);
  client.writeDirectAndFlush(new byte[]{TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SB, 31, 0, (byte) 180, 0, (byte) 160, TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SE});
  await();
}
 
开发者ID:aeshell,项目名称:aesh-readline,代码行数:40,代码来源:TelnetTermTest.java

示例3: testRejectNAWS

import org.apache.commons.net.telnet.WindowSizeOptionHandler; //导入依赖的package包/类
@Test
public void testRejectNAWS() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  WindowSizeOptionHandler optionHandler = new WindowSizeOptionHandler(20, 10, false, false, false, false);
  testOptionValue(new Supplier<TelnetHandler>() {
    @Override
    public TelnetHandler get() {
      return new TelnetHandler() {
        @Override
        protected void onOpen(TelnetConnection conn) {
          conn.writeDoOption(Option.NAWS);
        }
        @Override
        protected void onNAWS(boolean naws) {
          serverValue.set(naws);
          testComplete();
        }
        @Override
        protected void onSize(int width, int height) {
          super.onSize(width, height);
        }
      };
    }
  }, optionHandler);
  assertEquals(false, serverValue.get());
  assertEquals(false, optionHandler.getAcceptLocal());
}
 
开发者ID:aeshell,项目名称:aesh-readline,代码行数:28,代码来源:TelnetHandlerTest.java

示例4: testWindowSize

import org.apache.commons.net.telnet.WindowSizeOptionHandler; //导入依赖的package包/类
@Test
public void testWindowSize(TestContext context) throws Exception {
  Async async = context.async();
  startTelnet(context, term -> {
    context.assertEquals(-1, term.width());
    context.assertEquals(-1, term.height());
    term.resizehandler(v -> {
      context.assertEquals(10, term.width());
      context.assertEquals(20, term.height());
      async.complete();
    });
  });
  client.addOptionHandler(new WindowSizeOptionHandler(10, 20, false, false, true, false));
  client.connect("localhost", server.actualPort());
}
 
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:16,代码来源:TelnetTermServerTest.java

示例5: testOutBinaryTrue

import org.apache.commons.net.telnet.WindowSizeOptionHandler; //导入依赖的package包/类
@Test
public void testOutBinaryTrue(TestContext context) throws Exception {
  startTelnet(context, new TelnetTermOptions().setOutBinary(true), term -> {
    term.write("\u20AC");
  });
  client.addOptionHandler(new WindowSizeOptionHandler(10, 20, false, false, true, false));
  client.connect("localhost", server.actualPort());
  InputStream in = client.getInputStream();
  context.assertEquals(226, in.read());
  context.assertEquals(130, in.read());
  context.assertEquals(172, in.read());
}
 
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:13,代码来源:TelnetTermServerTest.java

示例6: testOutBinaryFalse

import org.apache.commons.net.telnet.WindowSizeOptionHandler; //导入依赖的package包/类
@Test
public void testOutBinaryFalse(TestContext context) throws Exception {
  byte[] expected = StandardCharsets.US_ASCII.encode("€").array();
  startTelnet(context, new TelnetTermOptions().setOutBinary(false), term -> {
    term.write("\u20AC");
  });
  client.addOptionHandler(new WindowSizeOptionHandler(10, 20, false, false, true, false));
  client.connect("localhost", server.actualPort());
  InputStream in = client.getInputStream();
  for (int i = 0;i < expected.length;i++) {
    context.assertEquals((int)expected[i], in.read());
  }
}
 
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:14,代码来源:TelnetTermServerTest.java

示例7: testSizeHandler

import org.apache.commons.net.telnet.WindowSizeOptionHandler; //导入依赖的package包/类
@Test
public void testSizeHandler() throws Exception {
  final CountDownLatch latch1 = new CountDownLatch(1);
  final CountDownLatch latch2 = new CountDownLatch(1);
  server.start(() -> {
    final AtomicInteger count = new AtomicInteger();
    return new TelnetTtyConnection(false, false, StandardCharsets.UTF_8, conn -> {
      conn.setSizeHandler(size -> {
        switch (count.getAndIncrement()) {
          case 0:
            assertEquals(20, size.x());
            assertEquals(10, size.y());
            latch1.countDown();
            break;
          case 1:
            assertEquals(80, size.x());
            assertEquals(24, size.y());
            latch2.countDown();
            break;
          case 2:
            assertEquals(180, size.x());
            assertEquals(160, size.y());
            testComplete();
            break;
          default:
            fail("Was not expecting that");
        }
      });
    });
  });
  WindowSizeOptionHandler optionHandler = new WindowSizeOptionHandler(20, 10, false, false, true, false);
  client.setOptionHandler(optionHandler);
  client.connect("localhost", 4000);
  latch1.await(30, TimeUnit.SECONDS);
  client.writeDirectAndFlush(new byte[]{TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SB, 31, 0, 80, 0, 24, TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SE});
  latch2.await(30, TimeUnit.SECONDS);
  client.writeDirectAndFlush(new byte[]{TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SB, 31, 0, (byte) 180, 0, (byte) 160, TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SE});
  await();
}
 
开发者ID:termd,项目名称:termd,代码行数:40,代码来源:TelnetTermTest.java

示例8: testSize

import org.apache.commons.net.telnet.WindowSizeOptionHandler; //导入依赖的package包/类
@Override
public void testSize() throws Exception {
  wsHandler = new WindowSizeOptionHandler(80, 24, false, false, true, true);
  client.setOptionHandler(wsHandler);
  super.testSize();
}
 
开发者ID:aeshell,项目名称:aesh-readline,代码行数:7,代码来源:TelnetTtyTestBase.java


注:本文中的org.apache.commons.net.telnet.WindowSizeOptionHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。