More accurate checks for presence of MediaType.ALL
Typically a straight up equals as well as Collections#contains checks for MediaType.ALL is susceptible to the presence of media type parameters. This commits adds equalsTypeAndSubtype as well as an isPresentIn(Collection<MimeType>) methods to MimeType to faciliate with checks for MediaType.ALL. Issue: SPR-17550
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -128,6 +128,17 @@ public class ProducesRequestConditionTests {
|
||||
assertNotNull(condition.getMatchingCondition(request));
|
||||
}
|
||||
|
||||
@Test // SPR-17550
|
||||
public void matchWithNegationAndMediaTypeAllWithQualityParameter() {
|
||||
ProducesRequestCondition condition = new ProducesRequestCondition("!application/json");
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addHeader("Accept",
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
|
||||
|
||||
assertNotNull(condition.getMatchingCondition(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareTo() {
|
||||
ProducesRequestCondition html = new ProducesRequestCondition("text/html");
|
||||
|
||||
Reference in New Issue
Block a user