]> source.dussan.org Git - poi.git/commitdiff
Patch from Josh from bug #44437 - improved unit test for poifs
authorNick Burch <nick@apache.org>
Thu, 21 Feb 2008 15:40:34 +0000 (15:40 +0000)
committerNick Burch <nick@apache.org>
Thu, 21 Feb 2008 15:40:34 +0000 (15:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@629831 13f79535-47bb-0310-9956-ffa450edef68

build.xml
src/testcases/org/apache/poi/hssf/HSSFTests.java
src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java

index b2c9977d0579e95dbc76fd71effbc3164643e287..3b1d2b6f39f35ca0ecad7fd119d64a1f28b1c54d 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -523,8 +523,7 @@ under the License.
       <batchtest todir="${main.reports.test}">
         <fileset dir="${main.src.test}">
           <include name="**/Test*.java"/>
-          <exclude name="**/AllTests.java"/>
-          <exclude name="**/TestEmptyDocument.java"/>
+          <exclude name="**/All*Tests.java"/>
           <exclude name="**/TestUnfixedBugs.java"/>
           <exclude name="**/TestcaseRecordInputStream.java"/>
         </fileset>
index da37b68adfa4aacbd19694feb1b17948c627d9b7..7a1d51903a2fa4f81208c8e70952942589a7fb61 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -100,15 +99,20 @@ import org.apache.poi.hssf.usermodel.TestReadWriteChart;
 import org.apache.poi.hssf.usermodel.TestSanityChecker;
 import org.apache.poi.hssf.usermodel.TestSheetShiftRows;
 import org.apache.poi.hssf.usermodel.TestWorkbook;
-import org.apache.poi.hssf.util.AllHSSFUtilTests;
+import org.apache.poi.hssf.util.TestAreaReference;
+import org.apache.poi.hssf.util.TestCellReference;
+import org.apache.poi.hssf.util.TestRKUtil;
+import org.apache.poi.hssf.util.TestRangeAddress;
+import org.apache.poi.hssf.util.TestSheetReferences;
 
 /**
- * Test Suite for running just HSSF tests.  Mostly
- * this is for my convienience.
+ * Test Suite for all sub-packages of org.apache.poi.hssf<br/>
+ * 
+ * Mostly this is for my convenience.
  * 
  * @author Andrew C. Oliver acoliver@apache.org
  */
-public class HSSFTests
+public final class HSSFTests
 {
 
     public static void main(String[] args)
@@ -119,7 +123,7 @@ public class HSSFTests
     public static Test suite()
     {
         TestSuite suite =
-            new TestSuite("Test for org.apache.poi.hssf.usermodel");
+            new TestSuite("Tests for org.apache.poi.hssf");
         //$JUnit-BEGIN$
 
     suite.addTest(new TestSuite(TestBugs.class));
@@ -198,7 +202,11 @@ public class HSSFTests
         suite.addTest(new TestSuite(TestUnitsRecord.class));
         suite.addTest(new TestSuite(TestValueRangeRecord.class));
         suite.addTest(new TestSuite(TestRowRecordsAggregate.class));
-        suite.addTest(AllHSSFUtilTests.suite());
+        suite.addTest(new TestSuite(TestAreaReference.class));
+        suite.addTest(new TestSuite(TestCellReference.class));
+                 suite.addTest(new TestSuite(TestRangeAddress.class));         
+        suite.addTest(new TestSuite(TestRKUtil.class));
+        suite.addTest(new TestSuite(TestSheetReferences.class));
         
         
         suite.addTest(AllFormulaTests.suite());
index 4f67f9876729a3f090b96c042f9d5d64e057c15c..870d752522a150be84606b0aae61ce166348ad2e 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.poi.poifs.filesystem;
 import java.io.IOException;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
 
 import junit.framework.TestCase;
 
@@ -157,12 +158,15 @@ public class TestEmptyDocument extends TestCase {
 
         DocumentEntry entry = (DocumentEntry) fs.getRoot().getEntry("Empty");
         assertEquals("Expected zero size", 0, entry.getSize());
+        byte[] actualReadbackData;
+        actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
         assertEquals("Expected zero read from stream", 0,
-                     IOUtils.toByteArray(new DocumentInputStream(entry)).length);
+                     actualReadbackData.length);
 
         entry = (DocumentEntry) fs.getRoot().getEntry("NotEmpty");
+        actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
         assertEquals("Expected size was wrong", testData.length, entry.getSize());
-        assertEquals("Expected different data read from stream", testData,
-                     IOUtils.toByteArray(new DocumentInputStream(entry)));
+        assertTrue("Expected different data read from stream", 
+                Arrays.equals(testData, actualReadbackData));
     }
 }