예제 #1
0
  @Test
  public void testTCPClientWithDefaultConnections() {
    Log.setLogLevel(LogLevel.DEBUG);

    TCPClient client =
        TCP.client()
            .host("localhost")
            .port(8080)
            .connections(5)
            .protocol(HI_CLIENT)
            .build()
            .start();

    // let the clients wait
    UTILS.sleep(3000);

    TCPServer server = TCP.server().port(8080).protocol(UPPERCASE_SERVER).build().start();

    // let the server serve the clients
    UTILS.sleep(3000);

    eq(client.info().messagesProcessed(), 5);
    eq(server.info().messagesProcessed(), 5);

    client.shutdown();
    server.shutdown();
  }
예제 #2
0
  @Test
  public void testTCPClientWithDefaultAndCustomConnections() {
    Log.setLogLevel(LogLevel.DEBUG);

    TCPClient client =
        TCP.client()
            .host("127.0.0.1")
            .port(8080)
            .connections(3)
            .protocol(HI_CLIENT)
            .build()
            .start();
    client.connect("localhost", 9090, HI_CLIENT, 2, false, null);

    // let the clients wait
    UTILS.sleep(3000);

    TCPServer server1 = TCP.server().port(8080).protocol(UPPERCASE_SERVER).build().start();
    TCPServer server2 = TCP.server().port(9090).protocol(UPPERCASE_SERVER).build().start();

    // let the servers serve the clients
    UTILS.sleep(3000);

    eq(client.info().messagesProcessed(), 5);
    eq(server1.info().messagesProcessed(), 3);
    eq(server2.info().messagesProcessed(), 2);

    client.shutdown();
    server1.shutdown();
    server2.shutdown();
  }