@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); assertTrue(transmission.timeout()); assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT * 2); assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT * 2); assertTrue(transmission.timeout()); assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT * 4); assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT * 4); assertTrue(transmission.timeout()); assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT * 8); assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT * 8); assertTrue(transmission.timeout()); assertTrue(transmission.getNextTimeout() > MIN_INIT_TIMEOUT * 16); assertTrue(transmission.getNextTimeout() < MAX_INIT_TIMEOUT * 16); assertFalse(transmission.timeout()); }
public boolean timeout() { if (transmissionCount < MAX_RETRANSMIT) { this.nextTimeout = this.nextTimeout * 2; this.transmissionCount++; return true; } return false; }
CoapTransmission { public boolean timeout() { if (transmissionCount < MAX_RETRANSMIT) { this.nextTimeout = this.nextTimeout * 2; this.transmissionCount++; return true; } return false; } }
CoapTransmission { public boolean timeout() { if (transmissionCount < MAX_RETRANSMIT) { this.nextTimeout = this.nextTimeout * 2; this.transmissionCount++; return true; } return false; } CoapTransmission(IoSession session, CoapMessage message); }
CoapTransmission { public boolean timeout() { if (transmissionCount < MAX_RETRANSMIT) { this.nextTimeout = this.nextTimeout * 2; this.transmissionCount++; return true; } return false; } CoapTransmission(IoSession session, CoapMessage message); boolean timeout(); String getId(); CoapMessage getMessage(); ScheduledFuture<?> getRetryFuture(); void setRetryFuture(ScheduledFuture<?> retryFuture); long getNextTimeout(); static String uniqueId(IoSession session, CoapMessage message); }
CoapTransmission { public boolean timeout() { if (transmissionCount < MAX_RETRANSMIT) { this.nextTimeout = this.nextTimeout * 2; this.transmissionCount++; return true; } return false; } CoapTransmission(IoSession session, CoapMessage message); boolean timeout(); String getId(); CoapMessage getMessage(); ScheduledFuture<?> getRetryFuture(); void setRetryFuture(ScheduledFuture<?> retryFuture); long getNextTimeout(); static String uniqueId(IoSession session, CoapMessage message);  }