Java源码示例:org.apache.commons.net.telnet.SuppressGAOptionHandler

示例1
@Test
public void testRejectSGA() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<Boolean>();
  SuppressGAOptionHandler optionHandler = new SuppressGAOptionHandler(false, false, false, false);
  testOptionValue(new Supplier<TelnetHandler>() {
    @Override
    public TelnetHandler get() {
      return new TelnetHandler() {
        @Override
        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());
}
 
示例2
@Test
public void testAcceptSGA() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<Boolean>();
  SuppressGAOptionHandler optionHandler = new SuppressGAOptionHandler(false, false, false, true);
  testOptionValue(new Supplier<TelnetHandler>() {
    @Override
    public TelnetHandler get() {
      return new TelnetHandler() {
        @Override
        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());
}
 
示例3
@Test
public void testRejectSGA() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  SuppressGAOptionHandler optionHandler = new SuppressGAOptionHandler(false, false, false, false);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    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());
}
 
示例4
@Test
public void testAcceptSGA() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  SuppressGAOptionHandler optionHandler = new SuppressGAOptionHandler(false, false, false, true);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    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());
}
 
示例5
@Test
public void testRejectSGA() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  SuppressGAOptionHandler optionHandler = new SuppressGAOptionHandler(false, false, false, false);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    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());
}
 
示例6
@Test
public void testAcceptSGA() throws Exception {
  final AtomicReference<Boolean> serverValue = new AtomicReference<>();
  SuppressGAOptionHandler optionHandler = new SuppressGAOptionHandler(false, false, false, true);
  testOptionValue(() -> new TelnetHandler() {
    @Override
    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());
}