Search in sources :

Example 11 with DataBufferUtils

use of org.springframework.core.io.buffer.DataBufferUtils in project spring-framework by spring-projects.

the class DefaultPartHttpMessageReaderTests method noHeaders.

@ParameterizedDefaultPartHttpMessageReaderTest
public void noHeaders(String displayName, DefaultPartHttpMessageReader reader) {
    MockServerHttpRequest request = createRequest(new ClassPathResource("no-header.multipart", getClass()), "boundary");
    Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
    StepVerifier.create(result).consumeNextWith(part -> {
        assertThat(part.headers()).isEmpty();
        part.content().subscribe(DataBufferUtils::release);
    }).verifyComplete();
}
Also used : StepVerifier(reactor.test.StepVerifier) NettyDataBufferFactory(org.springframework.core.io.buffer.NettyDataBufferFactory) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ClassPathResource(org.springframework.core.io.ClassPathResource) DecodingException(org.springframework.core.codec.DecodingException) Retention(java.lang.annotation.Retention) DataBufferUtils.release(org.springframework.core.io.buffer.DataBufferUtils.release) DataBufferUtils(org.springframework.core.io.buffer.DataBufferUtils) Nullable(org.springframework.lang.Nullable) Collections.singletonMap(java.util.Collections.singletonMap) Arguments.arguments(org.junit.jupiter.params.provider.Arguments.arguments) Path(java.nio.file.Path) MethodSource(org.junit.jupiter.params.provider.MethodSource) Resource(org.springframework.core.io.Resource) Collections.emptyMap(java.util.Collections.emptyMap) Files(java.nio.file.Files) ResolvableType.forClass(org.springframework.core.ResolvableType.forClass) UTF_8(java.nio.charset.StandardCharsets.UTF_8) MediaType(org.springframework.http.MediaType) IOException(java.io.IOException) Target(java.lang.annotation.Target) Mono(reactor.core.publisher.Mono) ElementType(java.lang.annotation.ElementType) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) Arguments(org.junit.jupiter.params.provider.Arguments) DataBuffer(org.springframework.core.io.buffer.DataBuffer) BaseSubscriber(reactor.core.publisher.BaseSubscriber) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) Flux(reactor.core.publisher.Flux) MockServerHttpRequest(org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) DataBufferFactory(org.springframework.core.io.buffer.DataBufferFactory) Subscription(org.reactivestreams.Subscription) Exceptions(reactor.core.Exceptions) Collections(java.util.Collections) RetentionPolicy(java.lang.annotation.RetentionPolicy) MockServerHttpRequest(org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

DataBufferUtils (org.springframework.core.io.buffer.DataBufferUtils)11 DataBuffer (org.springframework.core.io.buffer.DataBuffer)10 Mono (reactor.core.publisher.Mono)9 Flux (reactor.core.publisher.Flux)8 DataBufferFactory (org.springframework.core.io.buffer.DataBufferFactory)7 Resource (org.springframework.core.io.Resource)6 IOException (java.io.IOException)5 Nullable (org.springframework.lang.Nullable)5 GridFSFile (com.mongodb.client.gridfs.model.GridFSFile)4 HexUtils (com.mongodb.internal.HexUtils)4 InputStreamReader (java.io.InputStreamReader)4 ByteBuffer (java.nio.ByteBuffer)4 Assertions (org.assertj.core.api.Assertions)4 BsonObjectId (org.bson.BsonObjectId)4 BsonString (org.bson.BsonString)4 Document (org.bson.Document)4 ObjectId (org.bson.types.ObjectId)4 Before (org.junit.Before)4 Test (org.junit.Test)4 RunWith (org.junit.runner.RunWith)4