use of io.servicetalk.http.api.HttpStreamingSerializerDeserializer in project servicetalk by apple.
the class HttpSerializationErrorTest method serializationMapThrowsPropagatesToClient.
@ParameterizedTest
@MethodSource("executors")
void serializationMapThrowsPropagatesToClient(HttpTestExecutionStrategy serverStrategy) throws Exception {
serverExecutionStrategy = serverStrategy.executorSupplier.get();
TypeReference<Map<String, Object>> mapType = new TypeReference<Map<String, Object>>() {
};
HttpSerializerDeserializer<Map<String, Object>> httpSerializer = jsonSerializer(JACKSON.serializerDeserializer(mapType));
HttpStreamingSerializerDeserializer<Map<String, Object>> httpStreamingSerializer = jsonStreamingSerializer(JACKSON.streamingSerializerDeserializer(mapType));
try (ServerContext srv = HttpServers.forAddress(localAddress(0)).executionStrategy(serverExecutionStrategy).listenAndAwait((ctx, request, responseFactory) -> responseFactory.ok().toStreamingResponse().payloadBody(request.toStreamingRequest().payloadBody(httpStreamingSerializer).map(result -> {
throw DELIBERATE_EXCEPTION;
}), httpStreamingSerializer).toResponse());
BlockingHttpClient clt = HttpClients.forSingleAddress(serverHostAndPort(srv)).buildBlocking()) {
HttpResponse resp = clt.request(clt.post("/foo").payloadBody(emptyMap(), httpSerializer));
assertEquals(INTERNAL_SERVER_ERROR, resp.status());
}
}
use of io.servicetalk.http.api.HttpStreamingSerializerDeserializer in project servicetalk by apple.
the class HttpSerializerErrorTest method serializationMapThrowsPropagatesToClient.
@ParameterizedTest
@MethodSource("executors")
void serializationMapThrowsPropagatesToClient(HttpTestExecutionStrategy serverStrategy) throws Exception {
serverExecutionStrategy = serverStrategy.executorSupplier.get();
TypeReference<Map<String, Object>> mapType = new TypeReference<Map<String, Object>>() {
};
HttpStreamingSerializerDeserializer<Map<String, Object>> streamingSerializer = jsonStreamingSerializer(JACKSON.streamingSerializerDeserializer(mapType));
HttpSerializerDeserializer<Map<String, Object>> serializer = HttpSerializers.jsonSerializer(JACKSON.serializerDeserializer(mapType));
try (ServerContext srv = HttpServers.forAddress(localAddress(0)).executionStrategy(serverExecutionStrategy).listenAndAwait((ctx, request, responseFactory) -> responseFactory.ok().toStreamingResponse().payloadBody(request.toStreamingRequest().payloadBody(streamingSerializer).map(result -> {
throw DELIBERATE_EXCEPTION;
}), streamingSerializer).toResponse());
BlockingHttpClient clt = HttpClients.forSingleAddress(serverHostAndPort(srv)).buildBlocking()) {
HttpResponse resp = clt.request(clt.post("/foo").payloadBody(emptyMap(), serializer));
assertEquals(INTERNAL_SERVER_ERROR, resp.status());
}
}
Aggregations