[dna-commits] DNA SVN: r438 - trunk/dna-common/src/test/java/org/jboss/dna/common.
dna-commits at lists.jboss.org
dna-commits at lists.jboss.org
Mon Aug 18 12:58:48 EDT 2008
Author: jverhaeg at redhat.com
Date: 2008-08-18 12:58:48 -0400 (Mon, 18 Aug 2008)
New Revision: 438
Modified:
trunk/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java
Log:
DNA-206: Changed AbstractI18nTest to have a single test that first analyzes i18n fields for problems, then checks for global problems, where field checking triggers lazy localization that may reveal global problems.
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java 2008-08-17 22:33:27 UTC (rev 437)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java 2008-08-18 16:58:48 UTC (rev 438)
@@ -45,26 +45,30 @@
@Test
@SuppressWarnings( "unchecked" )
- public void shouldNotHaveLocalizationProblems() throws Exception {
- Method method = i18nClass.getDeclaredMethod("getLocalizationProblemLocales", (Class[])null);
- Set<Locale> locales = (Set<Locale>)method.invoke(null, (Object[])null);
- method = i18nClass.getDeclaredMethod("getLocalizationProblems", Locale.class);
- for (Locale locale : locales) {
- assertThat(((Set<String>)method.invoke(null, locale)).isEmpty(), is(true));
- }
- }
-
- @Test
- public void shouldNotHaveProblems() throws IllegalAccessException {
+ public void shouldNotHaveProblems() throws Exception {
for (Field fld : i18nClass.getDeclaredFields()) {
if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
&& (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
&& (fld.getModifiers() & Modifier.FINAL) != Modifier.FINAL) {
I18n i18n = (I18n)fld.get(null);
if (i18n.hasProblem()) {
- fail();
+ fail(i18n.problem());
}
}
}
+ // Check for global problems after checking field problems since global problems are detected lazily upon field usage
+ Method method = i18nClass.getDeclaredMethod("getLocalizationProblemLocales", (Class[])null);
+ Set<Locale> locales = (Set<Locale>)method.invoke(null, (Object[])null);
+ if (!locales.isEmpty()) {
+ method = i18nClass.getDeclaredMethod("getLocalizationProblems", Locale.class);
+ for (Locale locale : locales) {
+ Set<String> problems = (Set<String>)method.invoke(null, locale);
+ try {
+ assertThat(problems.isEmpty(), is(true));
+ } catch (AssertionError error) {
+ fail(problems.iterator().next());
+ }
+ }
+ }
}
}
More information about the dna-commits
mailing list