mirror of https://github.com/apache/poi.git
Apply some IDE suggestions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1919257 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2582e5e0c1
commit
a3d9c025e9
|
@ -1875,6 +1875,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try with one with the entities in the Content Types
|
// Try with one with the entities in the Content Types
|
||||||
|
//noinspection resource
|
||||||
assertThrows(Exception.class, () -> XSSFTestDataSamples.openSamplePackage("54764-2.xlsx"),
|
assertThrows(Exception.class, () -> XSSFTestDataSamples.openSamplePackage("54764-2.xlsx"),
|
||||||
"Should fail as too much expansion occurs");
|
"Should fail as too much expansion occurs");
|
||||||
|
|
||||||
|
@ -1943,6 +1944,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
|
|
||||||
// Workbook Factory gives helpful error on file
|
// Workbook Factory gives helpful error on file
|
||||||
File xlsbFile = HSSFTestDataSamples.getSampleFile("Simple.xlsb");
|
File xlsbFile = HSSFTestDataSamples.getSampleFile("Simple.xlsb");
|
||||||
|
//noinspection resource
|
||||||
assertThrows(XLSBUnsupportedException.class, () -> WorkbookFactory.create(xlsbFile), ".xlsb files not supported");
|
assertThrows(XLSBUnsupportedException.class, () -> WorkbookFactory.create(xlsbFile), ".xlsb files not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2292,7 +2294,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
|
|
||||||
List<XSSFShape> shapes = drawing.getShapes();
|
List<XSSFShape> shapes = drawing.getShapes();
|
||||||
assertEquals(1, shapes.size());
|
assertEquals(1, shapes.size());
|
||||||
assertTrue(shapes.get(0) instanceof XSSFSimpleShape);
|
assertInstanceOf(XSSFSimpleShape.class, shapes.get(0));
|
||||||
|
|
||||||
XSSFSimpleShape shape = (XSSFSimpleShape) shapes.get(0);
|
XSSFSimpleShape shape = (XSSFSimpleShape) shapes.get(0);
|
||||||
|
|
||||||
|
@ -2524,6 +2526,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("this test is only for manual verification, as we can't test if the cell is visible in Excel")
|
@Disabled("this test is only for manual verification, as we can't test if the cell is visible in Excel")
|
||||||
|
@Test
|
||||||
void test51451() throws IOException {
|
void test51451() throws IOException {
|
||||||
try (Workbook wb = new XSSFWorkbook()) {
|
try (Workbook wb = new XSSFWorkbook()) {
|
||||||
Sheet sh = wb.createSheet();
|
Sheet sh = wb.createSheet();
|
||||||
|
@ -3302,6 +3305,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
@Test
|
@Test
|
||||||
void test64045() {
|
void test64045() {
|
||||||
File file = XSSFTestDataSamples.getSampleFile("xlsx-corrupted.xlsx");
|
File file = XSSFTestDataSamples.getSampleFile("xlsx-corrupted.xlsx");
|
||||||
|
//noinspection resource
|
||||||
assertThrows(POIXMLException.class, () -> new XSSFWorkbook(file), "Should catch exception as the file is corrupted");
|
assertThrows(POIXMLException.class, () -> new XSSFWorkbook(file), "Should catch exception as the file is corrupted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3642,6 +3646,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
IOException ie = assertThrows(IOException.class, () -> WorkbookFactory.create(fis));
|
IOException ie = assertThrows(IOException.class, () -> WorkbookFactory.create(fis));
|
||||||
assertEquals("Can't open workbook - unsupported file type: XML", ie.getMessage());
|
assertEquals("Can't open workbook - unsupported file type: XML", ie.getMessage());
|
||||||
}
|
}
|
||||||
|
//noinspection resource
|
||||||
IOException ie = assertThrows(IOException.class, () -> WorkbookFactory.create(file));
|
IOException ie = assertThrows(IOException.class, () -> WorkbookFactory.create(file));
|
||||||
assertEquals("Can't open workbook - unsupported file type: XML", ie.getMessage());
|
assertEquals("Can't open workbook - unsupported file type: XML", ie.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -3899,7 +3904,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
XSSFCell cellSymbol = row.getCell(0);
|
XSSFCell cellSymbol = row.getCell(0);
|
||||||
if (cellSymbol != null) {
|
if (cellSymbol != null) {
|
||||||
XSSFComment comment = cellSymbol.getCellComment();
|
cellSymbol.getCellComment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
// assertTrue("Had zero length starting at length " + i, computeCellWidthFixed(font, b.toString()) > 0);
|
// assertTrue("Had zero length starting at length " + i, computeCellWidthFixed(font, b.toString()) > 0);
|
||||||
// }
|
// }
|
||||||
double widthManual = computeCellWidthManually(cell0, font);
|
double widthManual = computeCellWidthManually(cell0, font);
|
||||||
double widthBeforeCell = SheetUtil.getCellWidth(cell0, 8, null, false);
|
double widthBeforeCell = SheetUtil.getCellWidth(cell0, 8.0f, null, false);
|
||||||
double widthBeforeCol = SheetUtil.getColumnWidth(sheet, 0, false);
|
double widthBeforeCol = SheetUtil.getColumnWidth(sheet, 0, false);
|
||||||
|
|
||||||
String info = widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" +
|
String info = widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" +
|
||||||
|
@ -419,7 +419,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
|
|
||||||
double width = SheetUtil.getColumnWidth(sheet, 0, false);
|
double width = SheetUtil.getColumnWidth(sheet, 0, false);
|
||||||
assertTrue(width > 0, "Expected to have column width > 0 AFTER auto-size, but had " + width);
|
assertTrue(width > 0, "Expected to have column width > 0 AFTER auto-size, but had " + width);
|
||||||
width = SheetUtil.getCellWidth(cell0, 8, null, false);
|
width = SheetUtil.getCellWidth(cell0, 8.0f, null, false);
|
||||||
assertTrue(width > 0, "Expected to have cell width > 0 AFTER auto-size, but had " + width);
|
assertTrue(width > 0, "Expected to have cell width > 0 AFTER auto-size, but had " + width);
|
||||||
|
|
||||||
assertEquals(255 * 256, sheet.getColumnWidth(0)); // maximum column width is 255 characters
|
assertEquals(255 * 256, sheet.getColumnWidth(0)); // maximum column width is 255 characters
|
||||||
|
@ -1156,7 +1156,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
// verify that null-values can be set, this was possible up to 3.11, but broken in 3.12
|
// verify that null-values can be set, this was possible up to 3.11, but broken in 3.12
|
||||||
cell.setCellValue((String) null);
|
cell.setCellValue((String) null);
|
||||||
String value = cell.getStringCellValue();
|
String value = cell.getStringCellValue();
|
||||||
assertTrue(value == null || value.length() == 0,
|
assertTrue(value == null || value.isEmpty(),
|
||||||
"HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
|
"HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
|
||||||
|
|
||||||
cell = row.createCell(1);
|
cell = row.createCell(1);
|
||||||
|
@ -1166,7 +1166,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
||||||
|
|
||||||
value = cell.getStringCellValue();
|
value = cell.getStringCellValue();
|
||||||
assertTrue(value == null || value.length() == 0,
|
assertTrue(value == null || value.isEmpty(),
|
||||||
"HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
|
"HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
|
||||||
|
|
||||||
// set some value
|
// set some value
|
||||||
|
@ -1178,7 +1178,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||||
// verify that the null-value is actually set even if there was some value in the cell before
|
// verify that the null-value is actually set even if there was some value in the cell before
|
||||||
cell.setCellValue((String) null);
|
cell.setCellValue((String) null);
|
||||||
value = cell.getStringCellValue();
|
value = cell.getStringCellValue();
|
||||||
assertTrue(value == null || value.length() == 0,
|
assertTrue(value == null || value.isEmpty(),
|
||||||
"HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
|
"HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue