aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java2
-rw-r--r--src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java20
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java6
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java4
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java18
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java9
-rw-r--r--src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java10
8 files changed, 43 insertions, 28 deletions
diff --git a/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java b/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java
index 55e2c368f2..3bb0a53d5c 100644
--- a/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java
+++ b/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java
@@ -27,11 +27,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
-import java.util.zip.ZipException;
import org.apache.poi.POIOLE2TextExtractor;
import org.apache.poi.POITextExtractor;
-import org.apache.poi.dev.OOXMLPrettyPrint;
import org.apache.poi.extractor.ExtractorFactory;
import org.apache.poi.hpsf.extractor.HPSFPropertiesExtractor;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
diff --git a/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java b/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java
index 8f9ea7599e..919539592b 100644
--- a/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java
+++ b/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java
@@ -42,14 +42,18 @@ public class CommandLineTextExtractor {
POITextExtractor extractor =
ExtractorFactory.createExtractor(f);
- POITextExtractor metadataExtractor =
- extractor.getMetadataTextExtractor();
-
- System.out.println(" " + DIVIDER);
- System.out.println(metadataExtractor.getText());
- System.out.println(" " + DIVIDER);
- System.out.println(extractor.getText());
- System.out.println(DIVIDER);
+ try {
+ POITextExtractor metadataExtractor =
+ extractor.getMetadataTextExtractor();
+
+ System.out.println(" " + DIVIDER);
+ System.out.println(metadataExtractor.getText());
+ System.out.println(" " + DIVIDER);
+ System.out.println(extractor.getText());
+ System.out.println(DIVIDER);
+ } finally {
+ extractor.close();
+ }
}
}
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
index 8937f8e53f..ade8c806c3 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
@@ -50,6 +50,7 @@ import org.apache.poi.util.TempFile;
/**
* Physical zip package.
*/
+@SuppressWarnings("deprecation")
public final class ZipPackage extends Package {
private static POILogger logger = POILogFactory.getLogger(ZipPackage.class);
@@ -62,7 +63,6 @@ public final class ZipPackage extends Package {
/**
* Constructor. Creates a new, empty ZipPackage.
*/
- @SuppressWarnings("deprecation")
public ZipPackage() {
super(defaultPackageAccess);
this.zipArchive = null;
@@ -84,7 +84,6 @@ public final class ZipPackage extends Package {
* If the specified input stream not an instance of
* ZipInputStream.
*/
- @SuppressWarnings("deprecation")
ZipPackage(InputStream in, PackageAccess access) throws IOException {
super(access);
InputStream zis = new ZipInputStream(in);
@@ -102,7 +101,6 @@ public final class ZipPackage extends Package {
* @throws InvalidFormatException
* If the content type part parsing encounters an error.
*/
- @SuppressWarnings("deprecation")
ZipPackage(String path, PackageAccess access) {
super(access);
@@ -128,7 +126,6 @@ public final class ZipPackage extends Package {
* @throws InvalidFormatException
* If the content type part parsing encounters an error.
*/
- @SuppressWarnings("deprecation")
ZipPackage(File file, PackageAccess access) {
super(access);
@@ -156,7 +153,6 @@ public final class ZipPackage extends Package {
* @throws InvalidFormatException
* If the content type part parsing encounters an error.
*/
- @SuppressWarnings("deprecation")
ZipPackage(ZipEntrySource zipEntry, PackageAccess access) {
super(access);
this.zipArchive = zipEntry;
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
index 7bb2fd6db4..9d35eceace 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
@@ -917,8 +917,8 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
*/
- @Override
-public void setBorderRight(short border) {
+ @Override
+ public void setBorderRight(short border) {
CTBorder ct = getCTBorder();
CTBorderPr pr = ct.isSetRight() ? ct.getRight() : ct.addNewRight();
if(border == BORDER_NONE) ct.unsetRight();
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
index 7accdfdc25..3350149751 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
@@ -18,6 +18,8 @@ package org.apache.poi.xslf.usermodel;
import static org.junit.Assert.*;
+import java.io.IOException;
+
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
import org.apache.poi.sl.usermodel.TextShape.TextAutofit;
@@ -32,7 +34,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
*/
public class TestXSLFAutoShape {
@Test
- public void testTextBodyProperies() {
+ public void testTextBodyProperies() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
@@ -102,10 +104,12 @@ public class TestXSLFAutoShape {
assertEquals(TextDirection.VERTICAL, shape.getTextDirection());
shape.setTextDirection(null);
assertEquals(TextDirection.HORIZONTAL, shape.getTextDirection());
+
+ ppt.close();
}
@Test
- public void testTextParagraph() {
+ public void testTextParagraph() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
assertTrue(slide.getShapes().isEmpty());
@@ -202,10 +206,12 @@ public class TestXSLFAutoShape {
p.setTextAlign(null);
assertEquals(TextAlign.LEFT, p.getTextAlign());
assertFalse(p.getXmlObject().getPPr().isSetAlgn());
+
+ ppt.close();
}
@Test
- public void testTextRun() {
+ public void testTextRun() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
@@ -272,10 +278,12 @@ public class TestXSLFAutoShape {
assertEquals("POI", r.getRawText());
r.setText(null);
assertNull(r.getRawText());
+
+ ppt.close();
}
@Test
- public void testShapeType() {
+ public void testShapeType() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
@@ -290,5 +298,7 @@ public class TestXSLFAutoShape {
shape.setShapeType(tp);
assertEquals(tp, shape.getShapeType());
}
+
+ ppt.close();
}
} \ No newline at end of file
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 41e0580b70..566d1d712a 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
@@ -2381,9 +2381,12 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
// using temp file instead of ByteArrayOutputStream because of OOM in gump run
File tmp = TempFile.createTempFile("poi-test", ".bug57880");
- FileOutputStream fos = new FileOutputStream(tmp);
- wb.write(fos);
- fos.close();
+ OutputStream fos = new FileOutputStream(tmp);
+ try {
+ wb.write(fos);
+ } finally {
+ fos.close();
+ }
wb.close();
fmt = null; /*s = null;*/ wb = null;
diff --git a/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java b/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java
index d37a28eb2a..17fba4a29a 100644
--- a/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java
+++ b/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java
@@ -139,5 +139,7 @@ public final class VisioTextExtractor extends POIOLE2TextExtractor {
// Print not PrintLn as already has \n added to it
System.out.print(extractor.getText());
+
+ extractor.close();
}
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
index 8ef9a41be5..f1aad88c1f 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
@@ -228,6 +228,7 @@ public final class TestHSSFDataFormatter extends TestCase {
row = wb.getSheetAt(0).getRow(1);
it = row.cellIterator();
log("==== VALID TIME FORMATS ====");
+
while (it.hasNext()) {
Cell cell = it.next();
String fmt = cell.getCellStyle().getDataFormatString();
@@ -239,7 +240,8 @@ public final class TestHSSFDataFormatter extends TestCase {
assertTrue( ! "555.47431".equals(fmtval));
// check we found the time properly
- assertTrue("Format came out incorrect - " + fmt, fmtval.indexOf("11:23") > -1);
+ assertTrue("Format came out incorrect - " + fmt + ": " + fmtval + ", but expected to find '11:23'",
+ fmtval.indexOf("11:23") > -1);
}
// test number formats
@@ -409,8 +411,8 @@ public final class TestHSSFDataFormatter extends TestCase {
}
private static void log(String msg) {
- if (false) { // successful tests should be silent
- System.out.println(msg);
- }
+// if (false) { // successful tests should be silent
+// System.out.println(msg);
+// }
}
}