@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
  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));
  }
  @Test
  public void testArray() {
    System.out.println(
        "-----------------------------------"
            + tcpRestServer.getClass().getCanonicalName()
            + "--------------------------------");
    tcpRestServer.addSingletonResource(new HelloWorldResource());

    HelloWorld client =
        (HelloWorld)
            Proxy.newProxyInstance(
                HelloWorld.class.getClassLoader(),
                new Class[] {HelloWorld.class},
                new TcpRestClientProxy(
                    HelloWorld.class.getCanonicalName(),
                    "localhost",
                    tcpRestServer.getServerPort()));

    String[] in = new String[] {"a", "b", "c"};
    String[] out = client.getArray(in);
    for (int i = 0; i < in.length; i++) {
      assertEquals(in[i], out[i]);
    }
  }