I18n implements I18nResource { public static void initialize( Class<?> i18nClass ) { validateI18nClass(i18nClass); synchronized (i18nClass) { try { for (Field fld : i18nClass.getDeclaredFields()) { if (fld.getType() == I18n.class) { initializeI18nField(fld); } } cleanupPreviousProblems(i18nClass); } catch (IllegalAccessException err) { throw new IllegalArgumentException(CommonI18n.i18nClassNotPublic.text(i18nClass)); } } } private  I18n( String id,
                  Class<?> i18nClass ); static Set<Locale> getLocalizationProblemLocales( Class<?> i18nClass ); static Set<String> getLocalizationProblems( Class<?> i18nClass ); static Set<String> getLocalizationProblems( Class<?> i18nClass,
                                                       Locale locale ); static void initialize( Class<?> i18nClass ); String id(); boolean hasProblem(); boolean hasProblem( Locale locale ); String problem(); String problem( Locale locale ); @Override String text( Object... arguments ); @Override String text( Locale locale,
                        Object... arguments ); @Override String toString();  }
@Test( expected = IllegalArgumentException.class ) public void shouldFailToInitializeIfNoClassSupplied() { I18n.initialize(null); }
@Test public void shouldInitializeFinalClasses() { I18n.initialize(TestI18nFinal.class); assertThat(TestI18nFinal.testMessage, instanceOf(I18n.class)); }
@Test public void shouldInitializePrivateClasses() { I18n.initialize(TestI18nPrivate.class); assertThat(TestI18nPrivate.testMessage, instanceOf(I18n.class)); }
@Test public void shouldInitializeI18nFields() { I18n.initialize(TestI18n.class); assertThat(TestI18n.testMessage, instanceOf(I18n.class)); }
@Test public void shouldNotInitializeNonI18nFields() { I18n.initialize(TestI18n.class); assertThat(TestI18n.nonI18n, nullValue()); }
@Test public void shouldNotBeLocalizedAfterInitialization() { I18n.initialize(TestI18nDuplicateProperty.class); assertThat(TestI18nDuplicateProperty.testMessage.localeToTextMap.get(Locale.getDefault()), nullValue()); assertThat(TestI18nDuplicateProperty.testMessage.localeToProblemMap.get(Locale.getDefault()), nullValue()); }