/**
   * Retransmission intervals (RC = Retransmission Counter): immediately send CON message, set RC =
   * 0 wait 2 - 3 sec then send retransmission, set RC = 1 wait 4 - 6 sec then send retransmission,
   * set RC = 2 wait 8 - 12 sec then send retransmission, set RC = 3 wait 16 - 24 sec then send
   * retransmission, set RC = 4 wait 32 - 48 sec then fail transmission
   *
   * @throws Exception
   */
  @Override
  public void createTestScenario() throws Exception {

    //             client                        testEndpoint     DESCRIPTION
    //                  |                             |
    //              (1) |----CON-GET----------------->|           Client sends confirmable request
    //                  |                             |
    //              (2) |----1st RETRANSMISSION------>|           (Client should send four
    // retransmissions)
    //                  |                             |
    //              (3) |----2nd RETRANSMISSION------>|
    //                  |                             |
    //              (4) |----3rd RETRANSMISSION------>|
    //                  |                             |
    //              (5) |----4th RETRANSMISSION------>|
    //                  |                             |
    //                  |                             |           internal timeout notification to
    // response processor

    // Send coapRequest
    InetSocketAddress remoteEndpoint = new InetSocketAddress("127.0.0.1", testEndpoint.getPort());
    client.sendCoapRequest(coapRequest, responseProcessor, remoteEndpoint);

    timeRequestSent = System.currentTimeMillis();

    // Wait for the message ID to retire (takes 247 seconds).
    Thread.sleep(50000);
    log.warn(
        "Now we have to wait for the message ID to time out (~200 seconds)... Time to get a coffee!");
    Thread.sleep(200000);
  }
  @Override
  public void setupComponents() throws Exception {
    testEndpoint = new CoapTestEndpoint();

    client = new CoapClientApplication("CoAP Testclient");
    responseProcessor = new CoapResponseTestProcessor();
    URI targetUri = new URI("coap://localhost:" + testEndpoint.getPort() + "/testpath");
    coapRequest = new CoapRequest(MessageType.Name.CON, MessageCode.Name.GET, targetUri);
  }
  @Test
  public void testAllRequestsAreEqual() {
    SortedMap<Long, CoapMessage> receivedMessages = testEndpoint.getReceivedCoapMessages();
    CoapMessage firstMessage = receivedMessages.get(receivedMessages.firstKey());

    for (CoapMessage message : receivedMessages.values()) {
      assertEquals("Received requests did not equal.", firstMessage, message);
    }
  }
 @Override
 public void shutdownComponents() throws Exception {
   client.shutdown();
   testEndpoint.shutdown();
 }
 @Test
 public void testNumberOfReceivedRequests() {
   int expected = 5;
   int actual = testEndpoint.getReceivedCoapMessages().size();
   assertEquals("Endpoint received wrong number of requests!", expected, actual);
 }