Skip to content

Commit

Permalink
Improves Epub30CheckExpandedTest.testPageList() by actually setting a…
Browse files Browse the repository at this point in the history
…n 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).
  • Loading branch information
haqer1 authored and tofi86 committed Dec 20, 2016
1 parent 71a76ee commit 70cc37d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package com.adobe.epubcheck.api;

import java.util.Collections;
import java.util.Locale;

import org.junit.Test;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 70cc37d

Please sign in to comment.