Skip to content

Commit 11a017d

Browse files
committed
Add error stream tests for ProtobufEncoderTests
Issue: SPR-17419
1 parent 2439f87 commit 11a017d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
import org.springframework.util.MimeType;
3636

3737
import static java.util.Collections.emptyMap;
38-
import static org.junit.Assert.assertEquals;
39-
import static org.junit.Assert.assertFalse;
40-
import static org.junit.Assert.assertTrue;
38+
import static org.junit.Assert.*;
4139
import static org.springframework.core.ResolvableType.forClass;
4240

4341
/**
@@ -80,6 +78,19 @@ public void encode() {
8078
.verifyComplete();
8179
}
8280

81+
@Test
82+
public void encodeError() {
83+
Flux<Msg> messages = Flux.just(this.testMsg)
84+
.concatWith(Flux.error(new RuntimeException()));
85+
86+
ResolvableType elementType = forClass(Msg.class);
87+
Flux<DataBuffer> output = this.encoder.encode(messages, this.bufferFactory, elementType, PROTOBUF_MIME_TYPE, emptyMap());
88+
StepVerifier.create(output)
89+
.consumeNextWith(DataBufferUtils::release)
90+
.expectError(RuntimeException.class)
91+
.verify();
92+
}
93+
8394
@Test
8495
public void encodeStream() {
8596
Msg testMsg2 = Msg.newBuilder().setFoo("Bar").setBlah(SecondMsg.newBuilder().setBlah(456).build()).build();

0 commit comments

Comments
 (0)