Merge branch '5.1.x'
This commit is contained in:
@@ -21,7 +21,10 @@ import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.test.server.MockServerWebExchange;
|
||||
import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
|
||||
import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -129,6 +132,23 @@ public class ProducesRequestConditionTests {
|
||||
assertNotNull(condition.getMatchingCondition(exchange));
|
||||
}
|
||||
|
||||
@Test // gh-22853
|
||||
public void matchAndCompare() {
|
||||
RequestedContentTypeResolverBuilder builder = new RequestedContentTypeResolverBuilder();
|
||||
builder.headerResolver();
|
||||
builder.fixedResolver(MediaType.TEXT_HTML);
|
||||
RequestedContentTypeResolver resolver = builder.build();
|
||||
|
||||
ProducesRequestCondition none = new ProducesRequestCondition(new String[0], null, resolver);
|
||||
ProducesRequestCondition html = new ProducesRequestCondition(new String[] {"text/html"}, null, resolver);
|
||||
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").header("Accept", "*/*"));
|
||||
|
||||
ProducesRequestCondition noneMatch = none.getMatchingCondition(exchange);
|
||||
ProducesRequestCondition htmlMatch = html.getMatchingCondition(exchange);
|
||||
|
||||
assertEquals(1, noneMatch.compareTo(htmlMatch, exchange));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareTo() {
|
||||
|
||||
Reference in New Issue
Block a user