@Test
  public void testSingletonResource() throws Exception {
    System.out.println(
        "-----------------------------------"
            + tcpRestServer.getClass().getCanonicalName()
            + "--------------------------------");

    Object instance = new SingletonCounterResource(2);
    tcpRestServer.addSingletonResource(instance);

    TcpRestClientFactory factory =
        new TcpRestClientFactory(Counter.class, "localhost", tcpRestServer.getServerPort());

    Counter client = factory.getInstance();
    assertEquals(2, client.getCounter());

    client.increaseCounter();
    assertEquals(3, client.getCounter());

    tcpRestServer.deleteSingletonResource(instance);

    tcpRestServer.addResource(SingletonCounterResource.class);
    assertEquals(0, client.getCounter());
    client.increaseCounter();
    assertEquals(0, client.getCounter());
  }
  @Test(expectedExceptions = Exception.class)
  public void clientSideTimeoutTest() {
    System.out.println(
        "-----------------------------------"
            + tcpRestServer.getClass().getCanonicalName()
            + "--------------------------------");

    tcpRestServer.addResource(HelloWorldResource.class);

    TcpRestClientFactory factory =
        new TcpRestClientFactory(HelloWorld.class, "localhost", tcpRestServer.getServerPort());

    HelloWorld client = (HelloWorld) factory.getInstance();
    client.timeout();
  }
  @Test
  public void testClient() throws Exception {

    System.out.println(
        "-----------------------------------"
            + tcpRestServer.getClass().getCanonicalName()
            + "--------------------------------");
    tcpRestServer.addResource(HelloWorldResource.class);

    TcpRestClientFactory factory =
        new TcpRestClientFactory(HelloWorld.class, "localhost", tcpRestServer.getServerPort());

    HelloWorld client = (HelloWorld) factory.getInstance();

    assertEquals("Hello, world!", client.helloWorld());
    assertEquals("a,2,true123.0111", client.allTypes("a", 2, true, (short) 1, 2L, 3.0, (byte) 'o'));
  }
  @Test
  public void testNullParameter() {

    System.out.println(
        "-----------------------------------"
            + tcpRestServer.getClass().getCanonicalName()
            + "--------------------------------");

    tcpRestServer.addSingletonResource(new NullParamResource());

    TcpRestClientFactory factory =
        new TcpRestClientFactory(NullParam.class, "localhost", tcpRestServer.getServerPort());

    NullParam client = factory.getInstance();

    assertEquals("onetwo", client.nullMethod("one", null, "two"));
  }
  @Test
  public void largeDataTest() {
    StringBuilder builder = new StringBuilder();
    String[] alpha = {"a", "b", "c", "d", "e", "f"};
    for (int i = 0; i < 1024 * 10; i++) {
      builder.append(alpha[i % alpha.length]);
    }
    String req = builder.toString();

    tcpRestServer.addSingletonResource(new HelloWorldResource());
    System.out.println(
        "-----------------------------------"
            + tcpRestServer.getClass().getCanonicalName()
            + "--------------------------------");
    TcpRestClientFactory factory =
        new TcpRestClientFactory(HelloWorld.class, "localhost", tcpRestServer.getServerPort());

    HelloWorld client = (HelloWorld) factory.getInstance();
    assertEquals(req, client.echo(req));
  }