poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1516818 - in /poi: tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/ trunk/src/java/org/apache/poi/hssf/record/ trunk/src/java/org/apache/poi/ss/formula/atp/ trunk/src/ooxml/java/org/apache/poi/ trunk/src/testcases/org/apache...
Date Fri, 23 Aug 2013 10:44:39 GMT
Author: centic
Date: Fri Aug 23 10:44:39 2013
New Revision: 1516818

URL: http://svn.apache.org/r1516818
Log:
fix some Eclipse warnings, adjust some unit tests slightly

Modified:
    poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java
    poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
    poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java
    poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java

Modified: poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1516818&r1=1516817&r2=1516818&view=diff
==============================================================================
--- poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
(original)
+++ poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
Fri Aug 23 10:44:39 2013
@@ -19,17 +19,32 @@ package org.apache.poi.xssf.usermodel;
 
 import java.util.List;
 
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.hssf.record.PasswordRecord;
+import org.apache.poi.ss.usermodel.BaseTestSheet;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.RichTextString;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.HexDump;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.xssf.model.CalculationChain;
 import org.apache.poi.xssf.model.CommentsTable;
 import org.apache.poi.xssf.model.StylesTable;
-import org.apache.poi.xssf.model.CalculationChain;
 import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.hssf.record.PasswordRecord;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetData;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetProtection;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
 
 
 @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans
with JDK 1.5 support
@@ -40,7 +55,8 @@ public final class TestXSSFSheet extends
     }
 
     //TODO column styles are not yet supported by XSSF
-    public void testDefaultColumnStyle() {
+    @Override
+	public void testDefaultColumnStyle() {
         //super.testDefaultColumnStyle();
     }
 
@@ -903,7 +919,7 @@ public final class TestXSSFSheet extends
      * Rows and cells can be created in random order,
      * but CTRows are kept in ascending order
      */
-    public void testCreateRow() {
+	public void testCreateRowXSSF() {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
         CTWorksheet wsh = sheet.getCTWorksheet();
@@ -1031,7 +1047,7 @@ public final class TestXSSFSheet extends
         assertEquals("XSSFSheet#removeRow did not clear calcChain entries",
                 0, calcChain.getCTCalcChain().sizeOfCArray());
 
-        //calcChain should be gone 
+        //calcChain should be gone
         wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
         assertNull(wb.getCalculationChain());
 
@@ -1043,37 +1059,37 @@ public final class TestXSSFSheet extends
     public void testTables() {
        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithTable.xlsx");
        assertEquals(3, wb.getNumberOfSheets());
-       
+
        // Check the table sheet
        XSSFSheet s1 = wb.getSheetAt(0);
        assertEquals("a", s1.getRow(0).getCell(0).getRichStringCellValue().toString());
        assertEquals(1.0, s1.getRow(1).getCell(0).getNumericCellValue());
-       
+
        List<XSSFTable> tables = s1.getTables();
        assertNotNull(tables);
        assertEquals(1, tables.size());
-       
+
        XSSFTable table = tables.get(0);
        assertEquals("Tabella1", table.getName());
        assertEquals("Tabella1", table.getDisplayName());
-       
+
        // And the others
        XSSFSheet s2 = wb.getSheetAt(1);
        assertEquals(0, s2.getTables().size());
        XSSFSheet s3 = wb.getSheetAt(2);
        assertEquals(0, s3.getTables().size());
     }
-    
+
     /**
      * Test to trigger OOXML-LITE generating to include org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetCalcPr
      */
     public void testSetForceFormulaRecalculation() {
-    	   XSSFWorkbook workbook = new XSSFWorkbook();
-         XSSFSheet sheet = workbook.createSheet("Sheet 1");
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
 
-         // Set
-         sheet.setForceFormulaRecalculation(true);
-         assertEquals(true, sheet.getForceFormulaRecalculation());
+        // Set
+        sheet.setForceFormulaRecalculation(true);
+        assertEquals(true, sheet.getForceFormulaRecalculation());
 
         // calcMode="manual" is unset when forceFormulaRecalculation=true
         CTCalcPr calcPr = workbook.getCTWorkbook().addNewCalcPr();
@@ -1082,13 +1098,13 @@ public final class TestXSSFSheet extends
         assertEquals(STCalcMode.AUTO, calcPr.getCalcMode());
 
         // Check
-         sheet.setForceFormulaRecalculation(false);
-         assertEquals(false, sheet.getForceFormulaRecalculation());
+        sheet.setForceFormulaRecalculation(false);
+        assertEquals(false, sheet.getForceFormulaRecalculation());
 
 
-         // Save, re-load, and re-check
-         workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
-         sheet = workbook.getSheet("Sheet 1");
-         assertEquals(false, sheet.getForceFormulaRecalculation());
+        // Save, re-load, and re-check
+        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+        sheet = workbook.getSheet("Sheet 1");
+        assertEquals(false, sheet.getForceFormulaRecalculation());
 	}
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java?rev=1516818&r1=1516817&r2=1516818&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java Fri Aug 23 10:44:39 2013
@@ -61,7 +61,7 @@ public final class StyleRecord extends S
 			field_3_outline_style_level = in.readByte();
 		} else {
 			int field_2_name_length = in.readShort();
-			
+
 			if(in.remaining() < 1) {
 				// Some files from Crystal Reports lack the is16BitUnicode byte
 				//  the remaining fields, which is naughty
@@ -71,7 +71,7 @@ public final class StyleRecord extends S
 				// guess this is OK if the string length is zero
 				field_4_name = "";
 			} else {
-				
+
 				field_3_stringHasMultibyte = in.readByte() != 0x00;
 				if (field_3_stringHasMultibyte) {
 					field_4_name = StringUtil.readUnicodeLE(in, field_2_name_length);
@@ -92,7 +92,7 @@ public final class StyleRecord extends S
 
 	/**
 	 * get the actual index of the style extended format record
-	 * @see #getXFIndex() 
+	 * @see #getXFIndex()
 	 * @return index of the xf record
 	 */
 	public int getXFIndex() {
@@ -138,6 +138,7 @@ public final class StyleRecord extends S
 		return field_4_name;
 	}
 
+	@Override
 	public String toString() {
 		StringBuffer sb = new StringBuffer();
 
@@ -155,16 +156,18 @@ public final class StyleRecord extends S
 		return sb.toString();
 	}
 
-	
+
+	@Override
 	protected int getDataSize() {
 		if (isBuiltin()) {
 			return 4; // short, byte, byte
 		}
-		return 2 // short xf index 
-			+ 3 // str len + flag 
+		return 2 // short xf index
+			+ 3 // str len + flag
 			+ field_4_name.length() * (field_3_stringHasMultibyte ? 2 : 1);
 	}
 
+	@Override
 	public void serialize(LittleEndianOutput out) {
 		out.writeShort(field_1_xf_index);
 		if (isBuiltin()) {
@@ -181,6 +184,7 @@ public final class StyleRecord extends S
 		}
 	}
 
+	@Override
 	public short getSid() {
 		return sid;
 	}

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java?rev=1516818&r1=1516817&r2=1516818&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java Fri Aug 23 10:44:39
2013
@@ -21,7 +21,7 @@ import org.apache.poi.ss.formula.udf.UDF
 import java.util.*;
 
 /**
- * Analysis Toolpack Function Definitions 
+ * Analysis Toolpack Function Definitions
  */
 public final class AnalysisToolPak implements UDFFinder {
 
@@ -229,9 +229,9 @@ public final class AnalysisToolPak imple
             if(metaData != null) {
                 throw new IllegalArgumentException(name + " is a built-in Excel function.
" +
                         "Use FunctoinEval.registerFunction(String name, Function func) instead.");
-            } else {
-                throw new IllegalArgumentException(name + " is not a function from the Excel
Analysis Toolpack.");
             }
+
+            throw new IllegalArgumentException(name + " is not a function from the Excel
Analysis Toolpack.");
         }
         FreeRefFunction f = inst.findFunction(name);
         if(f != null && !(f instanceof NotImplemented)) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java?rev=1516818&r1=1516817&r2=1516818&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java Fri Aug 23 10:44:39 2013
@@ -106,7 +106,7 @@ public class POIXMLDocumentPart {
      *
      * @param part - The package part that holds xml data represenring this sheet.
      * @param rel - the relationship of the given package part
-     * @see #read(POIXMLFactory, java.util.Map) 
+     * @see #read(POIXMLFactory, java.util.Map)
      */
     public POIXMLDocumentPart(PackagePart part, PackageRelationship rel){
         this.packagePart = part;
@@ -131,7 +131,7 @@ public class POIXMLDocumentPart {
     /**
      * When you open something like a theme, call this to
      *  re-base the XML Document onto the core child of the
-     *  current core document 
+     *  current core document
      */
     protected final void rebase(OPCPackage pkg) throws InvalidFormatException {
         PackageRelationshipCollection cores =
@@ -179,7 +179,7 @@ public class POIXMLDocumentPart {
      * {@link POIXMLDocumentPart} to the {@link PackagePart} of the target
      * {@link POIXMLDocumentPart} with a {@link PackageRelationship#getId()}
      * matching the given parameter value.
-     * 
+     *
      * @param id
      *            The relation id to look for
      * @return the target part of the relation, or null, if none exists
@@ -193,7 +193,7 @@ public class POIXMLDocumentPart {
      * {@link PackageRelationship}, that sources from the {@link PackagePart} of
      * this {@link POIXMLDocumentPart} to the {@link PackagePart} of the given
      * parameter value.
-     * 
+     *
      * @param part
      *            The {@link POIXMLDocumentPart} for which the according
      *            relation-id shall be found.
@@ -233,7 +233,7 @@ public class POIXMLDocumentPart {
     /**
      * Remove the relation to the specified part in this package and remove the
      * part, if it is no longer needed and flag is set to true.
-     * 
+     *
      * @param part
      *            The related part, to which the relation shall be removed.
      * @param removeUnusedParts
@@ -343,7 +343,8 @@ public class POIXMLDocumentPart {
      * @param noRelation if true, then no relationship is added.
      * @return the created child POIXMLDocumentPart
      */
-    protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory
factory, int idx, boolean noRelation){
+    @SuppressWarnings("null")
+	protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory
factory, int idx, boolean noRelation){
         try {
             PackagePartName ppName = PackagingURIHelper.createPartName(descriptor.getFileName(idx));
             PackageRelationship rel = null;
@@ -414,7 +415,7 @@ public class POIXMLDocumentPart {
             }
         }
     }
-    
+
     /**
      * Get the PackagePart that is the target of a relationship from this Part.
      *

Modified: poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java?rev=1516818&r1=1516817&r2=1516818&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/POIDataSamples.java Fri Aug 23 10:44:39 2013
@@ -16,7 +16,12 @@
 ==================================================================== */
 package org.apache.poi;
 
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * Centralises logic for finding/opening sample files
@@ -219,16 +224,20 @@ public final class POIDataSamples {
             _is = is;
         }
 
-        public int read() throws IOException {
+        @Override
+		public int read() throws IOException {
             return _is.read();
         }
-        public int read(byte[] b, int off, int len) throws IOException {
+        @Override
+		public int read(byte[] b, int off, int len) throws IOException {
             return _is.read(b, off, len);
         }
-        public boolean markSupported() {
+        @Override
+		public boolean markSupported() {
             return false;
         }
-        public void close() throws IOException {
+        @Override
+		public void close() throws IOException {
             _is.close();
         }
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java?rev=1516818&r1=1516817&r2=1516818&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java Fri Aug 23
10:44:39 2013
@@ -71,9 +71,8 @@ public class AllUserModelTests {
 		result.addTestSuite(TestRowStyle.class);
 		result.addTestSuite(TestSanityChecker.class);
 		result.addTestSuite(TestSheetHiding.class);
-		if (false) { // deliberately avoiding this one
-			result.addTestSuite(TestUnfixedBugs.class);
-		}
+		/* deliberately avoiding this one
+		result.addTestSuite(TestUnfixedBugs.class);*/
 		result.addTestSuite(TestUnicodeWorkbook.class);
 		result.addTestSuite(TestNonStandardWorkbookStreamNames.class);
 		result.addTestSuite(TestWorkbook.class);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java?rev=1516818&r1=1516817&r2=1516818&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java Fri Aug 23 10:44:39
2013
@@ -89,36 +89,41 @@ public abstract class BaseTestRow extend
 
     public void testRemoveCell() {
         Workbook workbook = _testDataProvider.createWorkbook();
-        Sheet sheet = workbook.createSheet();
-        Row row = sheet.createRow(0);
-
-        assertEquals(0, row.getPhysicalNumberOfCells());
-        assertEquals(-1, row.getLastCellNum());
-        assertEquals(-1, row.getFirstCellNum());
-
-        row.createCell(1);
-        assertEquals(2, row.getLastCellNum());
-        assertEquals(1, row.getFirstCellNum());
-        assertEquals(1, row.getPhysicalNumberOfCells());
-        row.createCell(3);
-        assertEquals(4, row.getLastCellNum());
-        assertEquals(1, row.getFirstCellNum());
-        assertEquals(2, row.getPhysicalNumberOfCells());
-        row.removeCell(row.getCell(3));
-        assertEquals(2, row.getLastCellNum());
-        assertEquals(1, row.getFirstCellNum());
-        assertEquals(1, row.getPhysicalNumberOfCells());
-        row.removeCell(row.getCell(1));
-        assertEquals(-1, row.getLastCellNum());
-        assertEquals(-1, row.getFirstCellNum());
-        assertEquals(0, row.getPhysicalNumberOfCells());
+        {
+            Sheet sheet = workbook.createSheet();
+            Row row = sheet.createRow(0);
+
+            assertEquals(0, row.getPhysicalNumberOfCells());
+            assertEquals(-1, row.getLastCellNum());
+            assertEquals(-1, row.getFirstCellNum());
+
+            row.createCell(1);
+            assertEquals(2, row.getLastCellNum());
+            assertEquals(1, row.getFirstCellNum());
+            assertEquals(1, row.getPhysicalNumberOfCells());
+            row.createCell(3);
+            assertEquals(4, row.getLastCellNum());
+            assertEquals(1, row.getFirstCellNum());
+            assertEquals(2, row.getPhysicalNumberOfCells());
+            row.removeCell(row.getCell(3));
+            assertEquals(2, row.getLastCellNum());
+            assertEquals(1, row.getFirstCellNum());
+            assertEquals(1, row.getPhysicalNumberOfCells());
+            row.removeCell(row.getCell(1));
+            assertEquals(-1, row.getLastCellNum());
+            assertEquals(-1, row.getFirstCellNum());
+            assertEquals(0, row.getPhysicalNumberOfCells());
+        }
 
         workbook = _testDataProvider.writeOutAndReadBack(workbook);
-        sheet = workbook.getSheetAt(0);
-        row = sheet.getRow(0);
-        assertEquals(-1, row.getLastCellNum());
-        assertEquals(-1, row.getFirstCellNum());
-        assertEquals(0, row.getPhysicalNumberOfCells());
+
+        {
+            Sheet sheet = workbook.getSheetAt(0);
+            Row row = sheet.getRow(0);
+            assertEquals(-1, row.getLastCellNum());
+            assertEquals(-1, row.getFirstCellNum());
+            assertEquals(0, row.getPhysicalNumberOfCells());
+        }
     }
 
     public void baseTestRowBounds(int maxRowNum) {
@@ -387,30 +392,30 @@ public abstract class BaseTestRow extend
         assertTrue(cell2 == it.next());
         assertEquals(Cell.CELL_TYPE_STRING, cell5.getCellType());
     }
-    
+
     public void testRowStyle() {
        Workbook workbook = _testDataProvider.createWorkbook();
        Sheet sheet = workbook.createSheet("test");
        Row row1 = sheet.createRow(0);
        Row row2 = sheet.createRow(1);
-       
+
        // Won't be styled currently
        assertEquals(false, row1.isFormatted());
        assertEquals(false, row2.isFormatted());
        assertEquals(null, row1.getRowStyle());
        assertEquals(null, row2.getRowStyle());
-       
+
        // Style one
        CellStyle style = workbook.createCellStyle();
        style.setDataFormat((short)4);
        row2.setRowStyle(style);
-       
+
        // Check
        assertEquals(false, row1.isFormatted());
        assertEquals(true, row2.isFormatted());
        assertEquals(null, row1.getRowStyle());
        assertEquals(style, row2.getRowStyle());
-       
+
        // Save, load and re-check
        workbook = _testDataProvider.writeOutAndReadBack(workbook);
        sheet = workbook.getSheetAt(0);
@@ -418,7 +423,7 @@ public abstract class BaseTestRow extend
        row1 = sheet.getRow(0);
        row2 = sheet.getRow(1);
        style = workbook.getCellStyleAt(style.getIndex());
-       
+
        assertEquals(false, row1.isFormatted());
        assertEquals(true, row2.isFormatted());
        assertEquals(null, row1.getRowStyle());



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


Mime
View raw message