@Test public void locale() { Locale locale = new Locale("nl", "nl"); this.builder.locale(locale); MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); assertEquals(locale, request.getLocale()); }
MediaType MEDIA_TYPE_JSON_UTF8 = new MediaType("application", "json", java.nio.charset.Charset.forName("UTF-8")); MockHttpServletRequestBuilder request = post("/myPostPath"); request.content(json); request.locale(Locale.JAPANESE); request.accept(MEDIA_TYPE_JSON_UTF8); request.contentType(MEDIA_TYPE_JSON_UTF8); mockMvc.perform(request) .andDo(print()) .andExpect(status().isOk());
@Test public void errorResponse() throws Exception { Account account = accountCitizen("foo"); String token = prepareClientAppUserAccessToken(account); mockMvc.perform(post("/v1/echo/test-failure")// .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) .content(q("{'message':'abc'}")) .locale(Locale.ENGLISH) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.errors[0].type", is("RequireCitizenException"))) .andExpect(jsonPath("$.errors[0].translated", is(true))) .andExpect(jsonPath("$.errors[0].title", is("You have not activated your account, please activate and try again."))); } }