use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class AcceptHeaderLocaleResolverTests method defaultLocale.
@Test
public void defaultLocale() throws Exception {
this.resolver.setDefaultLocale(JAPANESE);
MockHttpServletRequest request = new MockHttpServletRequest();
assertEquals(JAPANESE, this.resolver.resolveLocale(request));
request.addHeader("Accept-Language", US.toString());
request.setPreferredLocales(Collections.singletonList(US));
assertEquals(US, this.resolver.resolveLocale(request));
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class CookieLocaleResolverTests method testResolveLocaleContext.
@Test
public void testResolveLocaleContext() {
MockHttpServletRequest request = new MockHttpServletRequest();
Cookie cookie = new Cookie("LanguageKoekje", "nl");
request.setCookies(cookie);
CookieLocaleResolver resolver = new CookieLocaleResolver();
resolver.setCookieName("LanguageKoekje");
LocaleContext loc = resolver.resolveLocaleContext(request);
assertEquals("nl", loc.getLocale().getLanguage());
assertTrue(loc instanceof TimeZoneAwareLocaleContext);
assertNull(((TimeZoneAwareLocaleContext) loc).getTimeZone());
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class JdkProxyControllerTests method typeLevel.
@Test
public void typeLevel() throws Exception {
initServlet(TypeLevelImpl.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("doIt", response.getContentAsString());
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class CompositeRequestConditionTests method compare.
@Test
public void compare() {
HttpServletRequest request = new MockHttpServletRequest();
CompositeRequestCondition cond1 = new CompositeRequestCondition(this.param1);
CompositeRequestCondition cond3 = new CompositeRequestCondition(this.param3);
assertEquals(1, cond1.compareTo(cond3, request));
assertEquals(-1, cond3.compareTo(cond1, request));
}
use of org.springframework.mock.web.test.MockHttpServletRequest in project spring-framework by spring-projects.
the class CompositeRequestConditionTests method compareEmpty.
@Test
public void compareEmpty() {
HttpServletRequest request = new MockHttpServletRequest();
CompositeRequestCondition empty = new CompositeRequestCondition();
CompositeRequestCondition notEmpty = new CompositeRequestCondition(this.param1);
assertEquals(0, empty.compareTo(empty, request));
assertEquals(-1, notEmpty.compareTo(empty, request));
assertEquals(1, empty.compareTo(notEmpty, request));
}
Aggregations