You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2016/06/11 17:03:59 UTC
svn commit: r1747916 -
/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
Author: centic
Date: Sat Jun 11 17:03:59 2016
New Revision: 1747916
URL: http://svn.apache.org/viewvc?rev=1747916&view=rev
Log:
Add some pre-checks to fail the test with better assertion if the locale is not set correctly.
Modified:
poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java?rev=1747916&r1=1747915&r2=1747916&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java Sat Jun 11 17:03:59 2016
@@ -34,7 +34,11 @@ import java.util.Locale;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.TestHSSFDataFormatter;
+import org.apache.poi.ss.format.CellFormat;
+import org.apache.poi.ss.format.CellFormatResult;
+import org.apache.poi.ss.util.NumberToTextConverter;
import org.apache.poi.util.LocaleUtil;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -47,6 +51,28 @@ import org.junit.Test;
public class TestDataFormatter {
private static final double _15_MINUTES = 0.041666667;
+ @BeforeClass
+ public static void setUpClass() {
+ // some pre-checks to hunt for a problem in the Maven build
+ // these checks ensure that the correct locale is set, so a failure here
+ // usually indicates an invalid locale during test-execution
+
+ assertFalse(DateUtil.isADateFormat(-1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
+ assertEquals(Locale.getDefault(), LocaleUtil.getUserLocale());
+ final String textValue = NumberToTextConverter.toText(1234.56);
+ assertEquals(-1, textValue.indexOf('E'));
+ Object cellValueO = Double.valueOf(1234.56);
+
+ /*CellFormat cellFormat = new CellFormat("_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-");
+ CellFormatResult result = cellFormat.apply(cellValueO);
+ assertEquals(" 1,234.56 ", result.text);*/
+
+ CellFormat cfmt = CellFormat.getInstance("_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-");
+ CellFormatResult result = cfmt.apply(cellValueO);
+ assertEquals("This failure can indicate that the wrong locale is used during test-execution, ensure you run with english/US via -Duser.language=en -Duser.country=US",
+ " 1,234.56 ", result.text);
+ }
+
/**
* Test that we use the specified locale when deciding
* how to format normal numbers
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org