@Test
public void timeout() {

    IoSession session = Mockito.mock(IoSession.class);
    Mockito.when(session.getId()).thenReturn(1L);
    CoapTransmission transmission = new CoapTransmission(session, new CoapMessage(1, MessageType.CONFIRMABLE, 1,
            1234, "token".getBytes(), null, "payload".getBytes()));
    assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT);
    assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT);
    // timeout #1
    assertTrue(transmission.timeout());
    assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT * 2);
    assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT * 2);
    // timeout #2
    assertTrue(transmission.timeout());
    assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT * 4);
    assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT * 4);
    // timeout #3
    assertTrue(transmission.timeout());
    assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT * 8);
    assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT * 8);
    // timeout #4
    assertTrue(transmission.timeout());
    assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT * 16);
    assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT * 16);
    // timeout #5 - no retry
    assertFalse(transmission.timeout());
}