Example #1
0
  @Test
  public void testNonConfirmable() throws Exception {
    // send request
    Request req2acc = new Request(Code.POST);
    req2acc.setConfirmable(false);
    req2acc.setURI("localhost:" + serverPort + "/" + ACC_RESOURCE);
    req2acc.setPayload("client says hi");
    req2acc.send();

    // receive response and check
    Response response = req2acc.waitForResponse(100);
    assertNotNull(response);
    assertEquals(response.getPayloadString(), SERVER_RESPONSE);
    assertEquals(response.getType(), Type.NON);

    Request req2noacc = new Request(Code.POST);
    req2noacc.setConfirmable(false);
    req2noacc.setURI("coap://localhost:" + serverPort + "/" + NO_ACC_RESOURCE);
    req2noacc.setPayload("client says hi");
    req2noacc.send();

    // receive response and check
    response = req2noacc.waitForResponse(100);
    assertNotNull(response);
    assertEquals(response.getPayloadString(), SERVER_RESPONSE);
    assertEquals(response.getType(), Type.NON);
  }
 /**
  * Gets the payload of this response as string.
  *
  * @return the response text
  */
 public String getResponseText() {
   return response.getPayloadString();
 }