You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2020/01/30 21:09:17 UTC

svn commit: r1873385 - in /poi/trunk/src: integrationtest/org/apache/poi/stress/ java/org/apache/poi/hssf/record/ scratchpad/src/org/apache/poi/hpbf/model/ scratchpad/src/org/apache/poi/hwpf/model/

Author: centic
Date: Thu Jan 30 21:09:17 2020
New Revision: 1873385

URL: http://svn.apache.org/viewvc?rev=1873385&view=rev
Log:
Improve some assertions and error messages for exceptions seen in the regression tests

Modified:
    poi/trunk/src/integrationtest/org/apache/poi/stress/SlideShowHandler.java
    poi/trunk/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/SlideShowHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/SlideShowHandler.java?rev=1873385&r1=1873384&r2=1873385&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/SlideShowHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/SlideShowHandler.java Thu Jan 30 21:09:17 2020
@@ -50,7 +50,7 @@ public abstract class SlideShowHandler e
 
         // write out the file
         ByteArrayOutputStream out = writeToArray(ss);
-        
+
         readContent(ss);
 
         // read in the written file
@@ -67,11 +67,11 @@ public abstract class SlideShowHandler e
         } finally {
             stream.close();
         }
-        
+
         return stream;
     }
 
-    
+
     private void readContent(SlideShow<?,?> ss) {
         for (Slide<?,?> s : ss.getSlides()) {
             s.getTitle();
@@ -96,8 +96,8 @@ public abstract class SlideShowHandler e
     private void readShapes(Shape<?,?> s) {
         // recursively walk group-shapes
         if(s instanceof GroupShape) {
-            GroupShape<? extends Shape, ?> shapes = (GroupShape<? extends Shape, ?>) s;
-            for (Shape<? extends Shape, ?> shape : shapes) {
+            GroupShape<? extends Shape<?,?>, ?> shapes = (GroupShape<? extends Shape<?,?>, ?>) s;
+            for (Shape<? extends Shape<?,?>, ?> shape : shapes) {
                 readShapes(shape);
             }
         }
@@ -123,20 +123,22 @@ public abstract class SlideShowHandler e
             }
         }
     }
-    
+
     private void readPictures(SlideShow<?,?> ss) {
         for (PictureData pd : ss.getPictureData()) {
             Dimension dim = pd.getImageDimension();
-            assertTrue(dim.getHeight() >= 0);
-            assertTrue(dim.getWidth() >= 0);
+            assertTrue("Expecting a valid height, but had an image with height: " + dim.getHeight(),
+                    dim.getHeight() >= 0);
+            assertTrue("Expecting a valid width, but had an image with width: " + dim.getWidth(),
+                    dim.getWidth() >= 0);
         }
     }
-    
+
     private void renderSlides(SlideShow<?,?> ss) {
-        Dimension pgsize = ss.getPageSize();
+        Dimension pgSize = ss.getPageSize();
 
         for (Slide<?,?> s : ss.getSlides()) {
-            BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_ARGB);
+            BufferedImage img = new BufferedImage(pgSize.width, pgSize.height, BufferedImage.TYPE_INT_ARGB);
             Graphics2D graphics = img.createGraphics();
 
             // default rendering options
@@ -145,10 +147,10 @@ public abstract class SlideShowHandler e
             graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
             graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
             graphics.setRenderingHint(Drawable.BUFFERED_IMAGE, new WeakReference<>(img));
-    
+
             // draw stuff
             s.draw(graphics);
-            
+
             graphics.dispose();
             img.flush();
         }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java?rev=1873385&r1=1873384&r2=1873385&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/HeaderFooterRecord.java Thu Jan 30 21:09:17 2020
@@ -89,13 +89,10 @@ public final class HeaderFooterRecord ex
     }
 
     public String toString() {
-        StringBuilder sb = new StringBuilder();
-
-        sb.append('[').append("HEADERFOOTER").append("] (0x");
-        sb.append(Integer.toHexString(sid).toUpperCase(Locale.ROOT)).append(")\n");
-        sb.append("  rawData=").append(HexDump.toHex(_rawData)).append("\n");
-        sb.append("[/").append("HEADERFOOTER").append("]\n");
-        return sb.toString();
+        return '[' + "HEADERFOOTER" + "] (0x" +
+                Integer.toHexString(sid).toUpperCase(Locale.ROOT) + ")\n" +
+                "  rawData=" + HexDump.toHex(_rawData) + "\n" +
+                "[/" + "HEADERFOOTER" + "]\n";
     }
 
     @Override

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java?rev=1873385&r1=1873384&r2=1873385&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java Thu Jan 30 21:09:17 2020
@@ -60,7 +60,7 @@ public abstract class HPBFPart {
 				dir = (DirectoryNode)dir.getEntry(path[i]);
 			} catch (FileNotFoundException e) {
 				throw new IllegalArgumentException("File invalid - failed to find directory entry '"
-						+ path[i] + "'");
+						+ path[i] + "': " + e);
 			}
 		}
 		return dir;
@@ -101,7 +101,7 @@ public abstract class HPBFPart {
 	public final byte[] getData() {
 		return data;
 	}
-	
+
 	protected final void setData(byte[] data) {
 	    this.data = data.clone();
 	}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java?rev=1873385&r1=1873384&r2=1873385&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java Thu Jan 30 21:09:17 2020
@@ -64,7 +64,8 @@ public class ComplexFileTable {
         this._grpprls = sprmBuffers.toArray(new SprmBuffer[0]);
 
         if (tableStream[offset] != TEXT_PIECE_TABLE_TYPE) {
-            throw new IOException("The text piece table is corrupted");
+            throw new IOException("The text piece table is corrupted, expected byte value " + TEXT_PIECE_TABLE_TYPE +
+                    " but had " + tableStream[offset]);
         }
         int pieceTableSize = LittleEndian.getInt(tableStream, ++offset);
         offset += LittleEndian.INT_SIZE;



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