### Question:
I18nController extends DefaultController { @Route(method = HttpMethod.GET, uri = "i18n/{key}") public Result getMessage(@Parameter("key") String key, @QueryParameter("locale") Locale locale) { String message; if (locale != null && !locale.equals(InternationalizationService.DEFAULT_LOCALE)) { message = service.get(locale, key); } else { message = service.get(context().request().languages(), key); } if (message != null) { return ok(message).as(MimeTypes.TEXT); } else { return notFound("No message for " + key).as(MimeTypes.TEXT); } }  @Route(method = HttpMethod.GET, uri = "i18n/bundles/{file<.+>}.properties") Result getBundleResource(@PathParameter("file") String file,
                                    @HttpParameter(HeaderNames.IF_NONE_MATCH) String ifNoneMatch); @Route(method = HttpMethod.GET, uri = "i18n/bundles/{file<.+>}.json") Result getBundleResourceForI18Next(@QueryParameter("locales") String listOfLocales,
                                              @HttpParameter(HeaderNames.IF_NONE_MATCH) String ifNoneMatch); @Route(method = HttpMethod.GET, uri = "i18n/{key}") Result getMessage(@Parameter("key") String key, @QueryParameter("locale") Locale locale); @Route(method = HttpMethod.GET, uri = "i18n") Result getMessages(@QueryParameter("locales") List<Locale> locales,
                              @HttpParameter(HeaderNames.IF_NONE_MATCH) String ifNoneMatch);  }### Answer:
@Test public void testThatWeCanRetrieveMessagesIndividuallyUsingQueryParameter() throws Exception { Action.ActionResult result = Action.action(new Invocation() { @Override public Result invoke() throws Throwable { return controller.getMessage("welcome", Locale.ENGLISH); } }).invoke(); assertThat(toString(result)).isEqualTo("hello"); result = Action.action(new Invocation() { @Override public Result invoke() throws Throwable { return controller.getMessage("welcome", Locale.FRENCH); } }).invoke(); assertThat(toString(result)).isEqualTo("bonjour"); result = Action.action(new Invocation() { @Override public Result invoke() throws Throwable { return controller.getMessage("welcome", Locale.FRANCE); } }).invoke(); assertThat(toString(result)).isEqualTo("hello"); }
@Test public void testThatWeCanRetrieveMessagesIndividuallyUsingHttpHeader() throws Exception { Action.ActionResult result = Action.action(new Invocation() { @Override public Result invoke() throws Throwable { return controller.getMessage("welcome", null); } }) .header(HeaderNames.ACCEPT_LANGUAGE, "en") .invoke(); assertThat(toString(result)).isEqualTo("hello"); result = Action.action(new Invocation() { @Override public Result invoke() throws Throwable { return controller.getMessage("welcome", null); } }) .header(HeaderNames.ACCEPT_LANGUAGE, "fr") .invoke(); assertThat(toString(result)).isEqualTo("bonjour"); }