poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1650598 - in /poi/trunk/src: ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java
Date Fri, 09 Jan 2015 16:52:24 GMT
Author: centic
Date: Fri Jan  9 16:52:23 2015
New Revision: 1650598

URL: http://svn.apache.org/r1650598
Log:
Fix Eclipse warnings, provide better error message and adjust javadoc slightly

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
    poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java?rev=1650598&r1=1650597&r2=1650598&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java Fri Jan  9 16:52:23
2015
@@ -168,7 +168,7 @@ public abstract class PackagePart implem
 	public PackageRelationship addExternalRelationship(String target,
 			String relationshipType, String id) {
 		if (target == null) {
-			throw new IllegalArgumentException("target");
+			throw new IllegalArgumentException("target is null for type " + relationshipType);
 		}
 		if (relationshipType == null) {
 			throw new IllegalArgumentException("relationshipType");

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java?rev=1650598&r1=1650597&r2=1650598&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java Fri Jan  9 16:52:23
2015
@@ -98,6 +98,8 @@ public class SXSSFSheet implements Sheet
      *
      * @param rownum  row number
      * @return high level Row object representing a row in the sheet
+     * @throws IllegalArgumentException If the max. number of rows is exceeded or 
+     *      a rownum is provided where the row is already flushed to disk.
      * @see #removeRow(Row)
      */
     public Row createRow(int rownum)

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java?rev=1650598&r1=1650597&r2=1650598&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java Fri Jan 
9 16:52:23 2015
@@ -17,6 +17,8 @@
 
 package org.apache.poi.ss.formula;
 
+import java.io.IOException;
+
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
@@ -213,37 +215,43 @@ public class TestWorkbookEvaluator exten
 	/**
 	 * Functions like IF, INDIRECT, INDEX, OFFSET etc can return AreaEvals which
 	 * should be dereferenced by the evaluator
+	 * @throws IOException 
 	 */
-	public void testResultOutsideRange() {
+	public void testResultOutsideRange() throws IOException {
 		Workbook wb = new HSSFWorkbook();
-		Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0);
-		cell.setCellFormula("D2:D5"); // IF(TRUE,D2:D5,D2) or  OFFSET(D2:D5,0,0) would work too
-		FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
-		CellValue cv;
 		try {
-			cv = fe.evaluate(cell);
-		} catch (IllegalArgumentException e) {
-			if ("Specified row index (0) is outside the allowed range (1..4)".equals(e.getMessage()))
{
-				throw new AssertionFailedError("Identified bug in result dereferencing");
-			}
-			throw new RuntimeException(e);
+    		Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0);
+    		cell.setCellFormula("D2:D5"); // IF(TRUE,D2:D5,D2) or  OFFSET(D2:D5,0,0) would work
too
+    		FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
+    		CellValue cv;
+    		try {
+    			cv = fe.evaluate(cell);
+    		} catch (IllegalArgumentException e) {
+    			if ("Specified row index (0) is outside the allowed range (1..4)".equals(e.getMessage()))
{
+    				throw new AssertionFailedError("Identified bug in result dereferencing");
+    			}
+    			throw new RuntimeException(e);
+    		}
+    		assertEquals(Cell.CELL_TYPE_ERROR, cv.getCellType());
+    		assertEquals(ErrorConstants.ERROR_VALUE, cv.getErrorValue());
+    
+    		// verify circular refs are still detected properly
+    		fe.clearAllCachedResultValues();
+    		cell.setCellFormula("OFFSET(A1,0,0)");
+    		cv = fe.evaluate(cell);
+    		assertEquals(Cell.CELL_TYPE_ERROR, cv.getCellType());
+    		assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cv.getErrorValue());
+		} finally {
+		    wb.close();
 		}
-		assertEquals(Cell.CELL_TYPE_ERROR, cv.getCellType());
-		assertEquals(ErrorConstants.ERROR_VALUE, cv.getErrorValue());
-
-		// verify circular refs are still detected properly
-		fe.clearAllCachedResultValues();
-		cell.setCellFormula("OFFSET(A1,0,0)");
-		cv = fe.evaluate(cell);
-		assertEquals(Cell.CELL_TYPE_ERROR, cv.getCellType());
-		assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cv.getErrorValue());
 	}
 	
 
   /**
    * formulas with defined names.
+ * @throws IOException 
    */
-  public void testNamesInFormulas() {
+  public void testNamesInFormulas() throws IOException {
     Workbook wb = new HSSFWorkbook();
     Sheet sheet = wb.createSheet("Sheet1");
     
@@ -279,6 +287,8 @@ public class TestWorkbookEvaluator exten
     assertEquals(10.0, fe.evaluate(row1.getCell(2)).getNumberValue());
     assertEquals(15.0, fe.evaluate(row2.getCell(2)).getNumberValue());
     assertEquals(28.14, fe.evaluate(row3.getCell(2)).getNumberValue());
+    
+    wb.close();
   }
 	
 }



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


Mime
View raw message