use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class HttpEntityArgumentResolverTests method httpEntityWithSingleBody.
@Test
public void httpEntityWithSingleBody() throws Exception {
ServerWebExchange exchange = postExchange("line1");
ResolvableType type = httpEntityType(Single.class, String.class);
HttpEntity<Single<String>> httpEntity = resolveValue(exchange, type);
assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
assertEquals("line1", httpEntity.getBody().toBlocking().value());
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class HttpEntityArgumentResolverTests method httpEntityWithRxJava2SingleBody.
@Test
public void httpEntityWithRxJava2SingleBody() throws Exception {
ServerWebExchange exchange = postExchange("line1");
ResolvableType type = httpEntityType(io.reactivex.Single.class, String.class);
HttpEntity<io.reactivex.Single<String>> httpEntity = resolveValue(exchange, type);
assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
assertEquals("line1", httpEntity.getBody().blockingGet());
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class HttpEntityArgumentResolverTests method httpEntityWithStringBody.
@Test
public void httpEntityWithStringBody() throws Exception {
ServerWebExchange exchange = postExchange("line1");
ResolvableType type = httpEntityType(String.class);
HttpEntity<String> httpEntity = resolveValue(exchange, type);
assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
assertEquals("line1", httpEntity.getBody());
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class HttpEntityArgumentResolverTests method httpEntityWithFluxBody.
@Test
public void httpEntityWithFluxBody() throws Exception {
ServerWebExchange exchange = postExchange("line1\nline2\nline3\n");
ResolvableType type = httpEntityType(Flux.class, String.class);
HttpEntity<Flux<String>> httpEntity = resolveValue(exchange, type);
assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
StepVerifier.create(httpEntity.getBody()).expectNext("line1\n").expectNext("line2\n").expectNext("line3\n").expectComplete().verify();
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class InitBinderBindingContextTests method returnValueNotExpected.
@Test(expected = IllegalStateException.class)
public void returnValueNotExpected() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
BindingContext context = createBindingContext("initBinderReturnValue", WebDataBinder.class);
context.createDataBinder(exchange, null, "invalidName");
}
Aggregations