@@ -137,29 +137,38 @@ public void encodeNonStream() {
137
137
);
138
138
139
139
testEncode (input , Pojo .class , step -> step
140
- .consumeNextWith (expectString ("[" ))
141
- .consumeNextWith (expectString ("{\" foo\" :\" foo\" ,\" bar\" :\" bar\" }" ))
140
+ .consumeNextWith (expectString ("[{\" foo\" :\" foo\" ,\" bar\" :\" bar\" }" ))
142
141
.consumeNextWith (expectString (",{\" foo\" :\" foofoo\" ,\" bar\" :\" barbar\" }" ))
143
142
.consumeNextWith (expectString (",{\" foo\" :\" foofoofoo\" ,\" bar\" :\" barbarbar\" }" ))
144
143
.consumeNextWith (expectString ("]" ))
145
144
.verifyComplete ());
146
145
}
147
146
147
+ @ Test // gh-29038
148
+ void encodeNonStreamWithErrorAsFirstSignal () {
149
+ String message = "I'm a teapot" ;
150
+ Flux <Object > input = Flux .error (new IllegalStateException (message ));
151
+
152
+ Flux <DataBuffer > output = this .encoder .encode (
153
+ input , this .bufferFactory , ResolvableType .forClass (Pojo .class ), null , null );
154
+
155
+ StepVerifier .create (output ).expectErrorMessage (message ).verify ();
156
+ }
157
+
148
158
@ Test
149
159
public void encodeWithType () {
150
160
Flux <ParentClass > input = Flux .just (new Foo (), new Bar ());
151
161
152
162
testEncode (input , ParentClass .class , step -> step
153
- .consumeNextWith (expectString ("[" ))
154
- .consumeNextWith (expectString ("{\" type\" :\" foo\" }" ))
163
+ .consumeNextWith (expectString ("[{\" type\" :\" foo\" }" ))
155
164
.consumeNextWith (expectString (",{\" type\" :\" bar\" }" ))
156
165
.consumeNextWith (expectString ("]" ))
157
166
.verifyComplete ());
158
167
}
159
168
160
169
161
170
@ Test // SPR-15727
162
- public void encodeAsStreamWithCustomStreamingType () {
171
+ public void encodeStreamWithCustomStreamingType () {
163
172
MediaType fooMediaType = new MediaType ("application" , "foo" );
164
173
MediaType barMediaType = new MediaType ("application" , "bar" );
165
174
this .encoder .setStreamingMediaTypes (Arrays .asList (fooMediaType , barMediaType ));
@@ -263,8 +272,7 @@ public void encodeWithFlushAfterWriteOff() {
263
272
ResolvableType .forClass (Pojo .class ), MimeTypeUtils .APPLICATION_JSON , Collections .emptyMap ());
264
273
265
274
StepVerifier .create (result )
266
- .consumeNextWith (expectString ("[" ))
267
- .consumeNextWith (expectString ("{\" foo\" :\" foo\" ,\" bar\" :\" bar\" }" ))
275
+ .consumeNextWith (expectString ("[{\" foo\" :\" foo\" ,\" bar\" :\" bar\" }" ))
268
276
.consumeNextWith (expectString ("]" ))
269
277
.expectComplete ()
270
278
.verify (Duration .ofSeconds (5 ));
0 commit comments