@Test
public void start() throws Exception {

    String host = "127.0.0.1";
    int port = 17701;
    ServerConfig serverConfig = new ServerConfig();
    serverConfig.setBoundHost(host);
    serverConfig.setPort(port);
    serverConfig.setProtocol(RpcConstants.PROTOCOL_TYPE_BOLT);
    BoltServer server = new BoltServer();
    server.init(serverConfig);
    server.start();
    Assert.assertTrue(server.started);
    Assert.assertTrue(NetUtils.canTelnet(host, port, 1000));
    // start use bound port will throw exception
    ServerConfig serverConfig2 = new ServerConfig();
    serverConfig2.setBoundHost(host);
    serverConfig2.setPort(port);
    serverConfig2.setProtocol(RpcConstants.PROTOCOL_TYPE_BOLT);
    BoltServer server2 = new BoltServer();
    server2.init(serverConfig2);
    boolean error = false;
    try {
        server2.start();
    } catch (Exception e) {
        error = true;
    }
    Assert.assertTrue(error);
    server.stop();
    Assert.assertFalse(server.started);
    Thread.sleep(1000); // 升级bolt后删除此行
    Assert.assertFalse(NetUtils.canTelnet(host, port, 1000));
    server.start();
    Assert.assertTrue(server.started);
    Assert.assertTrue(NetUtils.canTelnet(host, port, 1000));
    server.stop();
    Assert.assertFalse(server.started);
    Thread.sleep(1000); // 升级bolt后删除此行
    Assert.assertFalse(NetUtils.canTelnet(host, port, 1000));
    server.destroy();
}