poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r703596 [2/2] - in /poi/trunk/src: java/org/apache/poi/hssf/dev/ java/org/apache/poi/hssf/record/ testcases/org/apache/poi/hssf/eventmodel/ testcases/org/apache/poi/hssf/record/ testcases/org/apache/poi/hssf/record/constant/ testcases/org/a...
Date Fri, 10 Oct 2008 22:59:16 GMT
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java Fri Oct 10 15:59:14
2008
@@ -51,7 +51,7 @@
     };
 
     public void testLoad() {
-        ObjRecord record = new ObjRecord(new TestcaseRecordInputStream(ObjRecord.sid, (short)recdata.length,
recdata));
+        ObjRecord record = new ObjRecord(TestcaseRecordInputStream.create(ObjRecord.sid,
recdata));
 
         assertEquals(28, record.getRecordSize() - 4);
 
@@ -63,7 +63,7 @@
     }
 
     public void testStore() {
-        ObjRecord record = new ObjRecord(new TestcaseRecordInputStream(ObjRecord.sid, (short)recdata.length,
recdata));
+        ObjRecord record = new ObjRecord(TestcaseRecordInputStream.create(ObjRecord.sid,
recdata));
 
         byte [] recordBytes = record.serialize();
         assertEquals(28, recordBytes.length - 4);
@@ -91,7 +91,7 @@
         byte [] bytes = new byte[recordBytes.length-4];
         System.arraycopy(recordBytes, 4, bytes, 0, bytes.length);
 
-        record = new ObjRecord(new TestcaseRecordInputStream(ObjRecord.sid, (short)bytes.length,
bytes));
+        record = new ObjRecord(TestcaseRecordInputStream.create(ObjRecord.sid, bytes));
         List subrecords = record.getSubRecords();
         assertEquals( 2, subrecords.size() );
         assertTrue( subrecords.get(0) instanceof CommonObjectDataSubRecord);
@@ -99,7 +99,7 @@
     }
     
     public void testReadWriteWithPadding_bug45133() {
-        ObjRecord record = new ObjRecord(new TestcaseRecordInputStream(ObjRecord.sid, (short)recdataNeedingPadding.length,
recdataNeedingPadding));
+        ObjRecord record = new ObjRecord(TestcaseRecordInputStream.create(ObjRecord.sid,
recdataNeedingPadding));
         
         if (record.getRecordSize() == 34) {
         	throw new AssertionFailedError("Identified bug 45133");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjectLinkRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjectLinkRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjectLinkRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjectLinkRecord.java Fri Oct 10
15:59:14 2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        ObjectLinkRecord record = new ObjectLinkRecord(new TestcaseRecordInputStream((short)0x1027,
(short)data.length, data));
+        ObjectLinkRecord record = new ObjectLinkRecord(TestcaseRecordInputStream.create(0x1027,
data));
         
         assertEquals( (short)3, record.getAnchorId());
         assertEquals( (short)0x00, record.getLink1());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java Fri Oct 10 15:59:14
2008
@@ -37,7 +37,7 @@
     };
 
     public void testLoad() {
-        PaneRecord record = new PaneRecord(new TestcaseRecordInputStream((short)0x41, (short)data.length,
data));
+        PaneRecord record = new PaneRecord(TestcaseRecordInputStream.create(0x41, data));
 
         assertEquals( (short)1, record.getX());
         assertEquals( (short)2, record.getY());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotAreaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotAreaRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotAreaRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotAreaRecord.java Fri Oct 10
15:59:14 2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        PlotAreaRecord record = new PlotAreaRecord(new TestcaseRecordInputStream((short)0x1035,
(short)data.length, data));
+        PlotAreaRecord record = new PlotAreaRecord(TestcaseRecordInputStream.create(0x1035,
data));
 
         assertEquals( 4, record.getRecordSize() );
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotGrowthRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotGrowthRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotGrowthRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotGrowthRecord.java Fri Oct 10
15:59:14 2008
@@ -35,7 +35,7 @@
 
     public void testLoad() {
 
-        PlotGrowthRecord record = new PlotGrowthRecord(new TestcaseRecordInputStream((short)0x1064,
(short)data.length, data));
+        PlotGrowthRecord record = new PlotGrowthRecord(TestcaseRecordInputStream.create(0x1064,
data));
         assertEquals( 65536, record.getHorizontalScale());
         assertEquals( 65536, record.getVerticalScale());
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactory.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactory.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactory.java Fri Oct 10 15:59:14
2008
@@ -49,7 +49,7 @@
             0, 6, 5, 0, -2, 28, -51, 7, -55, 64, 0, 0, 6, 1, 0, 0
         };
         short    size    = 16;
-        Record[] record  = RecordFactory.createRecord(new TestcaseRecordInputStream(recType,
size, data));
+        Record[] record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType,
data));
 
         assertEquals(BOFRecord.class.getName(),
                      record[ 0 ].getClass().getName());
@@ -69,7 +69,7 @@
         {
             0, 0
         };
-        record  = RecordFactory.createRecord(new TestcaseRecordInputStream(recType, size,
data));
+        record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType, data));
         assertEquals(MMSRecord.class.getName(),
                      record[ 0 ].getClass().getName());
         MMSRecord mmsRecord = ( MMSRecord ) record[ 0 ];
@@ -94,7 +94,7 @@
             0, 0, 0, 0, 21, 0, 0, 0, 0, 0
         };
         short    size    = 10;
-        Record[] record  = RecordFactory.createRecord(new TestcaseRecordInputStream(recType,
size, data));
+        Record[] record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType,
data));
 
         assertEquals(NumberRecord.class.getName(),
                      record[ 0 ].getClass().getName());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java Fri Oct 10 15:59:14
2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        SCLRecord record = new SCLRecord(new TestcaseRecordInputStream((short)0xa0, (short)data.length,
data));
+        SCLRecord record = new SCLRecord(TestcaseRecordInputStream.create(0xa0, data));
         assertEquals( 3, record.getNumerator());
         assertEquals( 4, record.getDenominator());
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java Fri Oct 10
15:59:14 2008
@@ -32,31 +32,30 @@
  * @author Glen Stampoultzis (glens at apache.org)
  */
 public final class TestSSTDeserializer extends TestCase {
+	private static final int FAKE_SID = -5555;
 
-
-    private byte[] joinArray(byte[] array1, byte[] array2) {
-        byte[] bigArray = new byte[array1.length + array2.length];
-        System.arraycopy(array1, 0, bigArray, 0, array1.length);
-        System.arraycopy(array2, 0, bigArray, array1.length, array2.length);
-        return bigArray;
+    private static byte[] concat(byte[] a, byte[] b) {
+        byte[] result = new byte[a.length + b.length];
+        System.arraycopy(a, 0, result, 0, a.length);
+        System.arraycopy(b, 0, result, a.length, b.length);
+        return result;
     }
     
-    private static byte[] readSampleHexData(String sampleFileName, String sectionName) {
+    private static byte[] readSampleHexData(String sampleFileName, String sectionName, int
recSid) {
         InputStream is = HSSFTestDataSamples.openSampleFileStream(sampleFileName);
+        byte[] data;
         try {
-            return HexRead.readData(is, sectionName);
+			data = HexRead.readData(is, sectionName);
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
+        return TestcaseRecordInputStream.mergeDataAndSid(recSid, data.length, data);
     }
 
-    public void testSpanRichTextToPlainText()
-            throws Exception
-    {
-      byte[] header = readSampleHexData("richtextdata.txt", "header" );
-        byte[] continueBytes = readSampleHexData("richtextdata.txt", "continue1" );
-      continueBytes = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continueBytes.length,
continueBytes);
-      TestcaseRecordInputStream in = new TestcaseRecordInputStream((short)0, (short)header.length,
joinArray(header, continueBytes));
+    public void testSpanRichTextToPlainText() {
+        byte[] header = readSampleHexData("richtextdata.txt", "header", FAKE_SID);
+        byte[] continueBytes = readSampleHexData("richtextdata.txt", "continue1", ContinueRecord.sid);
+        RecordInputStream in = TestcaseRecordInputStream.create(concat(header, continueBytes));
       
 
         IntMapper strings = new IntMapper();
@@ -66,13 +65,10 @@
         assertEquals( "At a dinner party orAt At At ", strings.get( 0 ) + "" );
     }
 
-    public void testContinuationWithNoOverlap()
-            throws Exception
-    {
-        byte[] header = readSampleHexData("evencontinuation.txt", "header" );
-        byte[] continueBytes = readSampleHexData("evencontinuation.txt", "continue1" );
-        continueBytes = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continueBytes.length,
continueBytes);
-        TestcaseRecordInputStream in = new TestcaseRecordInputStream((short)0, (short)header.length,
joinArray(header, continueBytes));
+    public void testContinuationWithNoOverlap() {
+        byte[] header = readSampleHexData("evencontinuation.txt", "header", FAKE_SID);
+        byte[] continueBytes = readSampleHexData("evencontinuation.txt", "continue1", ContinueRecord.sid);
+        RecordInputStream in = TestcaseRecordInputStream.create(concat(header, continueBytes));
 
         IntMapper strings = new IntMapper();
         SSTDeserializer deserializer = new SSTDeserializer( strings );
@@ -85,18 +81,12 @@
     /**
      * Strings can actually span across more than one continuation.
      */
-    public void testStringAcross2Continuations()
-            throws Exception
-    {
-        byte[] header = readSampleHexData("stringacross2continuations.txt", "header" );
-        byte[] continue1 = readSampleHexData("stringacross2continuations.txt", "continue1"
);
-        continue1 = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continue1.length,
continue1);
-        byte[] continue2 = readSampleHexData("stringacross2continuations.txt", "continue2"
);
-        continue2 = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continue2.length,
continue2);
+    public void testStringAcross2Continuations() {
+        byte[] header = readSampleHexData("stringacross2continuations.txt", "header", FAKE_SID);
+        byte[] continue1 = readSampleHexData("stringacross2continuations.txt", "continue1",
ContinueRecord.sid);
+        byte[] continue2 = readSampleHexData("stringacross2continuations.txt", "continue2",
ContinueRecord.sid);
         
-        byte[] bytes = joinArray(header, continue1);
-        bytes = joinArray(bytes, continue2);
-        TestcaseRecordInputStream in = new TestcaseRecordInputStream((short)0, (short)header.length,
bytes);
+        RecordInputStream in = TestcaseRecordInputStream.create(concat(header, concat(continue1,
continue2)));
 
         IntMapper strings = new IntMapper();
         SSTDeserializer deserializer = new SSTDeserializer( strings );
@@ -107,10 +97,9 @@
     }
 
     public void testExtendedStrings() {
-        byte[] header = readSampleHexData("extendedtextstrings.txt", "rich-header" );
-        byte[] continueBytes = readSampleHexData("extendedtextstrings.txt", "rich-continue1"
);
-        continueBytes = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continueBytes.length,
continueBytes);
-        TestcaseRecordInputStream in = new TestcaseRecordInputStream((short)0, (short)header.length,
joinArray(header, continueBytes));
+        byte[] header = readSampleHexData("extendedtextstrings.txt", "rich-header", FAKE_SID);
+        byte[] continueBytes = readSampleHexData("extendedtextstrings.txt", "rich-continue1",
ContinueRecord.sid);
+        RecordInputStream in = TestcaseRecordInputStream.create(concat(header, continueBytes));
         
         IntMapper strings = new IntMapper();
         SSTDeserializer deserializer = new SSTDeserializer( strings );
@@ -119,10 +108,9 @@
         assertEquals( "At a dinner party orAt At At ", strings.get( 0  ) + "" );
 
 
-        header = readSampleHexData("extendedtextstrings.txt", "norich-header" );
-        continueBytes = readSampleHexData("extendedtextstrings.txt", "norich-continue1" );
-        continueBytes = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continueBytes.length,
continueBytes);
-        in = new TestcaseRecordInputStream((short)0, (short)header.length, joinArray(header,
continueBytes));
+        header = readSampleHexData("extendedtextstrings.txt", "norich-header", FAKE_SID);
+        continueBytes = readSampleHexData("extendedtextstrings.txt", "norich-continue1",
ContinueRecord.sid);
+        in = TestcaseRecordInputStream.create(concat(header, continueBytes));
         
         strings = new IntMapper();
         deserializer = new SSTDeserializer( strings );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesChartGroupIndexRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesChartGroupIndexRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesChartGroupIndexRecord.java
(original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesChartGroupIndexRecord.java
Fri Oct 10 15:59:14 2008
@@ -33,7 +33,7 @@
     };
 
     public void testLoad() {
-        SeriesChartGroupIndexRecord record = new SeriesChartGroupIndexRecord(new TestcaseRecordInputStream((short)0x1045,
(short)data.length, data));
+        SeriesChartGroupIndexRecord record = new SeriesChartGroupIndexRecord(TestcaseRecordInputStream.create(0x1045,
data));
         assertEquals( 0, record.getChartGroupIndex());
 
         assertEquals( 6, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesIndexRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesIndexRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesIndexRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesIndexRecord.java Fri Oct
10 15:59:14 2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        SeriesIndexRecord record = new SeriesIndexRecord(new TestcaseRecordInputStream((short)0x1065,
(short)data.length, data));
+        SeriesIndexRecord record = new SeriesIndexRecord(TestcaseRecordInputStream.create(0x1065,
data));
         
         assertEquals( (short)3, record.getIndex());
         assertEquals( 6, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesLabelsRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesLabelsRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesLabelsRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesLabelsRecord.java Fri Oct
10 15:59:14 2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        SeriesLabelsRecord record = new SeriesLabelsRecord(new TestcaseRecordInputStream((short)0x100c,
(short)data.length, data));
+        SeriesLabelsRecord record = new SeriesLabelsRecord(TestcaseRecordInputStream.create(0x100c,
data));
         assertEquals( 3, record.getFormatFlags());
         assertEquals( true, record.isShowActual() );
         assertEquals( true, record.isShowPercent() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesListRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesListRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesListRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesListRecord.java Fri Oct 10
15:59:14 2008
@@ -35,7 +35,7 @@
 
     public void testLoad() {
 
-        SeriesListRecord record = new SeriesListRecord(new TestcaseRecordInputStream((short)0x1016,
(short)data.length, data));
+        SeriesListRecord record = new SeriesListRecord(TestcaseRecordInputStream.create(0x1016,
data));
         assertEquals( (short)0x2001, record.getSeriesNumbers()[0]);
         assertEquals( (short)0xf0ff, record.getSeriesNumbers()[1]);
         assertEquals( 2, record.getSeriesNumbers().length);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java Fri Oct 10 15:59:14
2008
@@ -39,7 +39,7 @@
 
     public void testLoad() {
 
-        SeriesRecord record = new SeriesRecord(new TestcaseRecordInputStream((short)0x1003,
(short)data.length, data));
+        SeriesRecord record = new SeriesRecord(TestcaseRecordInputStream.create(0x1003, data));
         assertEquals( SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC, record.getCategoryDataType());
         assertEquals( SeriesRecord.VALUES_DATA_TYPE_NUMERIC, record.getValuesDataType());
         assertEquals( 27, record.getNumCategories());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesTextRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesTextRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesTextRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesTextRecord.java Fri Oct 10
15:59:14 2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        SeriesTextRecord record = new SeriesTextRecord(new TestcaseRecordInputStream((short)0x100d,
(short)data.length, data));
+        SeriesTextRecord record = new SeriesTextRecord(TestcaseRecordInputStream.create(0x100d,
data));
 
         assertEquals( (short)0, record.getId());
         assertEquals( (byte)0x0C, record.getTextLength());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesToChartGroupRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesToChartGroupRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesToChartGroupRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesToChartGroupRecord.java Fri
Oct 10 15:59:14 2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        SeriesToChartGroupRecord record = new SeriesToChartGroupRecord(new TestcaseRecordInputStream((short)0x1045,
(short)data.length, data));
+        SeriesToChartGroupRecord record = new SeriesToChartGroupRecord(TestcaseRecordInputStream.create(0x1045,
data));
         assertEquals( 0x0, record.getChartGroupIndex());
 
         assertEquals( 0x6, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java Fri Oct
10 15:59:14 2008
@@ -59,7 +59,7 @@
 	 */
 	public void testConvertSharedFormulasOperandClasses_bug45123() {
 		
-		TestcaseRecordInputStream in = new TestcaseRecordInputStream(0, SHARED_FORMULA_WITH_REF_ARRAYS_DATA);
+		RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(SHARED_FORMULA_WITH_REF_ARRAYS_DATA);
 		int encodedLen = in.readUShort();
 		Ptg[] sharedFormula = Ptg.readTokens(encodedLen, in);
 		

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSheetPropertiesRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSheetPropertiesRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSheetPropertiesRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSheetPropertiesRecord.java Fri
Oct 10 15:59:14 2008
@@ -36,7 +36,7 @@
     };
 
     public void testLoad() {
-        SheetPropertiesRecord record = new SheetPropertiesRecord(new TestcaseRecordInputStream((short)0x1044,
(short)data.length, data));
+        SheetPropertiesRecord record = new SheetPropertiesRecord(TestcaseRecordInputStream.create(0x1044,
data));
         assertEquals( 10, record.getFlags());
         assertEquals( false, record.isChartTypeManuallyFormatted() );
         assertEquals( true, record.isPlotVisibleOnly() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java Fri Oct 10 15:59:14
2008
@@ -27,7 +27,7 @@
  *
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class TestStringRecord extends TestCase {
+public final class TestStringRecord extends TestCase {
     byte[] data = new byte[] {
         (byte)0x0B,(byte)0x00,   // length
         (byte)0x00,              // option
@@ -37,7 +37,7 @@
 
     public void testLoad() {
 
-        StringRecord record = new StringRecord(new TestcaseRecordInputStream((short)0x207,
(short)data.length, data));
+        StringRecord record = new StringRecord(TestcaseRecordInputStream.create(0x207, data));
         assertEquals( "Fahrzeugtyp", record.getString());
 
         assertEquals( 18, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java Fri Oct 10 15:59:14
2008
@@ -51,7 +51,7 @@
      */
     public void testLoadIR() {
 
-        SupBookRecord record = new SupBookRecord(new TestcaseRecordInputStream((short)0x01AE,
dataIR));      
+        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE,
dataIR));      
         assertTrue( record.isInternalReferences() );             //expected flag
         assertEquals( 0x4, record.getNumberOfSheets() );    //expected # of sheets
 
@@ -62,7 +62,7 @@
      */
     public void testLoadER() {
 
-        SupBookRecord record = new SupBookRecord(new TestcaseRecordInputStream((short)0x01AE,
dataER));      
+        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE,
dataER));      
         assertTrue( record.isExternalReferences() );             //expected flag
         assertEquals( 0x2, record.getNumberOfSheets() );    //expected # of sheets
 
@@ -80,7 +80,7 @@
      */
     public void testLoadAIF() {
 
-        SupBookRecord record = new SupBookRecord(new TestcaseRecordInputStream((short)0x01AE,
dataAIF));      
+        SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE,
dataAIF));      
         assertTrue( record.isAddInFunctions() );             //expected flag
         assertEquals( 0x1, record.getNumberOfSheets() );    //expected # of sheets
         assertEquals( 8, record.getRecordSize() );  //sid+size+data

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java Fri Oct 10 15:59:14
2008
@@ -44,7 +44,7 @@
 
 	public void testLoad() {
 
-		TableRecord record = new TableRecord(new TestcaseRecordInputStream((short)0x236, (short)data.length,
data));
+		TableRecord record = new TableRecord(TestcaseRecordInputStream.create(0x236, data));
 
 		CellRangeAddress8Bit range = record.getRange();
 		assertEquals(3, range.getFirstRow());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextRecord.java Fri Oct 10 15:59:14
2008
@@ -27,7 +27,7 @@
  *
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class TestTextRecord extends TestCase {
+public final class TestTextRecord extends TestCase {
     byte[] data = new byte[] {
         (byte)0x02,                                          // horiz align
         (byte)0x02,                                          // vert align
@@ -45,7 +45,7 @@
 
     public void testLoad() {
 
-        TextRecord record = new TextRecord(new TestcaseRecordInputStream((short)0x1025, (short)data.length,
data));
+        TextRecord record = new TextRecord(TestcaseRecordInputStream.create(0x1025, data));
         assertEquals( TextRecord.HORIZONTAL_ALIGNMENT_CENTER, record.getHorizontalAlignment());
         assertEquals( TextRecord.VERTICAL_ALIGNMENT_CENTER, record.getVerticalAlignment());
         assertEquals( TextRecord.DISPLAY_MODE_TRANSPARENT, record.getDisplayMode());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTickRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTickRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTickRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTickRecord.java Fri Oct 10 15:59:14
2008
@@ -40,7 +40,7 @@
     };
 
     public void testLoad() {
-        TickRecord record = new TickRecord(new TestcaseRecordInputStream((short)0x101e, (short)data.length,
data));
+        TickRecord record = new TickRecord(TestcaseRecordInputStream.create(0x101e, data));
         assertEquals( (byte)2, record.getMajorTickType());
         assertEquals( (byte)0, record.getMinorTickType());
         assertEquals( (byte)3, record.getLabelPosition());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnitsRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnitsRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnitsRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnitsRecord.java Fri Oct 10 15:59:14
2008
@@ -35,7 +35,7 @@
 
     public void testLoad() {
 
-        UnitsRecord record = new UnitsRecord(new TestcaseRecordInputStream((short)0x1001,
(short)data.length, data));
+        UnitsRecord record = new UnitsRecord(TestcaseRecordInputStream.create(0x1001, data));
         assertEquals( 0, record.getUnits());
 
         assertEquals( 6, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java Fri Oct 10
15:59:14 2008
@@ -40,7 +40,7 @@
 
     public void testLoad() {
 
-        ValueRangeRecord record = new ValueRangeRecord(new TestcaseRecordInputStream((short)0x101f,
(short)data.length, data));
+        ValueRangeRecord record = new ValueRangeRecord(TestcaseRecordInputStream.create(0x101f,
data));
         assertEquals( 0.0, record.getMinimumAxisValue(), 0.001);
         assertEquals( 0.0, record.getMaximumAxisValue(), 0.001);
         assertEquals( 0.0, record.getMajorIncrement(), 0.001);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java Fri
Oct 10 15:59:14 2008
@@ -18,6 +18,7 @@
 package org.apache.poi.hssf.record;
 
 import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 
 import junit.framework.Assert;
 
@@ -30,27 +31,51 @@
  *
  * @author Jason Height (jheight at apache.org)
  */
-public class TestcaseRecordInputStream
-        extends RecordInputStream
-{
+public final class TestcaseRecordInputStream {
+	
+	private TestcaseRecordInputStream() {
+		// no instances of this class
+	}
+	
+	/**
+	 * Prepends a mock record identifier to the supplied data and opens a record input stream

+	 */
+	public static RecordInputStream createWithFakeSid(byte[] data) {
+		return create(-5555, data);
+		
+	}
+	public static RecordInputStream create(int sid, byte[] data) {
+		return create(mergeDataAndSid(sid, data.length, data));
+	}
+	/**
+	 * First 4 bytes of <tt>data</tt> are assumed to be record identifier and length.
The supplied 
+	 * <tt>data</tt> can contain multiple records (sequentially encoded in the same
way) 
+	 */
+	public static RecordInputStream create(byte[] data) {
+		InputStream is = new ByteArrayInputStream(data);
+		RecordInputStream result = new RecordInputStream(is);
+		result.nextRecord();
+		return result;
+	}
+	
     /**
      * Convenience constructor
      */
-    public TestcaseRecordInputStream(int sid, byte[] data)
-    {
-      super(new ByteArrayInputStream(mergeDataAndSid((short)sid, (short)data.length, data)));
-      nextRecord();
-    }
-    public TestcaseRecordInputStream(short sid, short length, byte[] data)
-    {
-      super(new ByteArrayInputStream(mergeDataAndSid(sid, length, data)));
-      nextRecord();
-    }
+//    public TestcaseRecordInputStream(int sid, byte[] data)
+//    {
+//      super(new ByteArrayInputStream(mergeDataAndSid(sid, data.length, data)));
+//      nextRecord();
+//    }
+//    public TestcaseRecordInputStream(short sid, short length, byte[] data)
+//    {
+//      super(new ByteArrayInputStream(mergeDataAndSid(sid, length, data)));
+//      nextRecord();
+//    }
 
-    public static byte[] mergeDataAndSid(short sid, short length, byte[] data) {
+    public static byte[] mergeDataAndSid(int sid, int length, byte[] data) {
       byte[] result = new byte[data.length + 4];
-      LittleEndian.putShort(result, 0, sid);
-      LittleEndian.putShort(result, 2, length);
+      LittleEndian.putUShort(result, 0, sid);
+      LittleEndian.putUShort(result, 2, length);
       System.arraycopy(data, 0, result, 4, data.length);
       return result;
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java
(original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java
Fri Oct 10 15:59:14 2008
@@ -25,6 +25,7 @@
 import org.apache.poi.hssf.record.TestcaseRecordInputStream;
 import org.apache.poi.hssf.record.UnicodeString;
 import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.util.HexRead;
 /**
  * 
  * @author Josh Micich
@@ -37,13 +38,12 @@
 			new UnicodeString("Sample text"),
 			ErrorConstant.valueOf(HSSFErrorConstants.ERROR_DIV_0),
 		};
-	private static final byte[] SAMPLE_ENCODING = {
-		4, 1, 0, 0, 0, 0, 0, 0, 0, 
-		0, 0, 0, 0, 0, 0, 0, 0, 0,
-		1, -102, -103, -103, -103, -103, -103, -15, 63, 
-		2, 11, 0, 0, 83, 97, 109, 112, 108, 101, 32, 116, 101, 120, 116,
-		16, 7, 0, 0, 0, 0, 0, 0, 0,		
-	};
+	private static final byte[] SAMPLE_ENCODING = HexRead.readFromString(
+		"04 01 00 00 00 00 00 00 00 " +
+		"00 00 00 00 00 00 00 00 00 " +
+		"01 9A 99 99 99 99 99 F1 3F " +
+		"02 0B 00 00 53 61 6D 70 6C 65 20 74 65 78 74 " +
+		"10 07 00 00 00 00 00 00 00");
 	
 	public void testGetEncodedSize() {
 		int actual = ConstantValueParser.getEncodedSize(SAMPLE_VALUES);
@@ -59,7 +59,7 @@
 		}
 	}
 	public void testDecode() {
-		RecordInputStream in = new TestcaseRecordInputStream(0x0001, SAMPLE_ENCODING);
+		RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(SAMPLE_ENCODING);
 		
 		Object[] values = ConstantValueParser.parse(in, 4);
 		for (int i = 0; i < values.length; i++) {

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java Fri Oct 10
15:59:14 2008
@@ -54,9 +54,9 @@
 	 */
 	public void testReadWriteTokenValueBytes() {
 		
-		ArrayPtg ptg = new ArrayPtg(new TestcaseRecordInputStream(ArrayPtg.sid, ENCODED_PTG_DATA));
+		ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createWithFakeSid(ENCODED_PTG_DATA));
 		
-		ptg.readTokenValues(new TestcaseRecordInputStream(0, ENCODED_CONSTANT_DATA));
+		ptg.readTokenValues(TestcaseRecordInputStream.createWithFakeSid(ENCODED_CONSTANT_DATA));
 		assertEquals(3, ptg.getColumnCount());
 		assertEquals(2, ptg.getRowCount());
 		Object[][] values = ptg.getTokenArrayValues();
@@ -82,8 +82,8 @@
 	 * Excel stores array elements column by column.  This test makes sure POI does the same.
 	 */
 	public void testElementOrdering() {
-		ArrayPtg ptg = new ArrayPtg(new TestcaseRecordInputStream(ArrayPtg.sid, ENCODED_PTG_DATA));
-		ptg.readTokenValues(new TestcaseRecordInputStream(0, ENCODED_CONSTANT_DATA));
+		ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createWithFakeSid(ENCODED_PTG_DATA));
+		ptg.readTokenValues(TestcaseRecordInputStream.createWithFakeSid(ENCODED_CONSTANT_DATA));
 		assertEquals(3, ptg.getColumnCount());
 		assertEquals(2, ptg.getRowCount());
 		
@@ -113,9 +113,9 @@
 	}
 
 	public void testToFormulaString() {
-		ArrayPtg ptg = new ArrayPtg(new TestcaseRecordInputStream(ArrayPtg.sid, ENCODED_PTG_DATA));
+		ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createWithFakeSid(ENCODED_PTG_DATA));
 		
-		ptg.readTokenValues(new TestcaseRecordInputStream(0, ENCODED_CONSTANT_DATA));
+		ptg.readTokenValues(TestcaseRecordInputStream.createWithFakeSid(ENCODED_CONSTANT_DATA));
 		
 		String actualFormula;
 		try {
@@ -146,7 +146,7 @@
 		// Force encoded operand class for tArray 
 		fullData[0] = (byte) (ArrayPtg.sid + operandClass);
 		
-		RecordInputStream in = new TestcaseRecordInputStream(ArrayPtg.sid, fullData);
+		RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(fullData);
 		
 		Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
 		assertEquals(1, ptgs.length);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java Fri Oct 10
15:59:14 2008
@@ -34,7 +34,7 @@
             0,
         };
 
-        FuncPtg ptg = new FuncPtg( new TestcaseRecordInputStream((short)0, (short)fakeData.length,
fakeData) );
+        FuncPtg ptg = new FuncPtg(TestcaseRecordInputStream.createWithFakeSid(fakeData) );
         assertEquals( "Len formula index is not 32(20H)", 0x20, ptg.getFunctionIndex() );
         assertEquals( "Number of operands in the len formula", 1, ptg.getNumberOfOperands()
);
         assertEquals( "Function Name", "LEN", ptg.getName() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java Fri Oct
10 15:59:14 2008
@@ -23,6 +23,7 @@
 import junit.framework.TestCase;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.record.RecordInputStream;
 import org.apache.poi.hssf.record.TestcaseRecordInputStream;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -93,7 +94,7 @@
     	0x2C, 33, 44, 55, 66,
     };
     public void testReadWrite_tRefN_bug45091() {
-        TestcaseRecordInputStream in = new TestcaseRecordInputStream(-1, tRefN_data);
+        RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(tRefN_data);
         Ptg[] ptgs = Ptg.readTokens(tRefN_data.length, in);
         byte[] outData = new byte[5];
         Ptg.serializePtgs(ptgs, outData, 0);



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


Mime
View raw message