From 11a017d8b7396e1fd2cd29a01cde7ec38ce37590 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 24 Oct 2018 10:10:24 +0200 Subject: [PATCH] Add error stream tests for ProtobufEncoderTests Issue: SPR-17419 --- .../codec/protobuf/ProtobufEncoderTests.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java index b3a3ed90713..9afc0519334 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java @@ -35,9 +35,7 @@ import org.springframework.protobuf.SecondMsg; import org.springframework.util.MimeType; import static java.util.Collections.emptyMap; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import static org.springframework.core.ResolvableType.forClass; /** @@ -80,6 +78,19 @@ public class ProtobufEncoderTests extends AbstractDataBufferAllocatingTestCase { .verifyComplete(); } + @Test + public void encodeError() { + Flux messages = Flux.just(this.testMsg) + .concatWith(Flux.error(new RuntimeException())); + + ResolvableType elementType = forClass(Msg.class); + Flux output = this.encoder.encode(messages, this.bufferFactory, elementType, PROTOBUF_MIME_TYPE, emptyMap()); + StepVerifier.create(output) + .consumeNextWith(DataBufferUtils::release) + .expectError(RuntimeException.class) + .verify(); + } + @Test public void encodeStream() { Msg testMsg2 = Msg.newBuilder().setFoo("Bar").setBlah(SecondMsg.newBuilder().setBlah(456).build()).build();