mirror of https://github.com/apache/poi.git
Fix some IDE warnings and enable commented test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1856691 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8f3935d023
commit
e6c3dd9350
|
@ -849,11 +849,9 @@ public class TestCellFormat {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testApplyObjectDate() throws ParseException {
|
public void testApplyObjectDate() throws ParseException {
|
||||||
|
|
||||||
CellFormat cf1 = CellFormat.getInstance("m/d/yyyy");
|
CellFormat cf1 = CellFormat.getInstance("m/d/yyyy");
|
||||||
Date date1 = new SimpleDateFormat("M/d/y", Locale.ROOT).parse("01/11/2012");
|
Date date1 = new SimpleDateFormat("M/d/y", Locale.ROOT).parse("01/11/2012");
|
||||||
//assertEquals("1/11/2012", cf1.apply(date1).text);
|
assertEquals("1/11/2012", cf1.apply(date1).text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -911,21 +909,18 @@ public class TestCellFormat {
|
||||||
public void testSimpleFractionFormat() throws IOException {
|
public void testSimpleFractionFormat() throws IOException {
|
||||||
CellFormat cf1 = CellFormat.getInstance("# ?/?");
|
CellFormat cf1 = CellFormat.getInstance("# ?/?");
|
||||||
// Create a workbook, row and cell to test with
|
// Create a workbook, row and cell to test with
|
||||||
Workbook wb = new HSSFWorkbook();
|
try (Workbook wb = new HSSFWorkbook()) {
|
||||||
try {
|
|
||||||
Sheet sheet = wb.createSheet();
|
Sheet sheet = wb.createSheet();
|
||||||
Row row = sheet.createRow(0);
|
Row row = sheet.createRow(0);
|
||||||
Cell cell = row.createCell(0);
|
Cell cell = row.createCell(0);
|
||||||
cell.setCellValue(123456.6);
|
cell.setCellValue(123456.6);
|
||||||
//System.out.println(cf1.apply(cell).text);
|
//System.out.println(cf1.apply(cell).text);
|
||||||
assertEquals("123456 3/5", cf1.apply(cell).text);
|
assertEquals("123456 3/5", cf1.apply(cell).text);
|
||||||
} finally {
|
|
||||||
wb.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAccountingFormats() throws IOException {
|
public void testAccountingFormats() {
|
||||||
char pound = '\u00A3';
|
char pound = '\u00A3';
|
||||||
char euro = '\u20AC';
|
char euro = '\u20AC';
|
||||||
|
|
||||||
|
@ -1011,4 +1006,4 @@ public class TestCellFormat {
|
||||||
assertNotNull(instance);
|
assertNotNull(instance);
|
||||||
assertEquals("01/01/1970", instance.apply(new Date(12345)).text);
|
assertEquals("01/01/1970", instance.apply(new Date(12345)).text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -584,8 +584,7 @@ public class TestDataFormatter {
|
||||||
DataFormatter dfUS = new DataFormatter(Locale.US, true);
|
DataFormatter dfUS = new DataFormatter(Locale.US, true);
|
||||||
|
|
||||||
// Create a spreadsheet with some formula errors in it
|
// Create a spreadsheet with some formula errors in it
|
||||||
Workbook wb = new HSSFWorkbook();
|
try (Workbook wb = new HSSFWorkbook()) {
|
||||||
try {
|
|
||||||
Sheet s = wb.createSheet();
|
Sheet s = wb.createSheet();
|
||||||
Row r = s.createRow(0);
|
Row r = s.createRow(0);
|
||||||
Cell c = r.createCell(0, CellType.ERROR);
|
Cell c = r.createCell(0, CellType.ERROR);
|
||||||
|
@ -595,8 +594,6 @@ public class TestDataFormatter {
|
||||||
|
|
||||||
c.setCellErrorValue(FormulaError.REF.getCode());
|
c.setCellErrorValue(FormulaError.REF.getCode());
|
||||||
assertEquals(FormulaError.REF.getString(), dfUS.formatCellValue(c));
|
assertEquals(FormulaError.REF.getString(), dfUS.formatCellValue(c));
|
||||||
} finally {
|
|
||||||
wb.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,8 +602,7 @@ public class TestDataFormatter {
|
||||||
DataFormatter formatter = new DataFormatter();
|
DataFormatter formatter = new DataFormatter();
|
||||||
|
|
||||||
// Create a spreadsheet with some TRUE/FALSE boolean values in it
|
// Create a spreadsheet with some TRUE/FALSE boolean values in it
|
||||||
Workbook wb = new HSSFWorkbook();
|
try (Workbook wb = new HSSFWorkbook()) {
|
||||||
try {
|
|
||||||
Sheet s = wb.createSheet();
|
Sheet s = wb.createSheet();
|
||||||
Row r = s.createRow(0);
|
Row r = s.createRow(0);
|
||||||
Cell c = r.createCell(0);
|
Cell c = r.createCell(0);
|
||||||
|
@ -616,8 +612,6 @@ public class TestDataFormatter {
|
||||||
|
|
||||||
c.setCellValue(false);
|
c.setCellValue(false);
|
||||||
assertEquals("FALSE", formatter.formatCellValue(c));
|
assertEquals("FALSE", formatter.formatCellValue(c));
|
||||||
} finally {
|
|
||||||
wb.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,8 +779,7 @@ public class TestDataFormatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertFormatsTo(String expected, double input) throws IOException {
|
private static void assertFormatsTo(String expected, double input) throws IOException {
|
||||||
Workbook wb = new HSSFWorkbook();
|
try (Workbook wb = new HSSFWorkbook()) {
|
||||||
try {
|
|
||||||
Sheet s1 = wb.createSheet();
|
Sheet s1 = wb.createSheet();
|
||||||
Row row = s1.createRow(0);
|
Row row = s1.createRow(0);
|
||||||
Cell rawValue = row.createCell(0);
|
Cell rawValue = row.createCell(0);
|
||||||
|
@ -797,9 +790,6 @@ public class TestDataFormatter {
|
||||||
String actual = new DataFormatter().formatCellValue(rawValue);
|
String actual = new DataFormatter().formatCellValue(rawValue);
|
||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
wb.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -835,7 +825,7 @@ public class TestDataFormatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatWithTrailingDotsOtherLocale() throws Exception {
|
public void testFormatWithTrailingDotsOtherLocale() {
|
||||||
DataFormatter dfIT = new DataFormatter(Locale.ITALY);
|
DataFormatter dfIT = new DataFormatter(Locale.ITALY);
|
||||||
assertEquals("1.000.000", dfIT.formatRawCellContents(1000000, -1, "#,##0"));
|
assertEquals("1.000.000", dfIT.formatRawCellContents(1000000, -1, "#,##0"));
|
||||||
assertEquals("1.000", dfIT.formatRawCellContents(1000000, -1, "#,##0,"));
|
assertEquals("1.000", dfIT.formatRawCellContents(1000000, -1, "#,##0,"));
|
||||||
|
@ -892,7 +882,7 @@ public class TestDataFormatter {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleNumericFormatsInGermanyLocale() {
|
public void testSimpleNumericFormatsInGermanyLocale() {
|
||||||
List<Locale> locales = Arrays.asList(new Locale[] {Locale.GERMANY, Locale.US, Locale.ROOT} );
|
Locale[] locales = new Locale[] {Locale.GERMANY, Locale.US, Locale.ROOT};
|
||||||
for (Locale locale : locales) {
|
for (Locale locale : locales) {
|
||||||
//show that LocaleUtil has no effect on these tests
|
//show that LocaleUtil has no effect on these tests
|
||||||
LocaleUtil.setUserLocale(locale);
|
LocaleUtil.setUserLocale(locale);
|
||||||
|
@ -1015,4 +1005,4 @@ public class TestDataFormatter {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue