Search in sources :

Example 91 with MockHttpServletRequest

use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.

the class HeadersRequestConditionTests method headerCaseSensitiveValueMatch.

@Test
public void headerCaseSensitiveValueMatch() {
    HeadersRequestCondition condition = new HeadersRequestCondition("foo=Bar");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("foo", "bar");
    assertNull(condition.getMatchingCondition(request));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) Test(org.junit.Test)

Example 92 with MockHttpServletRequest

use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.

the class ParamsRequestConditionTests method paramValueMatch.

@Test
public void paramValueMatch() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("foo", "bar");
    assertNotNull(new ParamsRequestCondition("foo=bar").getMatchingCondition(request));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) Test(org.junit.Test)

Example 93 with MockHttpServletRequest

use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.

the class ParamsRequestConditionTests method paramValueNoMatch.

@Test
public void paramValueNoMatch() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("foo", "bazz");
    assertNull(new ParamsRequestCondition("foo=bar").getMatchingCondition(request));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) Test(org.junit.Test)

Example 94 with MockHttpServletRequest

use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.

the class ParamsRequestConditionTests method paramNotPresent.

@Test
public void paramNotPresent() {
    ParamsRequestCondition condition = new ParamsRequestCondition("!foo");
    MockHttpServletRequest request = new MockHttpServletRequest();
    assertNotNull(condition.getMatchingCondition(request));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) Test(org.junit.Test)

Example 95 with MockHttpServletRequest

use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.

the class PatternsRequestConditionTests method matchSuffixPatternUsingFileExtensions2.

@Test
public void matchSuffixPatternUsingFileExtensions2() {
    PatternsRequestCondition condition1 = new PatternsRequestCondition(new String[] { "/prefix" }, null, null, true, false, Arrays.asList("json"));
    PatternsRequestCondition condition2 = new PatternsRequestCondition(new String[] { "/suffix" }, null, null, true, false, null);
    PatternsRequestCondition combined = condition1.combine(condition2);
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/prefix/suffix.json");
    PatternsRequestCondition match = combined.getMatchingCondition(request);
    assertNotNull(match);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) Test(org.junit.Test)

Aggregations

MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)646 Test (org.junit.Test)540 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)330 Before (org.junit.Before)78 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)77 MockServletContext (org.springframework.mock.web.test.MockServletContext)56 TestBean (org.springframework.tests.sample.beans.TestBean)43 StaticWebApplicationContext (org.springframework.web.context.support.StaticWebApplicationContext)41 HttpServletResponse (javax.servlet.http.HttpServletResponse)40 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)37 HttpServletRequest (javax.servlet.http.HttpServletRequest)35 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)30 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)29 ITestBean (org.springframework.tests.sample.beans.ITestBean)28 HandlerExecutionChain (org.springframework.web.servlet.HandlerExecutionChain)28 ServletException (javax.servlet.ServletException)27 HashMap (java.util.HashMap)26 FilterChain (javax.servlet.FilterChain)26 ModelAndViewContainer (org.springframework.web.method.support.ModelAndViewContainer)23 Cookie (javax.servlet.http.Cookie)22