Exemplo n.º 1
0
  @Theory
  public void shouldStopRetransmitOnRetransmitReception(
      final BiConsumer<RetransmitHandlerTest, Integer> creator) {
    createTermBuffer(creator, 5);
    handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
    handler.onRetransmitReceived(TERM_ID, offsetOfFrame(0));
    processTimersUntil(() -> wheel.clock().nanoTime() >= TimeUnit.MILLISECONDS.toNanos(100));

    verifyZeroInteractions(retransmitSender);
  }
Exemplo n.º 2
0
  @Theory
  public void shouldRetransmitOnNakAfterLinger(
      final BiConsumer<RetransmitHandlerTest, Integer> creator) {
    createTermBuffer(creator, 5);
    handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
    processTimersUntil(() -> wheel.clock().nanoTime() >= TimeUnit.MILLISECONDS.toNanos(100));
    handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
    processTimersUntil(() -> wheel.clock().nanoTime() >= TimeUnit.MILLISECONDS.toNanos(200));

    verify(retransmitSender, times(2)).resend(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
  }
Exemplo n.º 3
0
  @Theory
  public void shouldGoIntoLingerOnImmediateRetransmit(
      final BiConsumer<RetransmitHandlerTest, Integer> creator) {
    createTermBuffer(creator, 5);
    handler = newZeroDelayRetransmitHandler();

    handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
    processTimersUntil(() -> wheel.clock().nanoTime() >= TimeUnit.MILLISECONDS.toNanos(40));
    handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);

    verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
  }
Exemplo n.º 4
0
  @Theory
  public void shouldOnlyRetransmitOnNakWhenConfiguredTo(
      final BiConsumer<RetransmitHandlerTest, Integer> creator) {
    createTermBuffer(creator, 5);
    handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);

    verifyZeroInteractions(retransmitSender);
  }
Exemplo n.º 5
0
  @Theory
  public void shouldImmediateRetransmitOnNak(
      final BiConsumer<RetransmitHandlerTest, Integer> creator) {
    createTermBuffer(creator, 5);
    handler = newZeroDelayRetransmitHandler();

    handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);

    verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
  }
Exemplo n.º 6
0
  @Theory
  public void shouldRetransmitOnNakOverMtuLength(
      final BiConsumer<RetransmitHandlerTest, Integer> creator) {
    final int numFramesPerMtu = MTU_LENGTH / ALIGNED_FRAME_LENGTH;
    createTermBuffer(creator, numFramesPerMtu * 5);
    handler.onNak(TERM_ID, offsetOfFrame(0), MTU_LENGTH * 2);
    processTimersUntil(() -> wheel.clock().nanoTime() >= TimeUnit.MILLISECONDS.toNanos(100));

    verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), MTU_LENGTH * 2);
  }