poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1882025 - in /poi/trunk/src: integrationtest/org/apache/poi/stress/ ooxml/java/org/apache/poi/ooxml/ ooxml/testcases/org/apache/poi/ooxml/
Date Fri, 25 Sep 2020 19:39:45 GMT
Author: centic
Date: Fri Sep 25 19:39:45 2020
New Revision: 1882025

URL: http://svn.apache.org/viewvc?rev=1882025&view=rev
Log:
Fix IDE warnings, add more assertion-output

Modified:
    poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java
    poi/trunk/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java
    poi/trunk/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java
    poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java?rev=1882025&r1=1882024&r2=1882025&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java Fri Sep 25 19:39:45
2020
@@ -33,7 +33,6 @@ import java.util.Set;
 import org.apache.poi.examples.hpsf.CopyCompare;
 import org.apache.poi.hpsf.DocumentSummaryInformation;
 import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument;
-import org.apache.poi.hpsf.MarkUnsupportedException;
 import org.apache.poi.hpsf.PropertySet;
 import org.apache.poi.hpsf.SummaryInformation;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
@@ -85,7 +84,7 @@ public class HPSFFileHandler extends POI
 		handlePOIDocument(hpsf);
 	}
 
-	private static boolean hasPropertyStream(POIFSFileSystem poifs, String streamName) throws
IOException, MarkUnsupportedException {
+	private static boolean hasPropertyStream(POIFSFileSystem poifs, String streamName) throws
IOException {
         DirectoryNode root = poifs.getRoot();
 	    if (!root.hasEntry(streamName)) {
 	        return false;
@@ -121,7 +120,7 @@ public class HPSFFileHandler extends POI
     @Test
     @SuppressWarnings("java:S2699")
 	public void test() throws Exception {
-	    String path = "test-data/hpsf/Test0313rur.adm";
+	    String path = "test-data/diagram/44501.vsd";
         try (InputStream stream = new FileInputStream(path)) {
             handleFile(stream, path);
         }

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java?rev=1882025&r1=1882024&r2=1882025&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java Fri Sep 25 19:39:45
2020
@@ -43,7 +43,7 @@ public class OPCFileHandler extends Abst
                 assertEquals(ContentTypes.CORE_PROPERTIES_PART, part.getContentType());
             }
             if (part.getPartName().toString().equals("/word/document.xml")) {
-                assertTrue("Expected one of " + XWPFRelation.MACRO_DOCUMENT + ", " + XWPFRelation.DOCUMENT
+ ", " + XWPFRelation.TEMPLATE + 
+                assertTrue("Expected one of " + XWPFRelation.MACRO_DOCUMENT + ", " + XWPFRelation.DOCUMENT
+ ", " + XWPFRelation.TEMPLATE +
                         ", but had " + part.getContentType(),
                         XWPFRelation.DOCUMENT.getContentType().equals(part.getContentType())
||
                         XWPFRelation.MACRO_DOCUMENT.getContentType().equals(part.getContentType())
||
@@ -54,9 +54,9 @@ public class OPCFileHandler extends Abst
             }
         }
     }
-	
+
     @Override
-    public void handleExtracting(File file) throws Exception {
+    public void handleExtracting(File file) {
         // text-extraction is not possible currently for these types of files
     }
 
@@ -68,7 +68,7 @@ public class OPCFileHandler extends Abst
         try (InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000))
{
             handleFile(stream, file.getPath());
         }
-		
+
 		handleExtracting(file);
 	}
 }

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java?rev=1882025&r1=1882024&r2=1882025&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java Fri Sep 25 19:39:45
2020
@@ -52,9 +52,7 @@ public class XSLFFileHandler extends Sli
 
 
         // additionally try the other getText() methods
-
-		//noinspection rawtypes
-		try (SlideShowExtractor extractor = (SlideShowExtractor) ExtractorFactory.createExtractor(file))
{
+		try (SlideShowExtractor<?,?> extractor = (SlideShowExtractor<?, ?>) ExtractorFactory.createExtractor(file))
{
 			assertNotNull(extractor);
 			extractor.setSlidesByDefault(true);
 			extractor.setNotesByDefault(true);
@@ -81,4 +79,4 @@ public class XSLFFileHandler extends Sli
 
 		handleExtracting(file);
 	}
-}
\ No newline at end of file
+}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java?rev=1882025&r1=1882024&r2=1882025&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLRelation.java Fri Sep 25 19:39:45
2020
@@ -56,17 +56,17 @@ public abstract class POIXMLRelation {
     /**
      * Describes the content stored in a part.
      */
-    private String _type;
+    private final String _type;
 
     /**
      * The kind of connection between a source part and a target part in a package.
      */
-    private String _relation;
+    private final String _relation;
 
     /**
      * The path component of a pack URI.
      */
-    private String _defaultName;
+    private final String _defaultName;
 
     /**
      * Constructors or factory method to construct instances of this relationship

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java?rev=1882025&r1=1882024&r2=1882025&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java Fri Sep 25
19:39:45 2020
@@ -37,7 +37,6 @@ import java.util.List;
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart;
 import org.apache.poi.ooxml.util.PackageHelper;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
@@ -87,7 +86,7 @@ public final class TestPOIXMLDocument {
         }
     }
 
-    private static void traverse(POIXMLDocument doc) throws IOException{
+    private static void traverse(POIXMLDocument doc) {
         HashMap<String,POIXMLDocumentPart> context = new HashMap<>();
         for (RelationPart p : doc.getRelationParts()){
             traverse(p, context);
@@ -97,7 +96,7 @@ public final class TestPOIXMLDocument {
     /**
      * Recursively traverse a OOXML document and assert that same logical parts have the
same physical instances
      */
-    private static void traverse(RelationPart rp, HashMap<String,POIXMLDocumentPart>
context) throws IOException{
+    private static void traverse(RelationPart rp, HashMap<String,POIXMLDocumentPart>
context) {
         POIXMLDocumentPart dp = rp.getDocumentPart();
         assertEquals(rp.getRelationship().getTargetURI().toString(), dp.getPackagePart().getPartName().getName());
 
@@ -255,7 +254,7 @@ public final class TestPOIXMLDocument {
     }
 
     @Test
-    public void testCommitNullPart() throws IOException, InvalidFormatException {
+    public void testCommitNullPart() throws IOException {
         POIXMLDocumentPart part = new POIXMLDocumentPart();
         part.prepareForCommit();
         part.commit();
@@ -311,6 +310,7 @@ public final class TestPOIXMLDocument {
         try (InputStream is = pds.openResourceAsStream("bug62513.pptx");
             XMLSlideShow ppt = new XMLSlideShow(is)) {
             POIXMLDocumentPart doc = ppt.getSlides().get(12).getRelationById("rId3");
+            assertNotNull(doc);
             assertEquals(POIXMLDocumentPart.class, doc.getClass());
         }
     }
@@ -320,19 +320,17 @@ public final class TestPOIXMLDocument {
         // the schema type loader is cached per thread in POIXMLTypeLoader.
         // So create a new Thread and change the context class loader (which would normally
be used)
         // to not contain the OOXML classes
-        Runnable run = new Runnable() {
-            public void run() {
-                InputStream is = POIDataSamples.getSlideShowInstance().openResourceAsStream("table_test.pptx");
-                XMLSlideShow ppt = null;
-                try {
-                    ppt = new XMLSlideShow(is);
-                    ppt.getSlides().get(0).getShapes();
-                } catch (IOException e) {
-                    fail("failed to load XMLSlideShow");
-                } finally {
-                    IOUtils.closeQuietly(ppt);
-                    IOUtils.closeQuietly(is);
-                }
+        Runnable run = () -> {
+            InputStream is = POIDataSamples.getSlideShowInstance().openResourceAsStream("table_test.pptx");
+            XMLSlideShow ppt = null;
+            try {
+                ppt = new XMLSlideShow(is);
+                ppt.getSlides().get(0).getShapes();
+            } catch (IOException e) {
+                fail("failed to load XMLSlideShow");
+            } finally {
+                IOUtils.closeQuietly(ppt);
+                IOUtils.closeQuietly(is);
             }
         };
 
@@ -348,15 +346,15 @@ public final class TestPOIXMLDocument {
                 ta[i].setUncaughtExceptionHandler(uh);
                 ta[i].start();
             }
-            for (int i=0; i<ta.length; i++) {
+            for (Thread thread : ta) {
                 try {
-                    ta[i].join();
+                    thread.join();
                 } catch (InterruptedException e) {
                     fail("failed to join thread");
                 }
             }
         }
-        assertFalse(uh.hasException());
+        assertFalse("Should not have an exception now, but had " + uh.e, uh.hasException());
     }
 
     private static class UncaughtHandler implements UncaughtExceptionHandler {



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


Mime
View raw message