try to fix rare(?) localization issue in OOXMLParserTest
@@ -44,6 +44,7 @@ import javax.xml.transform.stream.StreamResult;
import org.apache.poi.util.LocaleUtil;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -77,14 +78,19 @@ public class OOXMLParserTest extends TikaTest {
@BeforeClass
public static void setUp() {
USER_LOCALE = LocaleUtil.getUserLocale();
- LocaleUtil.setUserLocale(Locale.US);
}
@AfterClass
public static void tearDown() {
LocaleUtil.setUserLocale(USER_LOCALE);
+ Locale.setDefault(USER_LOCALE);
}
+ @Before
+ public void beforeEach() {
+ LocaleUtil.setUserLocale(Locale.US);
+ Locale.setDefault(Locale.US);
+ }
@Test
public void testExcel() throws Exception {
@@ -1456,15 +1462,11 @@ public class OOXMLParserTest extends TikaTest {
@Test
public void testXLSBVarious() throws Exception {
- try {
- LocaleUtil.setUserLocale(Locale.US);
- //have to set to US because of a bug in POI for $ 3.03 in Locale.ITALIAN
OfficeParserConfig officeParserConfig = new OfficeParserConfig();
officeParserConfig.setExtractMacros(true);
ParseContext parseContext = new ParseContext();
parseContext.set(OfficeParserConfig.class, officeParserConfig);
- List<Metadata> metadataList =
- getRecursiveMetadata("testEXCEL_various.xlsb", parseContext);
+ List<Metadata> metadataList = getRecursiveMetadata("testEXCEL_various.xlsb", parseContext);
assertEquals(4, metadataList.size());
String xml = metadataList.get(0).get(TikaCoreProperties.TIKA_CONTENT);
@@ -1491,8 +1493,7 @@ public class OOXMLParserTest extends TikaTest {
assertContains("test WordArt", xml);
- assertContains("<a href=\"http://lucene.apache.org/\">http://lucene.apache.org/</a>",
- xml);
+ assertContains("<a href=\"http://lucene.apache.org/\">http://lucene.apache.org/</a>", xml);
assertContains("<a href=\"http://tika.apache.org/\">http://tika.apache.org/</a>", xml);
assertContains("OddLeftHeader OddCenterHeader OddRightHeader", xml);
@@ -1502,9 +1503,7 @@ public class OOXMLParserTest extends TikaTest {
assertContains("OddLeftFooter OddCenterFooter OddRightFooter", xml);
assertContains("EvenLeftFooter EvenCenterFooter EvenRightFooter", xml);
assertContains("FirstPageLeftFooter FirstPageCenterFooter FirstPageRightFooter", xml);
- } finally {
- LocaleUtil.setUserLocale(USER_LOCALE);
- }
+
}
@Test
