Skip to content

Commit

Permalink
Add test for supplying CallOptions to transport state
Browse files Browse the repository at this point in the history
  • Loading branch information
jduo committed Mar 21, 2024
1 parent 63a454d commit f0cf726
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,21 @@ public void transportTrailersReceived_missingStatusAfterHeadersIgnoresHttpStatus
assertEquals(Code.UNKNOWN, statusCaptor.getValue().getCode());
}

@Test
public void transportStateWithOnReadyThreshold() {
BaseTransportState state = new BaseTransportState(transportTracer,
CallOptions.DEFAULT.withOnReadyThreshold(Integer.MAX_VALUE));
assertEquals(Integer.MAX_VALUE, state.onReadyThreshold);
}

private static class BaseTransportState extends Http2ClientStreamTransportState {
private int onReadyThreshold;

public BaseTransportState(TransportTracer transportTracer, CallOptions options) {
super(DEFAULT_MAX_MESSAGE_SIZE, StatsTraceContext.NOOP, transportTracer, options);
}
public BaseTransportState(TransportTracer transportTracer) {
super(DEFAULT_MAX_MESSAGE_SIZE, StatsTraceContext.NOOP, transportTracer, CallOptions.DEFAULT);
this(transportTracer, CallOptions.DEFAULT);
}

@Override
Expand All @@ -368,5 +380,11 @@ public void bytesRead(int processedBytes) {}
public void runOnTransportThread(Runnable r) {
r.run();
}

@Override
void setOnReadyThreshold(int numBytes) {
onReadyThreshold = numBytes;
super.setOnReadyThreshold(numBytes);
}
}
}

0 comments on commit f0cf726

Please sign in to comment.