use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class CookieLocaleResolverTests method testSetAndResolveLocaleContextWithTimeZone.
@Test
public void testSetAndResolveLocaleContextWithTimeZone() {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
CookieLocaleResolver resolver = new CookieLocaleResolver();
resolver.setLocaleContext(request, response, new SimpleTimeZoneAwareLocaleContext(new Locale("nl", ""), TimeZone.getTimeZone("GMT+1")));
Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
request = new MockHttpServletRequest();
request.setCookies(cookie);
resolver = new CookieLocaleResolver();
LocaleContext loc = resolver.resolveLocaleContext(request);
assertEquals("nl", loc.getLocale().getLanguage());
assertTrue(loc instanceof TimeZoneAwareLocaleContext);
assertEquals(TimeZone.getTimeZone("GMT+1"), ((TimeZoneAwareLocaleContext) loc).getTimeZone());
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method consumesParseError.
@Test
public void consumesParseError() {
ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain");
MockHttpServletRequest request = new MockHttpServletRequest();
request.setContentType("01");
assertNull(condition.getMatchingCondition(request));
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method consumesWildcardMatch.
@Test
public void consumesWildcardMatch() {
ConsumesRequestCondition condition = new ConsumesRequestCondition("text/*");
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 compareToSingle.
@Test
public void compareToSingle() {
MockHttpServletRequest request = new MockHttpServletRequest();
ConsumesRequestCondition condition1 = new ConsumesRequestCondition("text/plain");
ConsumesRequestCondition condition2 = new ConsumesRequestCondition("text/*");
int result = condition1.compareTo(condition2, request);
assertTrue("Invalid comparison result: " + result, result < 0);
result = condition2.compareTo(condition1, request);
assertTrue("Invalid comparison result: " + result, result > 0);
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class ConsumesRequestConditionTests method compareToMultiple.
@Test
public void compareToMultiple() {
MockHttpServletRequest request = new MockHttpServletRequest();
ConsumesRequestCondition condition1 = new ConsumesRequestCondition("*/*", "text/plain");
ConsumesRequestCondition condition2 = new ConsumesRequestCondition("text/*", "text/plain;q=0.7");
int result = condition1.compareTo(condition2, request);
assertTrue("Invalid comparison result: " + result, result < 0);
result = condition2.compareTo(condition1, request);
assertTrue("Invalid comparison result: " + result, result > 0);
}
Aggregations