Search in sources :

Example 41 with MockServerWebExchange

use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.

the class ConsumesRequestConditionTests method compareToSingle.

@Test
public void compareToSingle() throws Exception {
    MockServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange();
    ConsumesRequestCondition condition1 = new ConsumesRequestCondition("text/plain");
    ConsumesRequestCondition condition2 = new ConsumesRequestCondition("text/*");
    int result = condition1.compareTo(condition2, exchange);
    assertTrue("Invalid comparison result: " + result, result < 0);
    result = condition2.compareTo(condition1, exchange);
    assertTrue("Invalid comparison result: " + result, result > 0);
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Example 42 with MockServerWebExchange

use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.

the class ConsumesRequestConditionTests method getMatchingCondition.

@Test
public void getMatchingCondition() throws Exception {
    MockServerWebExchange exchange = postExchange("text/plain");
    ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain", "application/xml");
    ConsumesRequestCondition result = condition.getMatchingCondition(exchange);
    assertConditions(result, "text/plain");
    condition = new ConsumesRequestCondition("application/xml");
    result = condition.getMatchingCondition(exchange);
    assertNull(result);
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Example 43 with MockServerWebExchange

use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.

the class ConsumesRequestConditionTests method consumesMatch.

@Test
public void consumesMatch() throws Exception {
    MockServerWebExchange exchange = postExchange("text/plain");
    ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain");
    assertNotNull(condition.getMatchingCondition(exchange));
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Example 44 with MockServerWebExchange

use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.

the class ConsumesRequestConditionTests method consumesSingleNoMatch.

@Test
public void consumesSingleNoMatch() throws Exception {
    MockServerWebExchange exchange = postExchange("application/xml");
    ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain");
    assertNull(condition.getMatchingCondition(exchange));
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Example 45 with MockServerWebExchange

use of org.springframework.mock.http.server.reactive.test.MockServerWebExchange in project spring-framework by spring-projects.

the class ConsumesRequestConditionTests method consumesParseError.

@Test
public void consumesParseError() throws Exception {
    MockServerWebExchange exchange = postExchange("01");
    ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain");
    assertNull(condition.getMatchingCondition(exchange));
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Aggregations

MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)135 Test (org.junit.Test)127 ClassPathResource (org.springframework.core.io.ClassPathResource)19 Resource (org.springframework.core.io.Resource)19 HandlerResult (org.springframework.web.reactive.HandlerResult)17 MethodParameter (org.springframework.core.MethodParameter)15 MediaType (org.springframework.http.MediaType)8 Instant (java.time.Instant)7 HttpHeaders (org.springframework.http.HttpHeaders)5 MockServerHttpResponse (org.springframework.mock.http.server.reactive.test.MockServerHttpResponse)5 FileSystemResource (org.springframework.core.io.FileSystemResource)3 UrlResource (org.springframework.core.io.UrlResource)3 DataBuffer (org.springframework.core.io.buffer.DataBuffer)3 CompositeContentTypeResolver (org.springframework.web.reactive.accept.CompositeContentTypeResolver)3 RequestedContentTypeResolverBuilder (org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Assert.assertSame (org.junit.Assert.assertSame)2 DefaultDataBufferFactory (org.springframework.core.io.buffer.DefaultDataBufferFactory)2