OcelotContext { Locale getLocaleFromHttpSession() { Locale locale = null; HttpSession httpSession = getHttpSession(); if (httpSession != null) { locale = (Locale) httpSession.getAttribute(Constants.LOCALE); } return locale; }  HttpSession getHttpSession(); Locale getLocale(); void setLocale(Locale locale); boolean isUserInRole(String role); Principal getPrincipal();  }
@Test public void testGetLocaleFromHttpSession() { System.out.println("getLocaleFromHttpSession"); HttpSession httpSession = mock(HttpSession.class); doReturn(httpSession).when(instance).getHttpSession(); when(httpSession.getAttribute(eq(Constants.LOCALE))).thenReturn(Locale.CHINA); Locale result = instance.getLocaleFromHttpSession(); assertThat(result).isEqualTo(Locale.CHINA); }