use of io.servicetalk.http.api.HttpContextKeys.HTTP_EXECUTION_STRATEGY_KEY in project servicetalk by apple.
the class HttpStreamingClientOverrideOffloadingTest method reserveRespectsDisable.
@ParameterizedTest
@EnumSource(Params.class)
void reserveRespectsDisable(final Params params) throws Exception {
setUp(params);
StreamingHttpRequest request = client.get("/");
request.context().put(HTTP_EXECUTION_STRATEGY_KEY, this.overridingStrategy);
client.reserveConnection(request).beforeOnSuccess(__ -> {
if (isInvalidThread()) {
throw new AssertionError("Invalid thread found providing the connection. Thread: " + currentThread());
}
}).toFuture().get().closeAsync().toFuture().get();
}
use of io.servicetalk.http.api.HttpContextKeys.HTTP_EXECUTION_STRATEGY_KEY in project servicetalk by apple.
the class HttpClientOverrideOffloadingTest method reserveRespectsDisable.
@ParameterizedTest
@EnumSource(Params.class)
void reserveRespectsDisable(final Params params) throws Exception {
setUp(params);
ConcurrentLinkedQueue<AssertionError> errors = new ConcurrentLinkedQueue<>();
HttpRequest request = client.get("/");
request.context().put(HTTP_EXECUTION_STRATEGY_KEY, this.overridingStrategy);
client.reserveConnection(request).beforeOnSuccess(__ -> {
if (isInvalidThread()) {
errors.add(new AssertionError("Invalid thread found providing the connection. Thread: " + currentThread()));
}
}).toFuture().get().closeAsync().toFuture().get();
assertThat("Unexpected errors: " + errors, errors, hasSize(0));
}
use of io.servicetalk.http.api.HttpContextKeys.HTTP_EXECUTION_STRATEGY_KEY in project servicetalk by apple.
the class HttpStreamingClientOverrideOffloadingTest method requestRespectsDisable.
@ParameterizedTest
@EnumSource(Params.class)
void requestRespectsDisable(final Params params) throws Exception {
setUp(params);
ConcurrentLinkedQueue<AssertionError> errors = new ConcurrentLinkedQueue<>();
StreamingHttpRequest req = client.get("/").transformPayloadBody(p -> p.beforeRequest(__ -> {
if (isInvalidThread()) {
errors.add(new AssertionError("Invalid thread called request-n. Thread: " + currentThread()));
}
}));
req.context().put(HTTP_EXECUTION_STRATEGY_KEY, this.overridingStrategy);
client.request(req).beforeOnSuccess(__ -> {
if (isInvalidThread()) {
errors.add(new AssertionError("Invalid thread called response metadata. " + "Thread: " + currentThread()));
}
}).flatMapPublisher(StreamingHttpResponse::payloadBody).beforeOnNext(__ -> {
if (isInvalidThread()) {
errors.add(new AssertionError("Invalid thread called response payload onNext. " + "Thread: " + currentThread()));
}
}).beforeOnComplete(() -> {
if (isInvalidThread()) {
errors.add(new AssertionError("Invalid thread called response payload onComplete. " + "Thread: " + currentThread()));
}
}).toFuture().get();
assertThat("Unexpected errors: " + errors, errors, hasSize(0));
}
Aggregations