示例#1
0
  @Test
  public void testEcho() throws CoordinatorException, InterruptedException, IOException {
    server.addService(EchoRequest.class, EchoService.class);

    server.start();

    this.client.requestEPUBlocking("/echo");

    EPU epu = this.client.epu("/echo");

    epu.request(new EchoRequest("TEST! "));

    Thread.sleep(1500);

    Object o = this.client.epu("/echo").getResponse();
    log.debug("Received object of type: " + o.getClass());

    EchoResponse resp = (EchoResponse) o;

    log.debug("Received message: " + resp.getValue());
    log.debug("\tfrom: " + resp.getNodePath());

    assertEquals("TEST! TEST! ", resp.getValue());
    assertEquals("/default/echo", resp.getNodePath());
  }
示例#2
0
  @Test
  public void testReadWrongNode() throws CoordinatorException, InterruptedException, IOException {
    server.addService(EchoRequest.class, EchoService.class);

    server.start();

    this.client.requestEPUBlocking("/echo");

    this.client.epu("/echo").request(new EchoRequest("TEST! "));

    Thread.sleep(1500);

    log.warn("Making impossible request");
    Object o = this.client.epu("/does-not-exist");
    if (o != null) {
      log.info("Received object of type: " + o.getClass());

      EchoResponse resp = (EchoResponse) o;

      log.info("Received message: " + resp.getValue());
      log.info("\tfrom: " + resp.getNodePath());
      fail();
    }
  }