@Test public void testLookupRequest() { HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class); EasyMock.expect(request.getSession(false)).andReturn(null); EasyMock.expect(request.getAttribute(DefaultLocaleStore.LOCALE_KEY)).andReturn(Locale.CANADA); request.setAttribute("javax.servlet.jsp.jstl.fmt.locale", Locale.CANADA); EasyMock.replay(request); DefaultLocaleStore provider = new DefaultLocaleStore(request); assertEquals(Locale.CANADA, provider.get()); EasyMock.verify(request); }
@Test public void testStoreSession() { HttpSession session = EasyMock.createStrictMock(HttpSession.class); session.setAttribute(DefaultLocaleStore.LOCALE_KEY, Locale.GERMANY); EasyMock.replay(session); HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class); EasyMock.expect(request.getSession(false)).andReturn(session); request.setAttribute("javax.servlet.jsp.jstl.fmt.locale", Locale.GERMANY); EasyMock.replay(request); DefaultLocaleStore provider = new DefaultLocaleStore(request); provider.set(Locale.GERMANY); EasyMock.verify(request, session); }