use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class CompositeRequestConditionTests method match.
@Test
public void match() {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
request.setParameter("param1", "paramValue1");
request.addHeader("header1", "headerValue1");
RequestCondition<?> getPostCond = new RequestMethodsRequestCondition(RequestMethod.GET, RequestMethod.POST);
RequestCondition<?> getCond = new RequestMethodsRequestCondition(RequestMethod.GET);
CompositeRequestCondition condition = new CompositeRequestCondition(this.param1, getPostCond);
CompositeRequestCondition matchingCondition = new CompositeRequestCondition(this.param1, getCond);
assertEquals(matchingCondition, condition.getMatchingCondition(request));
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class CompositeRequestConditionTests method compareDifferentLength.
@Test(expected = IllegalArgumentException.class)
public void compareDifferentLength() {
CompositeRequestCondition cond1 = new CompositeRequestCondition(this.param1);
CompositeRequestCondition cond2 = new CompositeRequestCondition(this.param1, this.header1);
cond1.compareTo(cond2, new MockHttpServletRequest());
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method consumesMultipleMatch.
@Test
public void consumesMultipleMatch() {
ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain", "application/xml");
MockHttpServletRequest request = new MockHttpServletRequest();
request.setContentType("text/plain");
assertNotNull(condition.getMatchingCondition(request));
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method negatedConsumesMatch.
@Test
public void negatedConsumesMatch() {
ConsumesRequestCondition condition = new ConsumesRequestCondition("!text/plain");
MockHttpServletRequest request = new MockHttpServletRequest();
request.setContentType("text/plain");
assertNull(condition.getMatchingCondition(request));
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method consumesParseErrorWithNegation.
@Test
public void consumesParseErrorWithNegation() {
ConsumesRequestCondition condition = new ConsumesRequestCondition("!text/plain");
MockHttpServletRequest request = new MockHttpServletRequest();
request.setContentType("01");
assertNull(condition.getMatchingCondition(request));
}
Aggregations