poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1701139 - in /poi/trunk/src: integrationtest/org/apache/poi/stress/ ooxml/java/org/apache/poi/extractor/ ooxml/java/org/apache/poi/openxml4j/opc/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/poi/xslf/usermodel/ ooxm...
Date Thu, 03 Sep 2015 20:59:15 GMT
Author: centic
Date: Thu Sep  3 20:59:14 2015
New Revision: 1701139

URL: http://svn.apache.org/r1701139
Log:
Eclipse warnings, close resources in CommandLineTextExtractor, add try/finally, formatting,
...

Modified:
    poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java
    poi/trunk/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java?rev=1701139&r1=1701138&r2=1701139&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java Thu Sep 
3 20:59:14 2015
@@ -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;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java?rev=1701139&r1=1701138&r2=1701139&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/extractor/CommandLineTextExtractor.java Thu Sep
 3 20:59:14 2015
@@ -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();
+         }
       }
    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java?rev=1701139&r1=1701138&r2=1701139&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java Thu Sep  3 20:59:14
2015
@@ -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 Pa
     /**
      * Constructor. Creates a new, empty ZipPackage.
      */
-    @SuppressWarnings("deprecation")
     public ZipPackage() {
     	super(defaultPackageAccess);
     	this.zipArchive = null;
@@ -84,7 +84,6 @@ public final class ZipPackage extends Pa
      *             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 Pa
      * @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 Pa
      * @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 Pa
      * @throws InvalidFormatException
      *             If the content type part parsing encounters an error.
      */
-    @SuppressWarnings("deprecation")
     ZipPackage(ZipEntrySource zipEntry, PackageAccess access) {
     	super(access);
     	this.zipArchive = zipEntry;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java?rev=1701139&r1=1701138&r2=1701139&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java Thu Sep  3 20:59:14
2015
@@ -917,8 +917,8 @@ public class XSSFCellStyle implements Ce
      * @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();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java?rev=1701139&r1=1701138&r2=1701139&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java Thu
Sep  3 20:59:14 2015
@@ -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.drawin
  */
 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

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1701139&r1=1701138&r2=1701139&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Thu Sep
 3 20:59:14 2015
@@ -2381,9 +2381,12 @@ public final class TestXSSFBugs extends
 
         // 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;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java?rev=1701139&r1=1701138&r2=1701139&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java Thu
Sep  3 20:59:14 2015
@@ -139,5 +139,7 @@ public final class VisioTextExtractor ex
 
 		// Print not PrintLn as already has \n added to it
 		System.out.print(extractor.getText());
+		
+		extractor.close();
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java?rev=1701139&r1=1701138&r2=1701139&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java Thu Sep
 3 20:59:14 2015
@@ -228,6 +228,7 @@ public final class TestHSSFDataFormatter
 		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
          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
 	}
 
 	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);
+//		}
 	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message