poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1537331 - in /poi/trunk: ./ src/java/org/apache/poi/hssf/usermodel/ src/java/org/apache/poi/util/ src/ooxml/testcases/org/apache/poi/xssf/streaming/ src/testcases/org/apache/poi/hssf/usermodel/ src/testcases/org/apache/poi/ss/usermodel/
Date Wed, 30 Oct 2013 22:26:14 GMT
Author: centic
Date: Wed Oct 30 22:26:13 2013
New Revision: 1537331

URL: http://svn.apache.org/r1537331
Log:
Slightly more test-coverage in HSSFSheet/XSSFSheet/SXSSFSheet and fix some Eclipse warnings

Modified:
    poi/trunk/build.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/trunk/src/java/org/apache/poi/util/NullLogger.java
    poi/trunk/src/java/org/apache/poi/util/POILogFactory.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java

Modified: poi/trunk/build.xml
URL: http://svn.apache.org/viewvc/poi/trunk/build.xml?rev=1537331&r1=1537330&r2=1537331&view=diff
==============================================================================
--- poi/trunk/build.xml (original)
+++ poi/trunk/build.xml Wed Oct 30 22:26:13 2013
@@ -681,7 +681,7 @@ under the License.
                 <group name="Main">
                     <classfiles>
                         <fileset dir="${main.output.dir}">
-                            <exclude name=""/>
+                            <exclude name="org/apache/poi/hssf/usermodel/DummyGraphics2d.class"/>
                         </fileset>
                     </classfiles>
                     <sourcefiles encoding="UTF-8">

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=1537331&r1=1537330&r2=1537331&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Wed Oct 30 22:26:13 2013
@@ -32,14 +32,14 @@ import org.apache.poi.hssf.record.*;
 import org.apache.poi.hssf.record.aggregates.DataValidityTable;
 import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
 import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock;
+import org.apache.poi.hssf.util.PaneInformation;
+import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.formula.FormulaShifter;
+import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.formula.ptg.Area3DPtg;
 import org.apache.poi.ss.formula.ptg.MemFuncPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.ss.formula.ptg.Area3DPtg;
 import org.apache.poi.ss.formula.ptg.UnionPtg;
-import org.apache.poi.hssf.util.PaneInformation;
-import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.formula.FormulaType;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellRange;
 import org.apache.poi.ss.usermodel.CellStyle;
@@ -1203,9 +1203,9 @@ public final class HSSFSheet implements 
      */
     public void setZoom(int numerator, int denominator) {
         if (numerator < 1 || numerator > 65535)
-            throw new IllegalArgumentException("Numerator must be greater than 1 and less
than 65536");
+            throw new IllegalArgumentException("Numerator must be greater than 0 and less
than 65536");
         if (denominator < 1 || denominator > 65535)
-            throw new IllegalArgumentException("Denominator must be greater than 1 and less
than 65536");
+            throw new IllegalArgumentException("Denominator must be greater than 0 and less
than 65536");
 
         SCLRecord sclRecord = new SCLRecord();
         sclRecord.setNumerator((short) numerator);

Modified: poi/trunk/src/java/org/apache/poi/util/NullLogger.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/NullLogger.java?rev=1537331&r1=1537330&r2=1537331&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/NullLogger.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/NullLogger.java Wed Oct 30 22:26:13 2013
@@ -29,6 +29,7 @@ package org.apache.poi.util;
  */
 public class NullLogger extends POILogger
 {
+    @Override
     public void initialize(final String cat)
     {
        //do nothing
@@ -41,6 +42,7 @@ public class NullLogger extends POILogge
      * @param obj1 The object to log.
      */
 
+    @Override
     public void log(final int level, final Object obj1)
     {
         //do nothing
@@ -52,6 +54,7 @@ public class NullLogger extends POILogge
      * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
      */
 
+    @Override
     public boolean check(final int level)
     {
        return false;
@@ -65,6 +68,7 @@ public class NullLogger extends POILogge
      * @param obj2 second object to place in the message
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2)
     {
        //do nothing
@@ -79,6 +83,7 @@ public class NullLogger extends POILogge
      * @param obj3 third Object to place in the message
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3)
     {
@@ -95,6 +100,7 @@ public class NullLogger extends POILogge
      * @param obj4 fourth Object to place in the message
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4)
     {
@@ -112,6 +118,7 @@ public class NullLogger extends POILogge
      * @param obj5 fifth Object to place in the message
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4, final Object obj5)
     {
@@ -130,6 +137,7 @@ public class NullLogger extends POILogge
      * @param obj6 sixth Object to place in the message
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4, final Object obj5,
                     final Object obj6)
@@ -150,6 +158,7 @@ public class NullLogger extends POILogge
      * @param obj7 seventh Object to place in the message
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4, final Object obj5,
                     final Object obj6, final Object obj7)
@@ -171,6 +180,7 @@ public class NullLogger extends POILogge
      * @param obj8 eighth Object to place in the message
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4, final Object obj5,
                     final Object obj6, final Object obj7, final Object obj8)
@@ -186,6 +196,7 @@ public class NullLogger extends POILogge
      * @param exception An exception to be logged
      */
 
+    @Override
     public void log(final int level, final Object obj1,
                     final Throwable exception)
     {
@@ -201,6 +212,7 @@ public class NullLogger extends POILogge
      * @param exception An exception to be logged
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Throwable exception)
     {
@@ -217,6 +229,7 @@ public class NullLogger extends POILogge
      * @param exception An error message to be logged
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Throwable exception)
     {
@@ -234,6 +247,7 @@ public class NullLogger extends POILogge
      * @param exception An exception to be logged
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4,
                     final Throwable exception)
@@ -253,6 +267,7 @@ public class NullLogger extends POILogge
      * @param exception An exception to be logged
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4, final Object obj5,
                     final Throwable exception)
@@ -273,6 +288,7 @@ public class NullLogger extends POILogge
      * @param exception An exception to be logged
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4, final Object obj5,
                     final Object obj6, final Throwable exception)
@@ -294,6 +310,7 @@ public class NullLogger extends POILogge
      * @param exception An exception to be logged
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4, final Object obj5,
                     final Object obj6, final Object obj7,
@@ -317,6 +334,7 @@ public class NullLogger extends POILogge
      * @param exception An exception to be logged
      */
 
+    @Override
     public void log(final int level, final Object obj1, final Object obj2,
                     final Object obj3, final Object obj4, final Object obj5,
                     final Object obj6, final Object obj7, final Object obj8,
@@ -350,6 +368,7 @@ public class NullLogger extends POILogge
      * @param obj1 The first object to match against.
      */
 
+    @Override
     public void logFormatted(final int level, final String message,
                              final Object obj1)
     {
@@ -382,6 +401,7 @@ public class NullLogger extends POILogge
      * @param obj2 The second object to match against.
      */
 
+    @Override
     public void logFormatted(final int level, final String message,
                              final Object obj1, final Object obj2)
     {
@@ -415,6 +435,7 @@ public class NullLogger extends POILogge
      * @param obj3 The third object to match against.
      */
 
+    @Override
     public void logFormatted(final int level, final String message,
                              final Object obj1, final Object obj2,
                              final Object obj3)
@@ -450,6 +471,7 @@ public class NullLogger extends POILogge
      * @param obj4 The forth object to match against.
      */
 
+    @Override
     public void logFormatted(final int level, final String message,
                              final Object obj1, final Object obj2,
                              final Object obj3, final Object obj4)

Modified: poi/trunk/src/java/org/apache/poi/util/POILogFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/POILogFactory.java?rev=1537331&r1=1537330&r2=1537331&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/POILogFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/POILogFactory.java Wed Oct 30 22:26:13 2013
@@ -19,7 +19,8 @@
 
 package org.apache.poi.util;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Provides logging without clients having to mess with
@@ -64,7 +65,7 @@ public class POILogFactory
      * @return a POILogger for the specified class
      */
 
-    public static POILogger getLogger(final Class theclass)
+    public static POILogger getLogger(final Class<?> theclass)
     {
         return getLogger(theclass.getName());
     }
@@ -111,7 +112,8 @@ public class POILogFactory
             logger = _loggers.get(cat);
         } else {
             try {
-              Class<? extends POILogger> loggerClass = 
+              @SuppressWarnings("unchecked")
+			Class<? extends POILogger> loggerClass = 
                  (Class<? extends POILogger>)Class.forName(_loggerClassName);
               logger = loggerClass.newInstance();
               logger.initialize(cat);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java?rev=1537331&r1=1537330&r2=1537331&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java Wed Oct
30 22:26:13 2013
@@ -19,9 +19,10 @@
 
 package org.apache.poi.xssf.streaming;
 
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestSheet;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.SXSSFITestDataProvider;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java?rev=1537331&r1=1537330&r2=1537331&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java Wed Oct 30 22:26:13
2013
@@ -347,17 +347,23 @@ public final class TestHSSFSheet extends
         int expectedHashB = -14556;
         HSSFWorkbook workbook = new HSSFWorkbook();
         HSSFSheet hssfSheet = workbook.createSheet();
+        assertFalse(hssfSheet.getObjectProtect());
         hssfSheet.protectSheet(passwordA);
+        assertTrue(hssfSheet.getObjectProtect());
+        assertEquals(expectedHashA, hssfSheet.getPassword());
 
         assertEquals(expectedHashA, hssfSheet.getSheet().getProtectionBlock().getPasswordHash());
 
         // Clone the sheet, and make sure the password hash is preserved
         HSSFSheet sheet2 = workbook.cloneSheet(0);
+        assertTrue(hssfSheet.getObjectProtect());
         assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash());
 
         // change the password on the first sheet
         hssfSheet.protectSheet(passwordB);
+        assertTrue(hssfSheet.getObjectProtect());
         assertEquals(expectedHashB, hssfSheet.getSheet().getProtectionBlock().getPasswordHash());
+        assertEquals(expectedHashB, hssfSheet.getPassword());
         // but the cloned sheet's password should remain unchanged
         assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash());
     }
@@ -452,6 +458,32 @@ public final class TestHSSFSheet extends
         int sclLoc = sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid);
         int window2Loc = sheet.getSheet().findFirstRecordLocBySid(WindowTwoRecord.sid);
         assertTrue(sclLoc == window2Loc + 1);
+        
+        // verify limits
+        try {
+        	sheet.setZoom(0, 2);
+        	fail("Should catch Exception here");
+        } catch (IllegalArgumentException e) {
+        	assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
+        }
+        try {
+        	sheet.setZoom(65536, 2);
+        	fail("Should catch Exception here");
+        } catch (IllegalArgumentException e) {
+        	assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
+        }
+        try {
+        	sheet.setZoom(2, 0);
+        	fail("Should catch Exception here");
+        } catch (IllegalArgumentException e) {
+        	assertEquals("Denominator must be greater than 0 and less than 65536", e.getMessage());
+        }
+        try {
+        	sheet.setZoom(2, 65536);
+        	fail("Should catch Exception here");
+        } catch (IllegalArgumentException e) {
+        	assertEquals("Denominator must be greater than 0 and less than 65536", e.getMessage());
+        }
     }
 
 
@@ -538,7 +570,8 @@ public final class TestHSSFSheet extends
         workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook);
     }
 
-    public void testAutoSizeColumn() {
+    @SuppressWarnings("deprecation")
+	public void testAutoSizeColumn() {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("43902.xls");
         String sheetName = "my sheet";
         HSSFSheet sheet = wb.getSheet(sheetName);
@@ -561,6 +594,7 @@ public final class TestHSSFSheet extends
 
         //create a region over the 2nd row and auto size the first column
         sheet.addMergedRegion(new CellRangeAddress(1,1,0,1));
+        assertNotNull(sheet.getMergedRegionAt(0));
         sheet.autoSizeColumn((short)0);
         HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb);
 
@@ -1009,4 +1043,27 @@ public final class TestHSSFSheet extends
         }
         assertEquals(40000, sheet.getColumnWidth((short)10));
     }
+
+    public void testShowInPane() {
+        Workbook wb = new HSSFWorkbook();
+        Sheet sheet = wb.createSheet();
+        sheet.showInPane(2, 3);
+        
+        try {
+        	sheet.showInPane(Integer.MAX_VALUE, 3);
+        	fail("Should catch exception here");
+        } catch (IllegalArgumentException e) {
+        	assertEquals("Maximum row number is 65535", e.getMessage());
+        }
+    }
+    
+    public void testDrawingRecords() {
+        HSSFWorkbook wb = new HSSFWorkbook();
+        HSSFSheet sheet = wb.createSheet();
+
+        /* TODO: NPE?
+        sheet.dumpDrawingRecords(false);
+        sheet.dumpDrawingRecords(true);*/
+        assertNull(sheet.getDrawingEscherAggregate());
+    }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java?rev=1537331&r1=1537330&r2=1537331&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java Wed Oct 30 22:26:13
2013
@@ -787,4 +787,17 @@ public abstract class BaseTestSheet exte
       }
     }
 
+    public void testBaseZoom() {
+        Workbook wb = _testDataProvider.createWorkbook();
+        Sheet sheet = wb.createSheet();
+        
+        // here we can only verify that setting some zoom values works, range-checking is
different between the implementations
+        sheet.setZoom(3,4);
+    }
+    
+    public void testBaseShowInPane() {
+        Workbook wb = _testDataProvider.createWorkbook();
+        Sheet sheet = wb.createSheet();
+        sheet.showInPane(2, 3);
+    }
 }



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


Mime
View raw message