From 70cc37dfafa865193578a779988494e58be5cb70 Mon Sep 17 00:00:00 2001 From: dilbirligi Date: Tue, 20 Dec 2016 15:58:19 -0700 Subject: [PATCH] Improves Epub30CheckExpandedTest.testPageList() by actually setting an appropriate default locale for the duration of the test (#712) * Improves Epub30CheckExpandedTest.testPageList() by actually setting a default locale for the duration of the test that tests that the case transformations are indeed locale-independent. Better testing of fix for issue #711. * Minor tweaks in comment wording. Perhaps configuring CI to run unit tests under random default locales or once in a while to run them under a number of different default locales is also worth considering (this could allow catching some similar issues proactively before they are reported by end-users). --- .../api/Epub30CheckExpandedTest.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java b/src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java index 735a1f5de..d07979593 100644 --- a/src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java +++ b/src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java @@ -23,6 +23,7 @@ package com.adobe.epubcheck.api; import java.util.Collections; +import java.util.Locale; import org.junit.Test; @@ -479,11 +480,26 @@ public void testValidateEPUB30_customNsAttr() testValidateDocument("invalid/custom-ns-attr/"); } - + /** + * Also tests locale-independent character case transformations (such as + * lower-casing). Specifically, in issue 711, when the default locale is set + * to Turkish, lower-casing resulted in incorrect vocabulary strings (for + * "PAGE_LIST" enum constant name relevant to the original issue report, as + * well as for numerous other strings). Therefore, a Turkish locale is set as + * the default at the beginning of the test (the original locale is restored + * at the end of the test). + */ @Test public void testPageList() { - testValidateDocument("valid/page-list"); + Locale l = Locale.getDefault(); + // E.g., tests that I is not lower-cased to \u0131 based on locale's collation rules: + Locale.setDefault(new Locale("tr", "TR")); + try { + testValidateDocument("valid/page-list"); + } finally { // restore the original locale + Locale.setDefault(l); + } } @Test