diff options
author | Nick Burch <nick@apache.org> | 2008-01-31 17:30:16 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2008-01-31 17:30:16 +0000 |
commit | 7238e677fae0461842eacd3430a389e8fd24918c (patch) | |
tree | c9e93034c2f134dd82f0fa086208b6ffec80dcdd /src/testcases/org/apache/poi/hssf | |
parent | ab75551e142683953d3c374c04cd9d06ad804400 (diff) | |
download | poi-7238e677fae0461842eacd3430a389e8fd24918c.tar.gz poi-7238e677fae0461842eacd3430a389e8fd24918c.zip |
Convert HSSFEventFactory to using the new HSSFRecordStream, which returns fully-formed HSSFRecords. HSSFRecordStream allows for pull-style eventusermodel processing
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@617167 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java b/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java index bd936a0afc..049b43ef93 100644 --- a/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java +++ b/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java @@ -23,8 +23,13 @@ import java.io.File; import java.io.FileInputStream; import java.util.ArrayList; +import org.apache.poi.hssf.record.DVALRecord; +import org.apache.poi.hssf.record.DVRecord; +import org.apache.poi.hssf.record.EOFRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.ContinueRecord; +import org.apache.poi.hssf.record.SelectionRecord; +import org.apache.poi.hssf.record.WindowTwoRecord; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import junit.framework.TestCase; @@ -48,7 +53,15 @@ public class TestHSSFEventFactory extends TestCase { factory.processWorkbookEvents(req, fs); // Check we got the records + System.out.println("Processed, found " + mockListen.records.size() + " records"); assertTrue( mockListen.records.size() > 100 ); + + // Check that the last few records are as we expect + // (Makes sure we don't accidently skip the end ones) + int numRec = mockListen.records.size(); + assertEquals(WindowTwoRecord.class, mockListen.records.get(numRec-3).getClass()); + assertEquals(SelectionRecord.class, mockListen.records.get(numRec-2).getClass()); + assertEquals(EOFRecord.class, mockListen.records.get(numRec-1).getClass()); } public void testWithCrazyContinueRecords() throws Exception { @@ -66,6 +79,7 @@ public class TestHSSFEventFactory extends TestCase { factory.processWorkbookEvents(req, fs); // Check we got the records + System.out.println("Processed, found " + mockListen.records.size() + " records"); assertTrue( mockListen.records.size() > 100 ); // And none of them are continue ones @@ -74,6 +88,13 @@ public class TestHSSFEventFactory extends TestCase { for(int i=0; i<r.length; i++) { assertFalse( r[i] instanceof ContinueRecord ); } + + // Check that the last few records are as we expect + // (Makes sure we don't accidently skip the end ones) + int numRec = mockListen.records.size(); + assertEquals(DVALRecord.class, mockListen.records.get(numRec-3).getClass()); + assertEquals(DVRecord.class, mockListen.records.get(numRec-2).getClass()); + assertEquals(EOFRecord.class, mockListen.records.get(numRec-1).getClass()); } /** |