Search in sources :

Example 56 with MockServerWebExchange

use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.

the class HandlerResultHandlerTests method noConcreteMediaType.

// SPR-12894
@Test
void noConcreteMediaType() {
    List<MediaType> producible = Collections.singletonList(ALL);
    MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path"));
    MediaType actual = this.resultHandler.selectMediaType(exchange, () -> producible);
    assertThat(actual).isEqualTo(APPLICATION_OCTET_STREAM);
}
Also used : MediaType(org.springframework.http.MediaType) MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) Test(org.junit.jupiter.api.Test)

Example 57 with MockServerWebExchange

use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.

the class HeadersRequestConditionTests method headerValueMatch.

@Test
public void headerValueMatch() {
    MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "bar"));
    HeadersRequestCondition condition = new HeadersRequestCondition("foo=bar");
    assertThat(condition.getMatchingCondition(exchange)).isNotNull();
}
Also used : MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) Test(org.junit.jupiter.api.Test)

Example 58 with MockServerWebExchange

use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.

the class HeadersRequestConditionTests method headerValueNoMatch.

@Test
public void headerValueNoMatch() {
    MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "bazz"));
    HeadersRequestCondition condition = new HeadersRequestCondition("foo=bar");
    assertThat(condition.getMatchingCondition(exchange)).isNull();
}
Also used : MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) Test(org.junit.jupiter.api.Test)

Example 59 with MockServerWebExchange

use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.

the class HeadersRequestConditionTests method headerValueNoMatchNegated.

@Test
public void headerValueNoMatchNegated() {
    MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("foo", "bar"));
    HeadersRequestCondition condition = new HeadersRequestCondition("foo!=bar");
    assertThat(condition.getMatchingCondition(exchange)).isNull();
}
Also used : MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) Test(org.junit.jupiter.api.Test)

Example 60 with MockServerWebExchange

use of org.springframework.web.testfixture.server.MockServerWebExchange in project spring-framework by spring-projects.

the class HeadersRequestConditionTests method headerNotPresent.

@Test
public void headerNotPresent() {
    MockServerWebExchange exchange = MockServerWebExchange.from(get("/"));
    HeadersRequestCondition condition = new HeadersRequestCondition("!accept");
    assertThat(condition.getMatchingCondition(exchange)).isNotNull();
}
Also used : MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) Test(org.junit.jupiter.api.Test)

Aggregations

MockServerWebExchange (org.springframework.web.testfixture.server.MockServerWebExchange)224 Test (org.junit.jupiter.api.Test)216 MockServerHttpRequest (org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest)61 ClassPathResource (org.springframework.core.io.ClassPathResource)26 HttpHeaders (org.springframework.http.HttpHeaders)25 Resource (org.springframework.core.io.Resource)24 HandlerResult (org.springframework.web.reactive.HandlerResult)23 MethodParameter (org.springframework.core.MethodParameter)22 MockServerHttpResponse (org.springframework.web.testfixture.http.server.reactive.MockServerHttpResponse)22 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)19 MediaType (org.springframework.http.MediaType)19 Mono (reactor.core.publisher.Mono)18 BeforeEach (org.junit.jupiter.api.BeforeEach)17 HttpMethod (org.springframework.http.HttpMethod)15 StepVerifier (reactor.test.StepVerifier)13 Arrays (java.util.Arrays)12 Collections (java.util.Collections)12 List (java.util.List)12 HttpStatus (org.springframework.http.HttpStatus)12 IOException (java.io.IOException)10