use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class DefaultPartHttpMessageReaderTests method testBrowser.
private void testBrowser(DefaultPartHttpMessageReader reader, Resource resource, String boundary) throws InterruptedException {
MockServerHttpRequest request = createRequest(resource, boundary);
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
CountDownLatch latch = new CountDownLatch(3);
StepVerifier.create(result).consumeNextWith(part -> testBrowserFormField(part, "text1", "a")).as("text1").consumeNextWith(part -> testBrowserFormField(part, "text2", "b")).as("text2").consumeNextWith(part -> testBrowserFile(part, "file1", "a.txt", LOREM_IPSUM, latch)).as("file1").consumeNextWith(part -> testBrowserFile(part, "file2", "a.txt", LOREM_IPSUM, latch)).as("file2-1").consumeNextWith(part -> testBrowserFile(part, "file2", "b.txt", MUSPI_MEROL, latch)).as("file2-2").verifyComplete();
latch.await();
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class DefaultPartHttpMessageReaderTests method tooManyParts.
@Test
public void tooManyParts() throws InterruptedException {
MockServerHttpRequest request = createRequest(new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
DefaultPartHttpMessageReader reader = new DefaultPartHttpMessageReader();
reader.setMaxParts(1);
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
CountDownLatch latch = new CountDownLatch(1);
StepVerifier.create(result).consumeNextWith(part -> testPart(part, null, "This is implicitly typed plain ASCII text.\r\nIt does NOT end with a linebreak.", latch)).as("Part 1").expectError(DecodingException.class).verify();
latch.await();
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class DefaultPartHttpMessageReaderTests method noEndBody.
@ParameterizedDefaultPartHttpMessageReaderTest
public void noEndBody(String displayName, DefaultPartHttpMessageReader reader) {
MockServerHttpRequest request = createRequest(new ClassPathResource("no-end-body.multipart", getClass()), "boundary");
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
StepVerifier.create(result).expectError(DecodingException.class).verify();
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class DefaultPartHttpMessageReaderTests method cancelBodyThenPart.
@ParameterizedDefaultPartHttpMessageReaderTest
public void cancelBodyThenPart(String displayName, DefaultPartHttpMessageReader reader) {
MockServerHttpRequest request = createRequest(new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
StepVerifier.create(result, 1).consumeNextWith(part -> part.content().subscribe(new CancelSubscriber())).thenCancel().verify();
}
use of org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest in project spring-framework by spring-projects.
the class DefaultPartHttpMessageReaderTests method quotedBoundary.
@ParameterizedDefaultPartHttpMessageReaderTest
public void quotedBoundary(String displayName, DefaultPartHttpMessageReader reader) throws InterruptedException {
MockServerHttpRequest request = createRequest(new ClassPathResource("simple.multipart", getClass()), "\"simple-boundary\"");
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
CountDownLatch latch = new CountDownLatch(2);
StepVerifier.create(result).consumeNextWith(part -> testPart(part, null, "This is implicitly typed plain ASCII text.\r\nIt does NOT end with a linebreak.", latch)).as("Part 1").consumeNextWith(part -> testPart(part, null, "This is explicitly typed plain ASCII text.\r\nIt DOES end with a linebreak.\r\n", latch)).as("Part 2").verifyComplete();
latch.await();
}
Aggregations