Search in sources :

Example 46 with MockServerWebExchange

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

the class HeadersRequestConditionTests method headerValueMatch.

@Test
public void headerValueMatch() throws Exception {
    MockServerWebExchange exchange = MockServerHttpRequest.get("/").header("foo", "bar").toExchange();
    HeadersRequestCondition condition = new HeadersRequestCondition("foo=bar");
    assertNotNull(condition.getMatchingCondition(exchange));
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Example 47 with MockServerWebExchange

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

the class HeadersRequestConditionTests method headerValueNoMatch.

@Test
public void headerValueNoMatch() throws Exception {
    MockServerWebExchange exchange = MockServerHttpRequest.get("/").header("foo", "bazz").toExchange();
    HeadersRequestCondition condition = new HeadersRequestCondition("foo=bar");
    assertNull(condition.getMatchingCondition(exchange));
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Example 48 with MockServerWebExchange

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

the class HeadersRequestConditionTests method headerValueMatchNegated.

@Test
public void headerValueMatchNegated() throws Exception {
    MockServerWebExchange exchange = MockServerHttpRequest.get("/").header("foo", "baz").toExchange();
    HeadersRequestCondition condition = new HeadersRequestCondition("foo!=bar");
    assertNotNull(condition.getMatchingCondition(exchange));
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Example 49 with MockServerWebExchange

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

the class ResourceWebHandlerTests method doOverwriteExistingCacheControlHeaders.

// SPR-14005
@Test
public void doOverwriteExistingCacheControlHeaders() throws Exception {
    MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
    exchange.getResponse().getHeaders().setCacheControl(CacheControl.noStore().getHeaderValue());
    setPathWithinHandlerMapping(exchange, "foo.css");
    this.handler.handle(exchange).block(TIMEOUT);
    assertEquals("max-age=3600", exchange.getResponse().getHeaders().getCacheControl());
}
Also used : MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Example 50 with MockServerWebExchange

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

the class ResourceWebHandlerTests method notModified.

@Test
public void notModified() throws Exception {
    MockServerWebExchange exchange = MockServerHttpRequest.get("").ifModifiedSince(resourceLastModified("test/foo.css")).toExchange();
    setPathWithinHandlerMapping(exchange, "foo.css");
    this.handler.handle(exchange).block(TIMEOUT);
    assertEquals(HttpStatus.NOT_MODIFIED, exchange.getResponse().getStatusCode());
}
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