Skip to content

Commit

Permalink
[github-523] set locales for some tests. This closes #523
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912583 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pjfanning committed Sep 28, 2023
1 parent 57e1f4b commit fdad7e1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import org.apache.poi.xddf.usermodel.chart.XDDFChartData;
import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.model.StylesTable;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExternalLink;
Expand All @@ -79,6 +81,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.zip.CRC32;

import static org.apache.poi.hssf.HSSFTestDataSamples.openSampleFileStream;
Expand All @@ -100,6 +103,16 @@ public TestXSSFWorkbook() {
super(XSSFITestDataProvider.instance);
}

@BeforeAll
static void setUp() {
LocaleUtil.setUserLocale(Locale.US);
}

@AfterAll
static void tearDown() {
LocaleUtil.setUserLocale(null);
}

/**
* Tests that we can save, and then re-load a new document
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.FormulaError;
import org.apache.poi.util.LocaleUtil;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.time.LocalDate;
import java.util.Locale;

import static org.apache.poi.ss.util.Utils.addRow;
import static org.apache.poi.ss.util.Utils.assertDouble;
Expand All @@ -37,6 +41,16 @@ Licensed to the Apache Software Foundation (ASF) under one or more
*/
public class TestDays {

@BeforeAll
static void setUp() {
LocaleUtil.setUserLocale(Locale.US);
}

@AfterAll
static void tearDown() {
LocaleUtil.setUserLocale(null);
}

//https://support.microsoft.com/en-us/office/days-function-57740535-d549-4395-8728-0f07bff0b9df
@Test
void testMicrosoftExample1() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.Locale;

import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.util.LocaleUtil;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -45,6 +49,16 @@ void assertNotBuiltInFormat(String customFmt) {
assertEquals(-1, BuiltinFormats.getBuiltinFormat(customFmt));
}

@BeforeAll
static void setUp() {
LocaleUtil.setUserLocale(Locale.US);
}

@AfterAll
static void tearDown() {
LocaleUtil.setUserLocale(null);
}

@Test
public final void testBuiltinFormats() throws IOException {
try (Workbook wb = _testDataProvider.createWorkbook()) {
Expand Down

0 comments on commit fdad7e1

Please sign in to comment.