@ -16,6 +16,7 @@
@@ -16,6 +16,7 @@
package org.springframework.http.codec.json ;
import java.util.Arrays ;
import java.util.Map ;
import com.fasterxml.jackson.annotation.JsonTypeInfo ;
@ -32,6 +33,7 @@ import reactor.test.StepVerifier;
@@ -32,6 +33,7 @@ import reactor.test.StepVerifier;
import org.springframework.core.ResolvableType ;
import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase ;
import org.springframework.core.io.buffer.DataBuffer ;
import org.springframework.http.MediaType ;
import org.springframework.http.codec.Pojo ;
import org.springframework.http.codec.ServerSentEvent ;
@ -108,6 +110,26 @@ public class Jackson2JsonEncoderTests extends AbstractDataBufferAllocatingTestCa
@@ -108,6 +110,26 @@ public class Jackson2JsonEncoderTests extends AbstractDataBufferAllocatingTestCa
. verifyComplete ( ) ;
}
@Test // SPR-15727
public void encodeAsStreamWithCustomStreamingType ( ) throws Exception {
MediaType fooMediaType = new MediaType ( "application" , "foo" ) ;
MediaType barMediaType = new MediaType ( "application" , "bar" ) ;
this . encoder . setStreamingMediaTypes ( Arrays . asList ( fooMediaType , barMediaType ) ) ;
Flux < Pojo > source = Flux . just (
new Pojo ( "foo" , "bar" ) ,
new Pojo ( "foofoo" , "barbar" ) ,
new Pojo ( "foofoofoo" , "barbarbar" )
) ;
ResolvableType type = ResolvableType . forClass ( Pojo . class ) ;
Flux < DataBuffer > output = this . encoder . encode ( source , this . bufferFactory , type , barMediaType , emptyMap ( ) ) ;
StepVerifier . create ( output )
. consumeNextWith ( stringConsumer ( "{\"foo\":\"foo\",\"bar\":\"bar\"}\n" ) )
. consumeNextWith ( stringConsumer ( "{\"foo\":\"foofoo\",\"bar\":\"barbar\"}\n" ) )
. consumeNextWith ( stringConsumer ( "{\"foo\":\"foofoofoo\",\"bar\":\"barbarbar\"}\n" ) )
. verifyComplete ( ) ;
}
@Test
public void fieldLevelJsonView ( ) throws Exception {
JacksonViewBean bean = new JacksonViewBean ( ) ;