use of jakarta.servlet.http.HttpServletRequest in project spring-framework by spring-projects.
the class ProducesRequestConditionTests method matchWithNegationAndMediaTypeAllWithQualityParameter.
// SPR-17550
@Test
public void matchWithNegationAndMediaTypeAllWithQualityParameter() {
ProducesRequestCondition condition = new ProducesRequestCondition("!application/json");
HttpServletRequest request = createRequest("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
assertThat(condition.getMatchingCondition(request)).isNotNull();
}
use of jakarta.servlet.http.HttpServletRequest in project spring-framework by spring-projects.
the class ProducesRequestConditionTests method matchParseError.
@Test
public void matchParseError() {
ProducesRequestCondition condition = new ProducesRequestCondition("text/plain");
HttpServletRequest request = createRequest("bogus");
assertThat(condition.getMatchingCondition(request)).isNull();
}
use of jakarta.servlet.http.HttpServletRequest in project spring-framework by spring-projects.
the class ProducesRequestConditionTests method compareToMultipleExpressionsAndMultipleAcceptHeaderValues.
@Test
public void compareToMultipleExpressionsAndMultipleAcceptHeaderValues() {
ProducesRequestCondition condition1 = new ProducesRequestCondition("text/*", "text/plain");
ProducesRequestCondition condition2 = new ProducesRequestCondition("application/*", "application/xml");
HttpServletRequest request = createRequest("text/plain", "application/xml");
int result = condition1.compareTo(condition2, request);
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
result = condition2.compareTo(condition1, request);
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
request = createRequest("application/xml", "text/plain");
result = condition1.compareTo(condition2, request);
assertThat(result > 0).as("Invalid comparison result: " + result).isTrue();
result = condition2.compareTo(condition1, request);
assertThat(result < 0).as("Invalid comparison result: " + result).isTrue();
}
use of jakarta.servlet.http.HttpServletRequest in project spring-framework by spring-projects.
the class ProducesRequestConditionTests method matchWithParameters.
// gh-21670
@Test
public void matchWithParameters() {
String base = "application/atom+xml";
ProducesRequestCondition condition = new ProducesRequestCondition(base + ";type=feed");
HttpServletRequest request = createRequest(base + ";type=entry");
assertThat(condition.getMatchingCondition(request)).as("Declared parameter value must match if present in request").isNull();
condition = new ProducesRequestCondition(base + ";type=feed");
request = createRequest(base + ";type=feed");
assertThat(condition.getMatchingCondition(request)).as("Declared parameter value must match if present in request").isNotNull();
condition = new ProducesRequestCondition(base + ";type=feed");
request = createRequest(base);
assertThat(condition.getMatchingCondition(request)).as("Declared parameter has no impact if not present in request").isNotNull();
condition = new ProducesRequestCondition(base);
request = createRequest(base + ";type=feed");
assertThat(condition.getMatchingCondition(request)).as("No impact from other parameters in request").isNotNull();
}
use of jakarta.servlet.http.HttpServletRequest in project spring-framework by spring-projects.
the class ProducesRequestConditionTests method matchMultiple.
@Test
public void matchMultiple() {
ProducesRequestCondition condition = new ProducesRequestCondition("text/plain", "application/xml");
HttpServletRequest request = createRequest("text/plain");
assertThat(condition.getMatchingCondition(request)).isNotNull();
}
Aggregations