コード例 #1
0
  @Test
  public void annotationSettingsAreComposedWithInstalledModules() {
    final C10NConfigBase childConfig =
        new C10NConfigBase() {
          @Override
          public void configure() {
            bindAnnotation(Jp.class).toLocale(Locale.JAPANESE);
          }
        };

    C10NConfigBase config =
        new C10NConfigBase() {
          @Override
          public void configure() {
            install(childConfig);
            bindAnnotation(Eng.class).toLocale(Locale.ENGLISH);
          }
        };

    C10N.configure(config);
    Locale.setDefault(Locale.ENGLISH);
    assertThat(C10N.get(Messages.class).greeting(), is("hello"));
    Locale.setDefault(Locale.JAPANESE);
    assertThat(C10N.get(ChildMessages.class).greeting(), is("こんにちは"));
  }
コード例 #2
0
  @Test
  public void bundleSettingsAreComposedWithInstalledModules() {
    final C10NConfigBase childConfig =
        new C10NConfigBase() {
          @Override
          public void configure() {
            bindBundle(ChildResourceBundle.class.getName());
          }
        };

    C10NConfigBase config =
        new C10NConfigBase() {
          @Override
          public void configure() {
            install(childConfig);
            bindBundle(ParentResourceBundle.class.getName());
          }
        };
    config.doConfigure();

    List<ResourceBundle> b =
        config.getBundlesForLocale(C10NConfigBaseInstallTest.class, Locale.ENGLISH);
    assertThat(b.size(), is(2));
    assertThat(b.get(0).getString("parentKey"), is("parentBundle"));
    assertThat(b.get(1).getString("childKey"), is("childBundle"));

    C10N.configure(config);
    assertThat(C10N.get(Messages.class).greeting(), is("parentHello"));
    assertThat(C10N.get(ChildMessages.class).greeting(), is("childHello"));
  }