aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2017-06-20 07:05:08 +0000
committerJaven O'Neal <onealj@apache.org>2017-06-20 07:05:08 +0000
commit12fd163018aef6760dfd53b834cb827f8cb8f682 (patch)
tree555574b167a7923a2d91f87ce8ddbf105080faf9 /src/ooxml/testcases/org/apache/poi
parent83a5c2f50ded6536649e0d0a13903e004f52e639 (diff)
downloadpoi-12fd163018aef6760dfd53b834cb827f8cb8f682.tar.gz
poi-12fd163018aef6760dfd53b834cb827f8cb8f682.zip
rename createXls and createXlsx helper functions: these are specifically for testing text rotation.
Made the file creation compatible on Windows and Mac/Linux using POI TempFile instead of a hard-coded filename. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1799307 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java50
1 files changed, 18 insertions, 32 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
index 3b45fdc539..38f1151f65 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
@@ -2885,51 +2885,37 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
wb.close();
}
- private void createXls() throws IOException {
- Workbook workbook = new HSSFWorkbook();
- FileOutputStream fileOut = new FileOutputStream("/tmp/rotated.xls");
- Sheet sheet1 = workbook.createSheet();
- Row row1 = sheet1.createRow((short) 0);
-
- Cell cell1 = row1.createCell(0);
-
- cell1.setCellValue("Successful rotated text.");
-
- CellStyle style = workbook.createCellStyle();
- style.setRotation((short) -90);
-
- cell1.setCellStyle(style);
-
- workbook.write(fileOut);
- fileOut.close();
- workbook.close();
- }
-
- private void createXlsx() throws IOException {
- Workbook workbook = new XSSFWorkbook();
- FileOutputStream fileOut = new FileOutputStream("/tmp/rotated.xlsx");
- Sheet sheet1 = workbook.createSheet();
- Row row1 = sheet1.createRow((short) 0);
+ /**
+ * helper function for {@link #test58043()}
+ * Side-effects: closes the provided workbook!
+ *
+ * @param workbook the workbook to save for manual checking
+ * @param outputFile the output file location to save the workbook to
+ */
+ private void saveRotatedTextExample(Workbook workbook, File outputFile) throws IOException {
+ Sheet sheet = workbook.createSheet();
+ Row row = sheet.createRow((short) 0);
- Cell cell1 = row1.createCell(0);
+ Cell cell = row.createCell(0);
- cell1.setCellValue("Unsuccessful rotated text.");
+ cell.setCellValue("Unsuccessful rotated text.");
CellStyle style = workbook.createCellStyle();
style.setRotation((short) -90);
- cell1.setCellStyle(style);
+ cell.setCellStyle(style);
- workbook.write(fileOut);
- fileOut.close();
+ OutputStream fos = new FileOutputStream(outputFile);
+ workbook.write(fos);
+ fos.close();
workbook.close();
}
@Ignore("Creates files for checking results manually, actual values are tested in Test*CellStyle")
@Test
public void test58043() throws IOException {
- createXls();
- createXlsx();
+ saveRotatedTextExample(new HSSFWorkbook(), TempFile.createTempFile("rotated", ".xls"));
+ saveRotatedTextExample(new XSSFWorkbook(), TempFile.createTempFile("rotated", ".xlsx"));
}
@Test