You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 20:56:49 UTC

svn commit: r1890120 [31/43] - in /poi/trunk/poi/src: main/java/org/apache/poi/ main/java/org/apache/poi/ddf/ main/java/org/apache/poi/extractor/ main/java/org/apache/poi/hpsf/ main/java/org/apache/poi/hssf/ main/java/org/apache/poi/hssf/dev/ main/java...

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordFactory.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordFactory.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordFactory.java Sat May 22 20:56:44 2021
@@ -6,7 +6,7 @@
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
 
-	   http://www.apache.org/licenses/LICENSE-2.0
+       http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
@@ -37,198 +37,198 @@ import org.junit.jupiter.api.Test;
 final class TestRecordFactory {
 
 
-	/**
-	 * TEST NAME:  Test Basic Record Construction <P>
-	 * OBJECTIVE:  Test that the RecordFactory given the required parameters for know
-	 *             record types can construct the proper record w/values.<P>
-	 * SUCCESS:	Record factory creates the records with the expected values.<P>
-	 * FAILURE:	The wrong records are creates or contain the wrong values <P>
-	 *
-	 */
+    /**
+     * TEST NAME:  Test Basic Record Construction <P>
+     * OBJECTIVE:  Test that the RecordFactory given the required parameters for know
+     *             record types can construct the proper record w/values.<P>
+     * SUCCESS: Record factory creates the records with the expected values.<P>
+     * FAILURE: The wrong records are creates or contain the wrong values <P>
+     *
+     */
     @Test
-	void testBasicRecordConstruction() {
-		short recType = BOFRecord.sid;
-		byte[]   data	= {
-			0, 6, 5, 0, -2, 28, -51, 7, -55, 64, 0, 0, 6, 1, 0, 0
-		};
-		Record[] record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType, data));
-
-		assertEquals(BOFRecord.class.getName(),
-					 record[ 0 ].getClass().getName());
-		BOFRecord bofRecord = ( BOFRecord ) record[ 0 ];
-
-		assertEquals(7422, bofRecord.getBuild());
-		assertEquals(1997, bofRecord.getBuildYear());
-		assertEquals(16585, bofRecord.getHistoryBitMask());
-		assertEquals(20, bofRecord.getRecordSize());
-		assertEquals(262, bofRecord.getRequiredVersion());
-		assertEquals(2057, bofRecord.getSid());
-		assertEquals(5, bofRecord.getType());
-		assertEquals(1536, bofRecord.getVersion());
-		recType = MMSRecord.sid;
-		data = new byte[] {
-			0, 0
-		};
-		record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType, data));
-		assertEquals(MMSRecord.class.getName(),
-					 record[ 0 ].getClass().getName());
-		MMSRecord mmsRecord = ( MMSRecord ) record[ 0 ];
-
-		assertEquals(0, mmsRecord.getAddMenuCount());
-		assertEquals(0, mmsRecord.getDelMenuCount());
-		assertEquals(6, mmsRecord.getRecordSize());
-		assertEquals(193, mmsRecord.getSid());
-	}
-
-	/**
-	 * TEST NAME:  Test Special Record Construction <P>
-	 * OBJECTIVE:  Test that the RecordFactory given the required parameters for
-	 *			 constructing a RKRecord will return a NumberRecord.<P>
-	 * SUCCESS:	Record factory creates the Number record with the expected values.<P>
-	 * FAILURE:	The wrong records are created or contain the wrong values <P>
-	 *
-	 */
+    void testBasicRecordConstruction() {
+        short recType = BOFRecord.sid;
+        byte[]   data   = {
+            0, 6, 5, 0, -2, 28, -51, 7, -55, 64, 0, 0, 6, 1, 0, 0
+        };
+        Record[] record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType, data));
+
+        assertEquals(BOFRecord.class.getName(),
+                     record[ 0 ].getClass().getName());
+        BOFRecord bofRecord = ( BOFRecord ) record[ 0 ];
+
+        assertEquals(7422, bofRecord.getBuild());
+        assertEquals(1997, bofRecord.getBuildYear());
+        assertEquals(16585, bofRecord.getHistoryBitMask());
+        assertEquals(20, bofRecord.getRecordSize());
+        assertEquals(262, bofRecord.getRequiredVersion());
+        assertEquals(2057, bofRecord.getSid());
+        assertEquals(5, bofRecord.getType());
+        assertEquals(1536, bofRecord.getVersion());
+        recType = MMSRecord.sid;
+        data = new byte[] {
+            0, 0
+        };
+        record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType, data));
+        assertEquals(MMSRecord.class.getName(),
+                     record[ 0 ].getClass().getName());
+        MMSRecord mmsRecord = ( MMSRecord ) record[ 0 ];
+
+        assertEquals(0, mmsRecord.getAddMenuCount());
+        assertEquals(0, mmsRecord.getDelMenuCount());
+        assertEquals(6, mmsRecord.getRecordSize());
+        assertEquals(193, mmsRecord.getSid());
+    }
+
+    /**
+     * TEST NAME:  Test Special Record Construction <P>
+     * OBJECTIVE:  Test that the RecordFactory given the required parameters for
+     *           constructing a RKRecord will return a NumberRecord.<P>
+     * SUCCESS: Record factory creates the Number record with the expected values.<P>
+     * FAILURE: The wrong records are created or contain the wrong values <P>
+     *
+     */
     @Test
     void testSpecial() {
-		short recType = RKRecord.sid;
-		byte[] data = {
-			0, 0, 0, 0, 21, 0, 0, 0, 0, 0
-		};
-		Record[] record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType, data));
-
-		assertEquals(NumberRecord.class.getName(),
-					 record[ 0 ].getClass().getName());
-		NumberRecord numberRecord = ( NumberRecord ) record[ 0 ];
-
-		assertEquals(0, numberRecord.getColumn());
-		assertEquals(18, numberRecord.getRecordSize());
-		assertEquals(0, numberRecord.getRow());
-		assertEquals(515, numberRecord.getSid());
-		assertEquals(0.0, numberRecord.getValue(), 0.001);
-		assertEquals(21, numberRecord.getXFIndex());
-	}
-
-	/**
-	 * TEST NAME:  Test Creating ContinueRecords After Unknown Records From An InputStream <P>
-	 * OBJECTIVE:  Test that the RecordFactory given an InputStream
-	 *             constructs the expected array of records.<P>
-	 * SUCCESS:	Record factory creates the expected records.<P>
-	 * FAILURE:	The wrong records are created or contain the wrong values <P>
-	 */
+        short recType = RKRecord.sid;
+        byte[] data = {
+            0, 0, 0, 0, 21, 0, 0, 0, 0, 0
+        };
+        Record[] record  = RecordFactory.createRecord(TestcaseRecordInputStream.create(recType, data));
+
+        assertEquals(NumberRecord.class.getName(),
+                     record[ 0 ].getClass().getName());
+        NumberRecord numberRecord = ( NumberRecord ) record[ 0 ];
+
+        assertEquals(0, numberRecord.getColumn());
+        assertEquals(18, numberRecord.getRecordSize());
+        assertEquals(0, numberRecord.getRow());
+        assertEquals(515, numberRecord.getSid());
+        assertEquals(0.0, numberRecord.getValue(), 0.001);
+        assertEquals(21, numberRecord.getXFIndex());
+    }
+
+    /**
+     * TEST NAME:  Test Creating ContinueRecords After Unknown Records From An InputStream <P>
+     * OBJECTIVE:  Test that the RecordFactory given an InputStream
+     *             constructs the expected array of records.<P>
+     * SUCCESS: Record factory creates the expected records.<P>
+     * FAILURE: The wrong records are created or contain the wrong values <P>
+     */
     @Test
-	void testContinuedUnknownRecord() {
-		byte[] data = {
-			0, -1, 0, 0, // an unknown record with 0 length
-			0x3C , 0, 3, 0, 1, 2, 3, // a continuation record with 3 bytes of data
-			0x3C , 0, 1, 0, 4 // one more continuation record with 1 byte of data
-		};
-
-		ByteArrayInputStream bois = new ByteArrayInputStream(data);
-		Record[] records = RecordFactory.createRecords(bois).toArray(new Record[0]);
-		assertEquals(3, records.length, "Created record count");
-		assertEquals(UnknownRecord.class.getName(), records[ 0 ].getClass().getName(), "1st record's type");
-		assertEquals((short)-256, records[0].getSid(), "1st record's sid");
-		assertEquals(ContinueRecord.class.getName(), records[ 1 ].getClass().getName(), "2nd record's type");
-		ContinueRecord record = (ContinueRecord) records[1];
-		assertEquals(0x3C, record.getSid(), "2nd record's sid");
-		assertEquals(1, record.getData()[ 0 ], "1st data byte");
-		assertEquals(2, record.getData()[ 1 ], "2nd data byte");
-		assertEquals(3, record.getData()[ 2 ], "3rd data byte");
-		assertEquals(ContinueRecord.class.getName(), records[ 2 ].getClass().getName(), "3rd record's type");
-		record = (ContinueRecord) records[2];
-		assertEquals(0x3C, record.getSid(), "3nd record's sid");
-		assertEquals(4, record.getData()[ 0 ], "4th data byte");
-	}
-
-	/**
-	 * Drawing records have a very strange continue behaviour.
-	 * There can actually be OBJ records mixed between the continues.
-	 * Record factory must preserve this structure when reading records.
-	 */
+    void testContinuedUnknownRecord() {
+        byte[] data = {
+            0, -1, 0, 0, // an unknown record with 0 length
+            0x3C , 0, 3, 0, 1, 2, 3, // a continuation record with 3 bytes of data
+            0x3C , 0, 1, 0, 4 // one more continuation record with 1 byte of data
+        };
+
+        ByteArrayInputStream bois = new ByteArrayInputStream(data);
+        Record[] records = RecordFactory.createRecords(bois).toArray(new Record[0]);
+        assertEquals(3, records.length, "Created record count");
+        assertEquals(UnknownRecord.class.getName(), records[ 0 ].getClass().getName(), "1st record's type");
+        assertEquals((short)-256, records[0].getSid(), "1st record's sid");
+        assertEquals(ContinueRecord.class.getName(), records[ 1 ].getClass().getName(), "2nd record's type");
+        ContinueRecord record = (ContinueRecord) records[1];
+        assertEquals(0x3C, record.getSid(), "2nd record's sid");
+        assertEquals(1, record.getData()[ 0 ], "1st data byte");
+        assertEquals(2, record.getData()[ 1 ], "2nd data byte");
+        assertEquals(3, record.getData()[ 2 ], "3rd data byte");
+        assertEquals(ContinueRecord.class.getName(), records[ 2 ].getClass().getName(), "3rd record's type");
+        record = (ContinueRecord) records[2];
+        assertEquals(0x3C, record.getSid(), "3nd record's sid");
+        assertEquals(4, record.getData()[ 0 ], "4th data byte");
+    }
+
+    /**
+     * Drawing records have a very strange continue behaviour.
+     * There can actually be OBJ records mixed between the continues.
+     * Record factory must preserve this structure when reading records.
+     */
     @Test
-	void testMixedContinue() throws IOException {
-		// Adapted from a real test sample file 39512.xls (Offset 0x4854).
-		// See Bug 39512 for details.
-		String dump =
-				//OBJ
-				"5D 00 48 00 15 00 12 00 0C 00 3C 00 11 00 A0 2E 03 01 CC 42 " +
-				"CF 00 00 00 00 00 0A 00 0C 00 00 00 00 00 00 00 00 00 00 00 " +
-				"03 00 0B 00 06 00 28 01 03 01 00 00 12 00 08 00 00 00 00 00 " +
-				"00 00 03 00 11 00 04 00 3D 00 00 00 00 00 00 00 " +
-				 //MSODRAWING
-				"EC 00 08 00 00 00 0D F0 00 00 00 00 " +
-				//TXO (and 2 trailing CONTINUE records)
-				"B6 01 12 00 22 02 00 00 00 00 00 00 00 00 10 00 10 00 00 00 00 00 " +
-				"3C 00 11 00 00 4F 70 74 69 6F 6E 20 42 75 74 74 6F 6E 20 33 39 " +
-				"3C 00 10 00 00 00 05 00 00 00 00 00 10 00 00 00 00 00 00 00 " +
-				// another CONTINUE
-				"3C 00 7E 00 0F 00 04 F0 7E 00 00 00 92 0C 0A F0 08 00 00 00 " +
-				"3D 04 00 00 00 0A 00 00 A3 00 0B F0 3C 00 00 00 7F 00 00 01 " +
-				"00 01 80 00 8C 01 03 01 85 00 01 00 00 00 8B 00 02 00 00 00 " +
-				"BF 00 08 00 1A 00 7F 01 29 00 29 00 81 01 41 00 00 08 BF 01 " +
-				"00 00 10 00 C0 01 40 00 00 08 FF 01 00 00 08 00 00 00 10 F0 " +
-				"12 00 00 00 02 00 02 00 A0 03 18 00 B5 00 04 00 30 02 1A 00 " +
-				"00 00 00 00 11 F0 00 00 00 00 " +
-				//OBJ
-				"5D 00 48 00 15 00 12 00 0C 00 3D 00 11 00 8C 01 03 01 C8 59 CF 00 00 " +
-				"00 00 00 0A 00 0C 00 00 00 00 00 00 00 00 00 00 00 03 00 0B 00 06 00 " +
-				"7C 16 03 01 00 00 12 00 08 00 00 00 00 00 00 00 03 00 11 00 04 00 01 " +
-				"00 00 00 00 00 00 00";
-		byte[] data = HexRead.readFromString(dump);
-
-		List<org.apache.poi.hssf.record.Record> records = RecordFactory.createRecords(new ByteArrayInputStream(data));
-		assertEquals(5, records.size());
-		assertTrue(records.get(0) instanceof ObjRecord);
-		assertTrue(records.get(1) instanceof DrawingRecord);
-		assertTrue(records.get(2) instanceof TextObjectRecord);
-		assertTrue(records.get(3) instanceof ContinueRecord);
-		assertTrue(records.get(4) instanceof ObjRecord);
-
-		//serialize and verify that the serialized data is the same as the original
-		UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
-		for(org.apache.poi.hssf.record.Record rec : records){
-			out.write(rec.serialize());
-		}
-
-		byte[] ser = out.toByteArray();
-		assertEquals(data.length, ser.length);
-		assertArrayEquals(data, ser);
-	}
+    void testMixedContinue() throws IOException {
+        // Adapted from a real test sample file 39512.xls (Offset 0x4854).
+        // See Bug 39512 for details.
+        String dump =
+                //OBJ
+                "5D 00 48 00 15 00 12 00 0C 00 3C 00 11 00 A0 2E 03 01 CC 42 " +
+                "CF 00 00 00 00 00 0A 00 0C 00 00 00 00 00 00 00 00 00 00 00 " +
+                "03 00 0B 00 06 00 28 01 03 01 00 00 12 00 08 00 00 00 00 00 " +
+                "00 00 03 00 11 00 04 00 3D 00 00 00 00 00 00 00 " +
+                 //MSODRAWING
+                "EC 00 08 00 00 00 0D F0 00 00 00 00 " +
+                //TXO (and 2 trailing CONTINUE records)
+                "B6 01 12 00 22 02 00 00 00 00 00 00 00 00 10 00 10 00 00 00 00 00 " +
+                "3C 00 11 00 00 4F 70 74 69 6F 6E 20 42 75 74 74 6F 6E 20 33 39 " +
+                "3C 00 10 00 00 00 05 00 00 00 00 00 10 00 00 00 00 00 00 00 " +
+                // another CONTINUE
+                "3C 00 7E 00 0F 00 04 F0 7E 00 00 00 92 0C 0A F0 08 00 00 00 " +
+                "3D 04 00 00 00 0A 00 00 A3 00 0B F0 3C 00 00 00 7F 00 00 01 " +
+                "00 01 80 00 8C 01 03 01 85 00 01 00 00 00 8B 00 02 00 00 00 " +
+                "BF 00 08 00 1A 00 7F 01 29 00 29 00 81 01 41 00 00 08 BF 01 " +
+                "00 00 10 00 C0 01 40 00 00 08 FF 01 00 00 08 00 00 00 10 F0 " +
+                "12 00 00 00 02 00 02 00 A0 03 18 00 B5 00 04 00 30 02 1A 00 " +
+                "00 00 00 00 11 F0 00 00 00 00 " +
+                //OBJ
+                "5D 00 48 00 15 00 12 00 0C 00 3D 00 11 00 8C 01 03 01 C8 59 CF 00 00 " +
+                "00 00 00 0A 00 0C 00 00 00 00 00 00 00 00 00 00 00 03 00 0B 00 06 00 " +
+                "7C 16 03 01 00 00 12 00 08 00 00 00 00 00 00 00 03 00 11 00 04 00 01 " +
+                "00 00 00 00 00 00 00";
+        byte[] data = HexRead.readFromString(dump);
+
+        List<org.apache.poi.hssf.record.Record> records = RecordFactory.createRecords(new ByteArrayInputStream(data));
+        assertEquals(5, records.size());
+        assertTrue(records.get(0) instanceof ObjRecord);
+        assertTrue(records.get(1) instanceof DrawingRecord);
+        assertTrue(records.get(2) instanceof TextObjectRecord);
+        assertTrue(records.get(3) instanceof ContinueRecord);
+        assertTrue(records.get(4) instanceof ObjRecord);
+
+        //serialize and verify that the serialized data is the same as the original
+        UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
+        for(org.apache.poi.hssf.record.Record rec : records){
+            out.write(rec.serialize());
+        }
+
+        byte[] ser = out.toByteArray();
+        assertEquals(data.length, ser.length);
+        assertArrayEquals(data, ser);
+    }
 
     @Test
-	void testNonZeroPadding_bug46987() throws IOException {
-		Record[] recs = {
-			new BOFRecord(),
-			new WriteAccessRecord(), // need *something* between BOF and EOF
-			EOFRecord.instance,
-			BOFRecord.createSheetBOF(),
-			EOFRecord.instance,
-		};
-		UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
-		for (org.apache.poi.hssf.record.Record rec : recs) {
-			try {
-				baos.write(rec.serialize());
-			} catch (IOException e) {
-				throw new RuntimeException(e);
-			}
-		}
-		//simulate the bad padding at the end of the workbook stream in attachment 23483 of bug 46987
-		baos.write(0x00);
-		baos.write(0x11);
-		baos.write(0x00);
-		baos.write(0x02);
-		for (int i = 0; i < 192; i++) {
-			baos.write(0x00);
-		}
-
-
-		try (POIFSFileSystem fs = new POIFSFileSystem()) {
-			fs.createDocument(baos.toInputStream(), "dummy");
-			InputStream is = fs.getRoot().createDocumentInputStream("dummy");
-
-			List<org.apache.poi.hssf.record.Record> outRecs = RecordFactory.createRecords(is);
-			// Buffer underrun - requested 512 bytes but 192 was available
-			assertEquals(5, outRecs.size());
-		}
-	}
+    void testNonZeroPadding_bug46987() throws IOException {
+        Record[] recs = {
+            new BOFRecord(),
+            new WriteAccessRecord(), // need *something* between BOF and EOF
+            EOFRecord.instance,
+            BOFRecord.createSheetBOF(),
+            EOFRecord.instance,
+        };
+        UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
+        for (org.apache.poi.hssf.record.Record rec : recs) {
+            try {
+                baos.write(rec.serialize());
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        //simulate the bad padding at the end of the workbook stream in attachment 23483 of bug 46987
+        baos.write(0x00);
+        baos.write(0x11);
+        baos.write(0x00);
+        baos.write(0x02);
+        for (int i = 0; i < 192; i++) {
+            baos.write(0x00);
+        }
+
+
+        try (POIFSFileSystem fs = new POIFSFileSystem()) {
+            fs.createDocument(baos.toInputStream(), "dummy");
+            InputStream is = fs.getRoot().createDocumentInputStream("dummy");
+
+            List<org.apache.poi.hssf.record.Record> outRecs = RecordFactory.createRecords(is);
+            // Buffer underrun - requested 512 bytes but 192 was available
+            assertEquals(5, outRecs.size());
+        }
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java Sat May 22 20:56:44 2021
@@ -33,49 +33,49 @@ import org.junit.jupiter.api.Test;
  * Tests for {@link RecordFactoryInputStream}
  */
 final class TestRecordFactoryInputStream {
-	/**
-	 * Hex dump of a BOF record and most of a FILEPASS record.
-	 * A 16 byte saltHash should be added to complete the second record
-	 */
-	private static final String COMMON_HEX_DATA = ""
-		// BOF
-		+ "09 08 10 00"
-		+ "00 06  05 00  D3 10  CC 07  01 00 00 00  00 06 00 00"
-		// FILEPASS
-		+ "2F 00 36 00"
-		+ "01 00  01 00  01 00"
-		+ "BAADF00D BAADF00D BAADF00D BAADF00D" // docId
-		+ "DEADBEEF DEADBEEF DEADBEEF DEADBEEF" // saltData
-		;
-
-	/**
-	 * Hex dump of a sample WINDOW1 record
-	 */
-	private static final String SAMPLE_WINDOW1 = "3D 00 12 00"
-		+ "00 00 00 00 40 38 55 23 38 00 00 00 00 00 01 00 58 02";
-
-
-	/**
-	 * Makes sure that a default password mismatch condition is represented with {@link EncryptedDocumentException}
-	 */
-	@Test
-	void defaultPasswordWrong() {
-		// This encodng depends on docId, password and stream position
-		final String SAMPLE_WINDOW1_ENCR1 = "3D 00 12 00"
-			+ "C4, 9B, 02, 50, 86, E0, DF, 34, FB, 57, 0E, 8C, CE, 25, 45, E3, 80, 01";
-
-		byte[] dataWrongDefault = HexRead.readFromString(""
-				+ COMMON_HEX_DATA
-				+ "00000000 00000000 00000000 00000001"
-				+ SAMPLE_WINDOW1_ENCR1
-		);
-
-		EncryptedDocumentException ex = assertThrows(
-			EncryptedDocumentException.class,
-			() -> createRFIS(dataWrongDefault)
-		);
-		assertTrue(ex.getMessage().contains("Default password is invalid for salt/verifier/verifierHash"));
-	}
+    /**
+     * Hex dump of a BOF record and most of a FILEPASS record.
+     * A 16 byte saltHash should be added to complete the second record
+     */
+    private static final String COMMON_HEX_DATA = ""
+        // BOF
+        + "09 08 10 00"
+        + "00 06  05 00  D3 10  CC 07  01 00 00 00  00 06 00 00"
+        // FILEPASS
+        + "2F 00 36 00"
+        + "01 00  01 00  01 00"
+        + "BAADF00D BAADF00D BAADF00D BAADF00D" // docId
+        + "DEADBEEF DEADBEEF DEADBEEF DEADBEEF" // saltData
+        ;
+
+    /**
+     * Hex dump of a sample WINDOW1 record
+     */
+    private static final String SAMPLE_WINDOW1 = "3D 00 12 00"
+        + "00 00 00 00 40 38 55 23 38 00 00 00 00 00 01 00 58 02";
+
+
+    /**
+     * Makes sure that a default password mismatch condition is represented with {@link EncryptedDocumentException}
+     */
+    @Test
+    void defaultPasswordWrong() {
+        // This encodng depends on docId, password and stream position
+        final String SAMPLE_WINDOW1_ENCR1 = "3D 00 12 00"
+            + "C4, 9B, 02, 50, 86, E0, DF, 34, FB, 57, 0E, 8C, CE, 25, 45, E3, 80, 01";
+
+        byte[] dataWrongDefault = HexRead.readFromString(""
+                + COMMON_HEX_DATA
+                + "00000000 00000000 00000000 00000001"
+                + SAMPLE_WINDOW1_ENCR1
+        );
+
+        EncryptedDocumentException ex = assertThrows(
+            EncryptedDocumentException.class,
+            () -> createRFIS(dataWrongDefault)
+        );
+        assertTrue(ex.getMessage().contains("Default password is invalid for salt/verifier/verifierHash"));
+    }
 
     @Test
     void defaultPasswordOK() {
@@ -94,32 +94,32 @@ final class TestRecordFactoryInputStream
     }
 
 
-	/**
-	 * Makes sure that an incorrect user supplied password condition is represented with {@link EncryptedDocumentException}
-	 */
-	@Test
-	void suppliedPasswordWrong() {
-		// This encoding depends on docId, password and stream position
-		final String SAMPLE_WINDOW1_ENCR2 = "3D 00 12 00"
-			+ "45, B9, 90, FE, B6, C6, EC, 73, EE, 3F, 52, 45, 97, DB, E3, C1, D6, FE";
-
-		byte[] dataWrongDefault = HexRead.readFromString(""
-				+ COMMON_HEX_DATA
-				+ "00000000 00000000 00000000 00000000"
-				+ SAMPLE_WINDOW1_ENCR2
-		);
-
-		Biff8EncryptionKey.setCurrentUserPassword("passw0rd");
-		try {
-			EncryptedDocumentException ex = assertThrows(
-				EncryptedDocumentException.class,
-				() -> createRFIS(dataWrongDefault)
-			);
-			assertEquals("Supplied password is invalid for salt/verifier/verifierHash", ex.getMessage());
-		} finally {
-			Biff8EncryptionKey.setCurrentUserPassword(null);
-		}
-	}
+    /**
+     * Makes sure that an incorrect user supplied password condition is represented with {@link EncryptedDocumentException}
+     */
+    @Test
+    void suppliedPasswordWrong() {
+        // This encoding depends on docId, password and stream position
+        final String SAMPLE_WINDOW1_ENCR2 = "3D 00 12 00"
+            + "45, B9, 90, FE, B6, C6, EC, 73, EE, 3F, 52, 45, 97, DB, E3, C1, D6, FE";
+
+        byte[] dataWrongDefault = HexRead.readFromString(""
+                + COMMON_HEX_DATA
+                + "00000000 00000000 00000000 00000000"
+                + SAMPLE_WINDOW1_ENCR2
+        );
+
+        Biff8EncryptionKey.setCurrentUserPassword("passw0rd");
+        try {
+            EncryptedDocumentException ex = assertThrows(
+                EncryptedDocumentException.class,
+                () -> createRFIS(dataWrongDefault)
+            );
+            assertEquals("Supplied password is invalid for salt/verifier/verifierHash", ex.getMessage());
+        } finally {
+            Biff8EncryptionKey.setCurrentUserPassword(null);
+        }
+    }
 
     @Test
     void suppliedPasswordOK() {
@@ -133,28 +133,28 @@ final class TestRecordFactoryInputStream
                 + SAMPLE_WINDOW1_ENCR2
         );
 
-		Biff8EncryptionKey.setCurrentUserPassword("passw0rd");
-		try {
-			RecordFactoryInputStream rfis = createRFIS(dataCorrectDefault);
-			confirmReadInitialRecords(rfis);
-		} finally {
-			Biff8EncryptionKey.setCurrentUserPassword(null);
-		}
+        Biff8EncryptionKey.setCurrentUserPassword("passw0rd");
+        try {
+            RecordFactoryInputStream rfis = createRFIS(dataCorrectDefault);
+            confirmReadInitialRecords(rfis);
+        } finally {
+            Biff8EncryptionKey.setCurrentUserPassword(null);
+        }
     }
 
 
-	/**
-	 * makes sure the record stream starts with {@link BOFRecord}, {@link FilePassRecord} and then {@link WindowOneRecord}
-	 * The third record is decrypted so this method also checks its content.
-	 */
-	private void confirmReadInitialRecords(RecordFactoryInputStream rfis) {
-		assertEquals(BOFRecord.class, rfis.nextRecord().getClass());
-		FilePassRecord recFP = (FilePassRecord) rfis.nextRecord();
-		WindowOneRecord rec1 = (WindowOneRecord) rfis.nextRecord();
-		assertArrayEquals(HexRead.readFromString(SAMPLE_WINDOW1),rec1.serialize());
-	}
-
-	private static RecordFactoryInputStream createRFIS(byte[] data) {
-		return new RecordFactoryInputStream(new ByteArrayInputStream(data), true);
-	}
+    /**
+     * makes sure the record stream starts with {@link BOFRecord}, {@link FilePassRecord} and then {@link WindowOneRecord}
+     * The third record is decrypted so this method also checks its content.
+     */
+    private void confirmReadInitialRecords(RecordFactoryInputStream rfis) {
+        assertEquals(BOFRecord.class, rfis.nextRecord().getClass());
+        FilePassRecord recFP = (FilePassRecord) rfis.nextRecord();
+        WindowOneRecord rec1 = (WindowOneRecord) rfis.nextRecord();
+        assertArrayEquals(HexRead.readFromString(SAMPLE_WINDOW1),rec1.serialize());
+    }
+
+    private static RecordFactoryInputStream createRFIS(byte[] data) {
+        return new RecordFactoryInputStream(new ByteArrayInputStream(data), true);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordInputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordInputStream.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestRecordInputStream.java Sat May 22 20:56:44 2021
@@ -30,74 +30,74 @@ import org.junit.jupiter.params.provider
  */
 final class TestRecordInputStream {
 
-	/**
-	 * Data inspired by attachment 22626 of bug 45866<br>
-	 * A unicode string of 18 chars, with a continue record where the compression flag changes
-	 */
-	private static final String HED_DUMP1 = ""
-			+ "1A 59 00 8A 9E 8A " // 3 uncompressed unicode chars
-			+ "3C 00 " // Continue sid
-			+ "10 00 " // rec size 16 (1+15)
-			+ "00"	// next chunk is compressed
-			+ "20 2D 20 4D 75 6C 74 69 6C 69 6E 67 75 61 6C " // 15 chars
-	;
-	/**
-	 * same string re-arranged
-	 */
-	private static final String HED_DUMP2 = ""
-			// 15 chars at end of current record
-			+ "4D 75 6C 74 69 6C 69 6E 67 75 61 6C 20 2D 20"
-			+ "3C 00 " // Continue sid
-			+ "07 00 " // rec size 7 (1+6)
-			+ "01"	// this bit uncompressed
-			+ "1A 59 00 8A 9E 8A " // 3 uncompressed unicode chars
-	;
-
-
-	@Test
-	void testChangeOfCompressionFlag_bug25866() {
-		byte[] changingFlagSimpleData = HexRead.readFromString(""
-				+ "AA AA "  // fake SID
-				+ "06 00 "  // first rec len 6
-				+ HED_DUMP1
-				);
-		RecordInputStream in = TestcaseRecordInputStream.create(changingFlagSimpleData);
-
-		// bug 45866 - compressByte in continue records must be 1 while reading unicode LE string
-		String actual  = in.readUnicodeLEString(18);
-		assertEquals("\u591A\u8A00\u8A9E - Multilingual", actual);
-	}
-
-	@Test
-	void testChangeFromUnCompressedToCompressed() {
-		byte[] changingFlagSimpleData = HexRead.readFromString(""
-				+ "AA AA "  // fake SID
-				+ "0F 00 "  // first rec len 15
-				+ HED_DUMP2
-				);
-		RecordInputStream in = TestcaseRecordInputStream.create(changingFlagSimpleData);
-		String actual = in.readCompressedUnicode(18);
-		assertEquals("Multilingual - \u591A\u8A00\u8A9E", actual);
-	}
-
-	@Test
-	void testReadString() {
-		byte[] changingFlagFullData = HexRead.readFromString(""
-				+ "AA AA "  // fake SID
-				+ "12 00 "  // first rec len 18 (15 + next 3 bytes)
-				+ "12 00 "  // total chars 18
-				+ "00 "	 // this bit compressed
-				+ HED_DUMP2
-				);
-		RecordInputStream in = TestcaseRecordInputStream.create(changingFlagFullData);
-		String actual = in.readString();
-		assertEquals("Multilingual - \u591A\u8A00\u8A9E", actual);
-	}
-
-	@ParameterizedTest
-	@CsvSource({"1, 200", "0, 200", "999999999, 200", HeaderRecord.sid+", 200"})
-	void testLeftoverDataException(int sid, int remainingByteCount) {
-	    // just ensure that the exception is created correctly, even with unknown sids
-		assertDoesNotThrow(() -> new RecordInputStream.LeftoverDataException(sid, remainingByteCount));
-	}
+    /**
+     * Data inspired by attachment 22626 of bug 45866<br>
+     * A unicode string of 18 chars, with a continue record where the compression flag changes
+     */
+    private static final String HED_DUMP1 = ""
+            + "1A 59 00 8A 9E 8A " // 3 uncompressed unicode chars
+            + "3C 00 " // Continue sid
+            + "10 00 " // rec size 16 (1+15)
+            + "00"  // next chunk is compressed
+            + "20 2D 20 4D 75 6C 74 69 6C 69 6E 67 75 61 6C " // 15 chars
+    ;
+    /**
+     * same string re-arranged
+     */
+    private static final String HED_DUMP2 = ""
+            // 15 chars at end of current record
+            + "4D 75 6C 74 69 6C 69 6E 67 75 61 6C 20 2D 20"
+            + "3C 00 " // Continue sid
+            + "07 00 " // rec size 7 (1+6)
+            + "01"  // this bit uncompressed
+            + "1A 59 00 8A 9E 8A " // 3 uncompressed unicode chars
+    ;
+
+
+    @Test
+    void testChangeOfCompressionFlag_bug25866() {
+        byte[] changingFlagSimpleData = HexRead.readFromString(""
+                + "AA AA "  // fake SID
+                + "06 00 "  // first rec len 6
+                + HED_DUMP1
+                );
+        RecordInputStream in = TestcaseRecordInputStream.create(changingFlagSimpleData);
+
+        // bug 45866 - compressByte in continue records must be 1 while reading unicode LE string
+        String actual  = in.readUnicodeLEString(18);
+        assertEquals("\u591A\u8A00\u8A9E - Multilingual", actual);
+    }
+
+    @Test
+    void testChangeFromUnCompressedToCompressed() {
+        byte[] changingFlagSimpleData = HexRead.readFromString(""
+                + "AA AA "  // fake SID
+                + "0F 00 "  // first rec len 15
+                + HED_DUMP2
+                );
+        RecordInputStream in = TestcaseRecordInputStream.create(changingFlagSimpleData);
+        String actual = in.readCompressedUnicode(18);
+        assertEquals("Multilingual - \u591A\u8A00\u8A9E", actual);
+    }
+
+    @Test
+    void testReadString() {
+        byte[] changingFlagFullData = HexRead.readFromString(""
+                + "AA AA "  // fake SID
+                + "12 00 "  // first rec len 18 (15 + next 3 bytes)
+                + "12 00 "  // total chars 18
+                + "00 "  // this bit compressed
+                + HED_DUMP2
+                );
+        RecordInputStream in = TestcaseRecordInputStream.create(changingFlagFullData);
+        String actual = in.readString();
+        assertEquals("Multilingual - \u591A\u8A00\u8A9E", actual);
+    }
+
+    @ParameterizedTest
+    @CsvSource({"1, 200", "0, 200", "999999999, 200", HeaderRecord.sid+", 200"})
+    void testLeftoverDataException(int sid, int remainingByteCount) {
+        // just ensure that the exception is created correctly, even with unknown sids
+        assertDoesNotThrow(() -> new RecordInputStream.LeftoverDataException(sid, remainingByteCount));
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java Sat May 22 20:56:44 2021
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
  * Exercise the SSTDeserializer class.
  */
 final class TestSSTDeserializer {
-	private static final int FAKE_SID = -5555;
+    private static final int FAKE_SID = -5555;
 
     private static byte[] concat(byte[] a, byte[] b) {
         byte[] result = new byte[a.length + b.length];

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSSTRecordSizeCalculator.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSSTRecordSizeCalculator.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSSTRecordSizeCalculator.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSSTRecordSizeCalculator.java Sat May 22 20:56:44 2021
@@ -29,109 +29,109 @@ import org.junit.jupiter.api.Test;
  * Tests that records size calculates correctly.
  */
 final class TestSSTRecordSizeCalculator {
-	private static final String SMALL_STRING = "Small string";
-	private static final int COMPRESSED_PLAIN_STRING_OVERHEAD = 3;
-	private static final int OPTION_FIELD_SIZE = 1;
-
-	private final IntMapper<UnicodeString> strings = new IntMapper<>();
-
-
-	/** standard record overhead: two shorts (record id plus data space size)*/
-	private static final int STD_RECORD_OVERHEAD = 2 * LittleEndianConsts.SHORT_SIZE;
-
-	/** SST overhead: the standard record overhead, plus the number of strings and the number of unique strings -- two ints */
-	private static final int SST_RECORD_OVERHEAD = STD_RECORD_OVERHEAD + 2 * LittleEndianConsts.INT_SIZE;
-
-	/** how much data can we stuff into an SST record? That would be _max minus the standard SST record overhead */
-	private static final int MAX_DATA_SPACE = RecordInputStream.MAX_RECORD_DATA_SIZE - 8;
-
-
-	private void confirmSize(int expectedSize) {
-		ContinuableRecordOutput cro = ContinuableRecordOutput.createForCountingOnly();
-		SSTSerializer ss = new SSTSerializer(strings, 0, 0);
-		ss.serialize(cro);
-		assertEquals(expectedSize, cro.getTotalSize());
-	}
-
-	@Test
-	void testBasic() {
-		strings.add(makeUnicodeString(SMALL_STRING));
-		confirmSize(SST_RECORD_OVERHEAD
-				+ COMPRESSED_PLAIN_STRING_OVERHEAD
-				+ SMALL_STRING.length());
-	}
-
-	@Test
-	void testBigStringAcrossUnicode() {
-		int bigString = MAX_DATA_SPACE + 100;
-		strings.add(makeUnicodeString(bigString));
-		confirmSize(SST_RECORD_OVERHEAD
-				+ COMPRESSED_PLAIN_STRING_OVERHEAD
-				+ MAX_DATA_SPACE
-				+ STD_RECORD_OVERHEAD
-				+ OPTION_FIELD_SIZE
-				+ 100);
-	}
-
-	@Test
-	void testPerfectFit() {
-		int perfectFit = MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD;
-		strings.add(makeUnicodeString(perfectFit));
-		confirmSize(SST_RECORD_OVERHEAD
-				+ COMPRESSED_PLAIN_STRING_OVERHEAD
-				+ perfectFit);
-	}
-
-	@Test
-	void testJustOversized() {
-		int tooBig = MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD + 1;
-		strings.add(makeUnicodeString(tooBig));
-		confirmSize(SST_RECORD_OVERHEAD
-				+ COMPRESSED_PLAIN_STRING_OVERHEAD
-				+ tooBig - 1
-				// continue record
-				+ STD_RECORD_OVERHEAD
-				+ OPTION_FIELD_SIZE + 1);
-
-	}
-
-	@Test
-	void testSecondStringStartsOnNewContinuation() {
-		int perfectFit = MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD;
-		strings.add(makeUnicodeString(perfectFit));
-		strings.add(makeUnicodeString(SMALL_STRING));
-		confirmSize(SST_RECORD_OVERHEAD
-				+ MAX_DATA_SPACE
-				// second string
-				+ STD_RECORD_OVERHEAD
-				+ COMPRESSED_PLAIN_STRING_OVERHEAD
-				+ SMALL_STRING.length());
-	}
-
-	@Test
-	void testHeaderCrossesNormalContinuePoint() {
-		int almostPerfectFit = MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD - 2;
-		strings.add(makeUnicodeString(almostPerfectFit));
-		String oneCharString = new String(new char[1]);
-		strings.add(makeUnicodeString(oneCharString));
-		confirmSize(SST_RECORD_OVERHEAD
-				+ COMPRESSED_PLAIN_STRING_OVERHEAD
-				+ almostPerfectFit
-				// second string
-				+ STD_RECORD_OVERHEAD
-				+ COMPRESSED_PLAIN_STRING_OVERHEAD
-				+ oneCharString.length());
-
-	}
-
-	private static UnicodeString makeUnicodeString(int size) {
-		String s = new String(new char[size]);
-		return makeUnicodeString(s);
-	}
-
-	private static UnicodeString makeUnicodeString(String s) {
-		UnicodeString st = new UnicodeString(s);
-		st.setOptionFlags((byte) 0);
-		return st;
-	}
+    private static final String SMALL_STRING = "Small string";
+    private static final int COMPRESSED_PLAIN_STRING_OVERHEAD = 3;
+    private static final int OPTION_FIELD_SIZE = 1;
+
+    private final IntMapper<UnicodeString> strings = new IntMapper<>();
+
+
+    /** standard record overhead: two shorts (record id plus data space size)*/
+    private static final int STD_RECORD_OVERHEAD = 2 * LittleEndianConsts.SHORT_SIZE;
+
+    /** SST overhead: the standard record overhead, plus the number of strings and the number of unique strings -- two ints */
+    private static final int SST_RECORD_OVERHEAD = STD_RECORD_OVERHEAD + 2 * LittleEndianConsts.INT_SIZE;
+
+    /** how much data can we stuff into an SST record? That would be _max minus the standard SST record overhead */
+    private static final int MAX_DATA_SPACE = RecordInputStream.MAX_RECORD_DATA_SIZE - 8;
+
+
+    private void confirmSize(int expectedSize) {
+        ContinuableRecordOutput cro = ContinuableRecordOutput.createForCountingOnly();
+        SSTSerializer ss = new SSTSerializer(strings, 0, 0);
+        ss.serialize(cro);
+        assertEquals(expectedSize, cro.getTotalSize());
+    }
+
+    @Test
+    void testBasic() {
+        strings.add(makeUnicodeString(SMALL_STRING));
+        confirmSize(SST_RECORD_OVERHEAD
+                + COMPRESSED_PLAIN_STRING_OVERHEAD
+                + SMALL_STRING.length());
+    }
+
+    @Test
+    void testBigStringAcrossUnicode() {
+        int bigString = MAX_DATA_SPACE + 100;
+        strings.add(makeUnicodeString(bigString));
+        confirmSize(SST_RECORD_OVERHEAD
+                + COMPRESSED_PLAIN_STRING_OVERHEAD
+                + MAX_DATA_SPACE
+                + STD_RECORD_OVERHEAD
+                + OPTION_FIELD_SIZE
+                + 100);
+    }
+
+    @Test
+    void testPerfectFit() {
+        int perfectFit = MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD;
+        strings.add(makeUnicodeString(perfectFit));
+        confirmSize(SST_RECORD_OVERHEAD
+                + COMPRESSED_PLAIN_STRING_OVERHEAD
+                + perfectFit);
+    }
+
+    @Test
+    void testJustOversized() {
+        int tooBig = MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD + 1;
+        strings.add(makeUnicodeString(tooBig));
+        confirmSize(SST_RECORD_OVERHEAD
+                + COMPRESSED_PLAIN_STRING_OVERHEAD
+                + tooBig - 1
+                // continue record
+                + STD_RECORD_OVERHEAD
+                + OPTION_FIELD_SIZE + 1);
+
+    }
+
+    @Test
+    void testSecondStringStartsOnNewContinuation() {
+        int perfectFit = MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD;
+        strings.add(makeUnicodeString(perfectFit));
+        strings.add(makeUnicodeString(SMALL_STRING));
+        confirmSize(SST_RECORD_OVERHEAD
+                + MAX_DATA_SPACE
+                // second string
+                + STD_RECORD_OVERHEAD
+                + COMPRESSED_PLAIN_STRING_OVERHEAD
+                + SMALL_STRING.length());
+    }
+
+    @Test
+    void testHeaderCrossesNormalContinuePoint() {
+        int almostPerfectFit = MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD - 2;
+        strings.add(makeUnicodeString(almostPerfectFit));
+        String oneCharString = new String(new char[1]);
+        strings.add(makeUnicodeString(oneCharString));
+        confirmSize(SST_RECORD_OVERHEAD
+                + COMPRESSED_PLAIN_STRING_OVERHEAD
+                + almostPerfectFit
+                // second string
+                + STD_RECORD_OVERHEAD
+                + COMPRESSED_PLAIN_STRING_OVERHEAD
+                + oneCharString.length());
+
+    }
+
+    private static UnicodeString makeUnicodeString(int size) {
+        String s = new String(new char[size]);
+        return makeUnicodeString(s);
+    }
+
+    private static UnicodeString makeUnicodeString(String s) {
+        UnicodeString st = new UnicodeString(s);
+        st.setOptionFlags((byte) 0);
+        return st;
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestStringRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestStringRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestStringRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestStringRecord.java Sat May 22 20:56:44 2021
@@ -34,69 +34,69 @@ import org.junit.jupiter.api.Test;
  * Excel file.
  */
 final class TestStringRecord {
-	private static final byte[] data = HexRead.readFromString(
-			"0B 00 " + // length
-			"00 " +    // option
-			// string
-			"46 61 68 72 7A 65 75 67 74 79 70"
-	);
-
-	@Test
-	void testLoad() {
+    private static final byte[] data = HexRead.readFromString(
+            "0B 00 " + // length
+            "00 " +    // option
+            // string
+            "46 61 68 72 7A 65 75 67 74 79 70"
+    );
+
+    @Test
+    void testLoad() {
 
-		StringRecord record = new StringRecord(TestcaseRecordInputStream.create(0x207, data));
-		assertEquals( "Fahrzeugtyp", record.getString());
+        StringRecord record = new StringRecord(TestcaseRecordInputStream.create(0x207, data));
+        assertEquals( "Fahrzeugtyp", record.getString());
 
-		assertEquals( 18, record.getRecordSize() );
-	}
+        assertEquals( 18, record.getRecordSize() );
+    }
 
-	@Test
+    @Test
     void testStore() {
-		StringRecord record = new StringRecord();
-		record.setString("Fahrzeugtyp");
+        StringRecord record = new StringRecord();
+        record.setString("Fahrzeugtyp");
 
-		byte [] recordBytes = record.serialize();
-		assertEquals(recordBytes.length - 4, data.length);
-		for (int i = 0; i < data.length; i++) {
+        byte [] recordBytes = record.serialize();
+        assertEquals(recordBytes.length - 4, data.length);
+        for (int i = 0; i < data.length; i++) {
             assertEquals(data[i], recordBytes[i+4], "At offset " + i);
         }
-	}
+    }
 
-	@Test
+    @Test
     void testContinue() throws IOException {
-		int MAX_BIFF_DATA = RecordInputStream.MAX_RECORD_DATA_SIZE;
-		int TEXT_LEN = MAX_BIFF_DATA + 1000; // deliberately over-size
-		String textChunk = "ABCDEGGHIJKLMNOP"; // 16 chars
-		StringBuilder sb = new StringBuilder(16384);
-		while (sb.length() < TEXT_LEN) {
-			sb.append(textChunk);
-		}
-		sb.setLength(TEXT_LEN);
-
-		StringRecord sr = new StringRecord();
-		sr.setString(sb.toString());
-		byte[] ser = sr.serialize();
-		assertEquals(StringRecord.sid, LittleEndian.getUShort(ser, 0));
-		assertTrue(LittleEndian.getUShort(ser, 2) <= MAX_BIFF_DATA,
-			"StringRecord should have been split with a continue record");
-		// Confirm expected size of first record, and ushort strLen.
-		assertEquals(MAX_BIFF_DATA, LittleEndian.getUShort(ser, 2));
-		assertEquals(TEXT_LEN, LittleEndian.getUShort(ser, 4));
-
-		// Confirm first few bytes of ContinueRecord
-		LittleEndianByteArrayInputStream crIn = new LittleEndianByteArrayInputStream(ser, (MAX_BIFF_DATA + 4));
-		int nCharsInFirstRec = MAX_BIFF_DATA - (2 + 1); // strLen, optionFlags
-		int nCharsInSecondRec = TEXT_LEN - nCharsInFirstRec;
-		assertEquals(ContinueRecord.sid, crIn.readUShort());
-		assertEquals(1 + nCharsInSecondRec, crIn.readUShort());
-		assertEquals(0, crIn.readUByte());
-		assertEquals('N', crIn.readUByte());
-		assertEquals('O', crIn.readUByte());
-
-		// re-read and make sure string value is the same
-		RecordInputStream in = TestcaseRecordInputStream.create(ser);
-		StringRecord sr2 = new StringRecord(in);
-		assertEquals(sb.toString(), sr2.getString());
-		crIn.close();
-	}
+        int MAX_BIFF_DATA = RecordInputStream.MAX_RECORD_DATA_SIZE;
+        int TEXT_LEN = MAX_BIFF_DATA + 1000; // deliberately over-size
+        String textChunk = "ABCDEGGHIJKLMNOP"; // 16 chars
+        StringBuilder sb = new StringBuilder(16384);
+        while (sb.length() < TEXT_LEN) {
+            sb.append(textChunk);
+        }
+        sb.setLength(TEXT_LEN);
+
+        StringRecord sr = new StringRecord();
+        sr.setString(sb.toString());
+        byte[] ser = sr.serialize();
+        assertEquals(StringRecord.sid, LittleEndian.getUShort(ser, 0));
+        assertTrue(LittleEndian.getUShort(ser, 2) <= MAX_BIFF_DATA,
+            "StringRecord should have been split with a continue record");
+        // Confirm expected size of first record, and ushort strLen.
+        assertEquals(MAX_BIFF_DATA, LittleEndian.getUShort(ser, 2));
+        assertEquals(TEXT_LEN, LittleEndian.getUShort(ser, 4));
+
+        // Confirm first few bytes of ContinueRecord
+        LittleEndianByteArrayInputStream crIn = new LittleEndianByteArrayInputStream(ser, (MAX_BIFF_DATA + 4));
+        int nCharsInFirstRec = MAX_BIFF_DATA - (2 + 1); // strLen, optionFlags
+        int nCharsInSecondRec = TEXT_LEN - nCharsInFirstRec;
+        assertEquals(ContinueRecord.sid, crIn.readUShort());
+        assertEquals(1 + nCharsInSecondRec, crIn.readUShort());
+        assertEquals(0, crIn.readUByte());
+        assertEquals('N', crIn.readUByte());
+        assertEquals('O', crIn.readUByte());
+
+        // re-read and make sure string value is the same
+        RecordInputStream in = TestcaseRecordInputStream.create(ser);
+        StringRecord sr2 = new StringRecord(in);
+        assertEquals(sb.toString(), sr2.getString());
+        crIn.close();
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestStyleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestStyleRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestStyleRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestStyleRecord.java Sat May 22 20:56:44 2021
@@ -27,15 +27,15 @@ import org.junit.jupiter.api.Test;
  * Tests for {@link StyleRecord}
  */
 final class TestStyleRecord {
-	@Test
-	void testUnicodeReadName() {
-		byte[] data = HexRead.readFromString(
-				"11 00 09 00 01 38 5E C4 89 5F 00 53 00 68 00 65 00 65 00 74 00 31 00");
-		RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
-		StyleRecord sr = new StyleRecord(in);
-		assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
-		// bug 46385 - Incorrect number of bytes written - expected 27 but got 18
-		byte[] ser = sr.serialize();
-		confirmRecordEncoding(StyleRecord.sid, data, ser);
-	}
+    @Test
+    void testUnicodeReadName() {
+        byte[] data = HexRead.readFromString(
+                "11 00 09 00 01 38 5E C4 89 5F 00 53 00 68 00 65 00 65 00 74 00 31 00");
+        RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
+        StyleRecord sr = new StyleRecord(in);
+        assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
+        // bug 46385 - Incorrect number of bytes written - expected 27 but got 18
+        byte[] ser = sr.serialize();
+        confirmRecordEncoding(StyleRecord.sid, data, ser);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSubRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSubRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSubRecord.java Sat May 22 20:56:44 2021
@@ -35,114 +35,114 @@ import org.junit.jupiter.api.Test;
  * from a real Excel file.
  */
 final class TestSubRecord {
-	/*
-	   The following is a dump of the OBJ record corresponding to an auto-filter
-	   drop-down list. The 3rd subrecord beginning at offset 0x002e (type=0x0013)
-	   does not conform to the documentation, because the length field is 0x1fee,
-	   which is longer than the entire OBJ record.
-
-	   00000000 15 00 12 00 14 00 01 00 01 21 00 00 00 00 3C 13 .........!....<.  Type=0x15 Len=0x0012 ftCmo
-	   00000010 F4 03 00 00 00 00
-	                              0C 00 14 00 00 00 00 00 00 00 ................  Type=0x0c Len=0x0014 ftSbs
-	   00000020 00 00 00 00 01 00 08 00 00 00 10 00 00 00
-	                                                      13 00 ................  Type=0x13 Len=0x1FEE ftLbsData
-	   00000030 EE 1F 00 00 08 00 08 00 01 03 00 00 0A 00 14 00 ................
-	   00000040 6C 00
-	                  00 00 00 00                               l.....            Type=0x00 Len=0x0000 ftEnd
-	*/
-
-	private static final byte[] dataAutoFilter
-		= HexRead.readFromString(""
-			+ "5D 00 46 00 " // ObjRecord.sid, size=70
-			// ftCmo
-			+ "15 00 12 00 "
-			+ "14 00 01 00 01 00 01 21 00 00 3C 13 F4 03 00 00 00 00 "
-			// ftSbs (currently UnknownSubrecord)
-			+ "0C 00 14 00 "
-			+ "00 00 00 00 00 00 00 00 00 00 01 00 08 00 00 00 10 00 00 00 "
-			// ftLbsData (currently UnknownSubrecord)
-			+ "13 00 EE 1F 00 00 "
-			+ "08 00 08 00 01 03 00 00 0A 00 14 00 6C 00 "
-			// ftEnd
-			+ "00 00 00 00"
-		);
-
-
-	/**
-	 * Make sure that ftLbsData (which has abnormal size info) is parsed correctly.
-	 * If the size field is interpreted incorrectly, the resulting ObjRecord becomes way too big.
-	 * At the time of fixing (Oct-2008 svn r707447) {@link RecordInputStream} allowed  buffer
-	 * read overruns, so the bug was mostly silent.
-	 */
-	@Test
-	void testReadAll_bug45778() {
-		RecordInputStream in = TestcaseRecordInputStream.create(dataAutoFilter);
-		ObjRecord or = new ObjRecord(in);
-		byte[] data2 = or.serialize();
-		assertNotEquals(8228, data2.length, "Identified bug 45778");
-		assertEquals(74, data2.length);
-		assertArrayEquals(dataAutoFilter, data2);
-	}
-
-	@Test
-	void testReadManualComboWithFormula() {
-		byte[] data = HexRead.readFromString(""
-			+ "5D 00 66 00 "
-			+ "15 00 12 00 14 00 02 00 11 20 00 00 00 00 "
-			+ "20 44 C6 04 00 00 00 00 0C 00 14 00 04 F0 C6 04 "
-			+ "00 00 00 00 00 00 01 00 06 00 00 00 10 00 00 00 "
-			+ "0E 00 0C 00 05 00 80 44 C6 04 24 09 00 02 00 02 "
-			+ "13 00 DE 1F 10 00 09 00 80 44 C6 04 25 0A 00 0F "
-			+ "00 02 00 02 00 02 06 00 03 00 08 00 00 00 00 00 "
-			+ "08 00 00 00 00 00 00 00 " // TODO sometimes last byte is non-zero
-		);
-
-		RecordInputStream in = TestcaseRecordInputStream.create(data);
-		ObjRecord or = new ObjRecord(in);
-		byte[] data2 = or.serialize();
-		assertNotEquals(8228, data2.length, "Identified bug 45778");
-		assertEquals(data.length, data2.length, "Encoded length");
-		assertArrayEquals(data, data2, "Encoded data differs");
-	}
-
-	/**
-	 * Some versions of POI (e.g. 3.1 - prior to svn r707450 / bug 45778) interpreted the ftLbs
-	 * subrecord second short (0x1FEE) as a length, and hence read lots of extra padding.  This
-	 * buffer-overrun in {@link RecordInputStream} happened silently due to problems later fixed
-	 * in svn 707778. When the ObjRecord is written, the extra padding is written too, making the
-	 * record 8224 bytes long instead of 70.
-	 * (An aside: It seems more than a coincidence that this problem creates a record of exactly
-	 * {@link RecordInputStream#MAX_RECORD_DATA_SIZE} but not enough is understood about
-	 * subrecords to explain this.)<br>
-	 *
-	 * Excel reads files with this excessive padding OK.  It also truncates the over-sized
-	 * ObjRecord back to the proper size.  POI should do the same.
-	 */
-	@Test
-	void testWayTooMuchPadding_bug46545() {
-		byte[] data = HexRead.readFromString(""
-			+ "15 00 12 00 14 00 13 00 01 21 00 00 00"
-			+ "00 98 0B 5B 09 00 00 00 00 0C 00 14 00 00 00 00 00 00 00 00"
-			+ "00 00 00 01 00 01 00 00 00 10 00 00 00 "
-			// ftLbs
-			+ "13 00 EE 1F 00 00 "
-			+ "01 00 00 00 01 06 00 00 02 00 08 00 75 00 "
-			// ftEnd
-			+ "00 00 00 00"
-		);
-		final int LBS_START_POS = 0x002E;
-		final int WRONG_LBS_SIZE = 0x1FEE;
-		assertEquals(0x0013, LittleEndian.getShort(data, LBS_START_POS));
-		assertEquals(WRONG_LBS_SIZE, LittleEndian.getShort(data, LBS_START_POS+2));
-		int wrongTotalSize = LBS_START_POS + 4 + WRONG_LBS_SIZE;
-		byte[] wrongData = Arrays.copyOf(data, wrongTotalSize);
-		// wrongData has the ObjRecord data as would have been written by v3.1
-
-		RecordInputStream in = TestcaseRecordInputStream.create(ObjRecord.sid, wrongData);
-		// bug 46545 - Leftover 8154 bytes in subrecord data
-		ObjRecord or = new ObjRecord(in);
-		// make sure POI properly truncates the ObjRecord data
-		byte[] data2 = or.serialize();
-		confirmRecordEncoding(ObjRecord.sid, data, data2);
-	}
+    /*
+       The following is a dump of the OBJ record corresponding to an auto-filter
+       drop-down list. The 3rd subrecord beginning at offset 0x002e (type=0x0013)
+       does not conform to the documentation, because the length field is 0x1fee,
+       which is longer than the entire OBJ record.
+
+       00000000 15 00 12 00 14 00 01 00 01 21 00 00 00 00 3C 13 .........!....<.  Type=0x15 Len=0x0012 ftCmo
+       00000010 F4 03 00 00 00 00
+                                  0C 00 14 00 00 00 00 00 00 00 ................  Type=0x0c Len=0x0014 ftSbs
+       00000020 00 00 00 00 01 00 08 00 00 00 10 00 00 00
+                                                          13 00 ................  Type=0x13 Len=0x1FEE ftLbsData
+       00000030 EE 1F 00 00 08 00 08 00 01 03 00 00 0A 00 14 00 ................
+       00000040 6C 00
+                      00 00 00 00                               l.....            Type=0x00 Len=0x0000 ftEnd
+    */
+
+    private static final byte[] dataAutoFilter
+        = HexRead.readFromString(""
+            + "5D 00 46 00 " // ObjRecord.sid, size=70
+            // ftCmo
+            + "15 00 12 00 "
+            + "14 00 01 00 01 00 01 21 00 00 3C 13 F4 03 00 00 00 00 "
+            // ftSbs (currently UnknownSubrecord)
+            + "0C 00 14 00 "
+            + "00 00 00 00 00 00 00 00 00 00 01 00 08 00 00 00 10 00 00 00 "
+            // ftLbsData (currently UnknownSubrecord)
+            + "13 00 EE 1F 00 00 "
+            + "08 00 08 00 01 03 00 00 0A 00 14 00 6C 00 "
+            // ftEnd
+            + "00 00 00 00"
+        );
+
+
+    /**
+     * Make sure that ftLbsData (which has abnormal size info) is parsed correctly.
+     * If the size field is interpreted incorrectly, the resulting ObjRecord becomes way too big.
+     * At the time of fixing (Oct-2008 svn r707447) {@link RecordInputStream} allowed  buffer
+     * read overruns, so the bug was mostly silent.
+     */
+    @Test
+    void testReadAll_bug45778() {
+        RecordInputStream in = TestcaseRecordInputStream.create(dataAutoFilter);
+        ObjRecord or = new ObjRecord(in);
+        byte[] data2 = or.serialize();
+        assertNotEquals(8228, data2.length, "Identified bug 45778");
+        assertEquals(74, data2.length);
+        assertArrayEquals(dataAutoFilter, data2);
+    }
+
+    @Test
+    void testReadManualComboWithFormula() {
+        byte[] data = HexRead.readFromString(""
+            + "5D 00 66 00 "
+            + "15 00 12 00 14 00 02 00 11 20 00 00 00 00 "
+            + "20 44 C6 04 00 00 00 00 0C 00 14 00 04 F0 C6 04 "
+            + "00 00 00 00 00 00 01 00 06 00 00 00 10 00 00 00 "
+            + "0E 00 0C 00 05 00 80 44 C6 04 24 09 00 02 00 02 "
+            + "13 00 DE 1F 10 00 09 00 80 44 C6 04 25 0A 00 0F "
+            + "00 02 00 02 00 02 06 00 03 00 08 00 00 00 00 00 "
+            + "08 00 00 00 00 00 00 00 " // TODO sometimes last byte is non-zero
+        );
+
+        RecordInputStream in = TestcaseRecordInputStream.create(data);
+        ObjRecord or = new ObjRecord(in);
+        byte[] data2 = or.serialize();
+        assertNotEquals(8228, data2.length, "Identified bug 45778");
+        assertEquals(data.length, data2.length, "Encoded length");
+        assertArrayEquals(data, data2, "Encoded data differs");
+    }
+
+    /**
+     * Some versions of POI (e.g. 3.1 - prior to svn r707450 / bug 45778) interpreted the ftLbs
+     * subrecord second short (0x1FEE) as a length, and hence read lots of extra padding.  This
+     * buffer-overrun in {@link RecordInputStream} happened silently due to problems later fixed
+     * in svn 707778. When the ObjRecord is written, the extra padding is written too, making the
+     * record 8224 bytes long instead of 70.
+     * (An aside: It seems more than a coincidence that this problem creates a record of exactly
+     * {@link RecordInputStream#MAX_RECORD_DATA_SIZE} but not enough is understood about
+     * subrecords to explain this.)<br>
+     *
+     * Excel reads files with this excessive padding OK.  It also truncates the over-sized
+     * ObjRecord back to the proper size.  POI should do the same.
+     */
+    @Test
+    void testWayTooMuchPadding_bug46545() {
+        byte[] data = HexRead.readFromString(""
+            + "15 00 12 00 14 00 13 00 01 21 00 00 00"
+            + "00 98 0B 5B 09 00 00 00 00 0C 00 14 00 00 00 00 00 00 00 00"
+            + "00 00 00 01 00 01 00 00 00 10 00 00 00 "
+            // ftLbs
+            + "13 00 EE 1F 00 00 "
+            + "01 00 00 00 01 06 00 00 02 00 08 00 75 00 "
+            // ftEnd
+            + "00 00 00 00"
+        );
+        final int LBS_START_POS = 0x002E;
+        final int WRONG_LBS_SIZE = 0x1FEE;
+        assertEquals(0x0013, LittleEndian.getShort(data, LBS_START_POS));
+        assertEquals(WRONG_LBS_SIZE, LittleEndian.getShort(data, LBS_START_POS+2));
+        int wrongTotalSize = LBS_START_POS + 4 + WRONG_LBS_SIZE;
+        byte[] wrongData = Arrays.copyOf(data, wrongTotalSize);
+        // wrongData has the ObjRecord data as would have been written by v3.1
+
+        RecordInputStream in = TestcaseRecordInputStream.create(ObjRecord.sid, wrongData);
+        // bug 46545 - Leftover 8154 bytes in subrecord data
+        ObjRecord or = new ObjRecord(in);
+        // make sure POI properly truncates the ObjRecord data
+        byte[] data2 = or.serialize();
+        confirmRecordEncoding(ObjRecord.sid, data, data2);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSupBookRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSupBookRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSupBookRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestSupBookRecord.java Sat May 22 20:56:44 2021
@@ -128,44 +128,44 @@ final class TestSupBookRecord {
 
     @Test
     void testExternalReferenceUrl() {
-    	String[] sheetNames = new String[]{"SampleSheet"};
-    	final char startMarker = (char)1;
+        String[] sheetNames = new String[]{"SampleSheet"};
+        final char startMarker = (char)1;
 
-		SupBookRecord record;
+        SupBookRecord record;
 
-		record = new SupBookRecord(startMarker + "test.xls", sheetNames);
-    	assertEquals("test.xls", record.getURL());
+        record = new SupBookRecord(startMarker + "test.xls", sheetNames);
+        assertEquals("test.xls", record.getURL());
 
-    	//UNC path notation
-    	record = new SupBookRecord(startMarker + "" + CH_VOLUME + "@servername" + CH_DOWN_DIR + "test.xls", sheetNames);
-    	assertEquals("\\\\servername" + PATH_SEPERATOR + "test.xls", record.getURL());
+        //UNC path notation
+        record = new SupBookRecord(startMarker + "" + CH_VOLUME + "@servername" + CH_DOWN_DIR + "test.xls", sheetNames);
+        assertEquals("\\\\servername" + PATH_SEPERATOR + "test.xls", record.getURL());
 
-    	//Absolute path notation - different device
-    	record = new SupBookRecord(startMarker + "" + CH_VOLUME + "D" + CH_DOWN_DIR + "test.xls", sheetNames);
-    	assertEquals("D:" + PATH_SEPERATOR + "test.xls", record.getURL());
+        //Absolute path notation - different device
+        record = new SupBookRecord(startMarker + "" + CH_VOLUME + "D" + CH_DOWN_DIR + "test.xls", sheetNames);
+        assertEquals("D:" + PATH_SEPERATOR + "test.xls", record.getURL());
 
-    	//Absolute path notation - same device
-    	record = new SupBookRecord(startMarker + "" + CH_SAME_VOLUME + "folder" + CH_DOWN_DIR + "test.xls", sheetNames);
-    	assertEquals(PATH_SEPERATOR + "folder" + PATH_SEPERATOR + "test.xls", record.getURL());
+        //Absolute path notation - same device
+        record = new SupBookRecord(startMarker + "" + CH_SAME_VOLUME + "folder" + CH_DOWN_DIR + "test.xls", sheetNames);
+        assertEquals(PATH_SEPERATOR + "folder" + PATH_SEPERATOR + "test.xls", record.getURL());
 
-    	//Relative path notation - down
-    	record = new SupBookRecord(startMarker + "folder" + CH_DOWN_DIR + "test.xls", sheetNames);
-    	assertEquals("folder" + PATH_SEPERATOR + "test.xls", record.getURL());
+        //Relative path notation - down
+        record = new SupBookRecord(startMarker + "folder" + CH_DOWN_DIR + "test.xls", sheetNames);
+        assertEquals("folder" + PATH_SEPERATOR + "test.xls", record.getURL());
 
-    	//Relative path notation - up
-    	record = new SupBookRecord(startMarker +""+ CH_UP_DIR + "test.xls", sheetNames);
-    	assertEquals(".." + PATH_SEPERATOR + "test.xls", record.getURL());
+        //Relative path notation - up
+        record = new SupBookRecord(startMarker +""+ CH_UP_DIR + "test.xls", sheetNames);
+        assertEquals(".." + PATH_SEPERATOR + "test.xls", record.getURL());
 
-    	//Relative path notation - for EXCEL.exe - fallback
-    	record = new SupBookRecord(startMarker +""+ CH_STARTUP_DIR + "test.xls", sheetNames);
-    	assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
+        //Relative path notation - for EXCEL.exe - fallback
+        record = new SupBookRecord(startMarker +""+ CH_STARTUP_DIR + "test.xls", sheetNames);
+        assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
 
-    	//Relative path notation - for EXCEL lib folder - fallback
-    	record = new SupBookRecord(startMarker +""+ CH_LIB_DIR + "test.xls", sheetNames);
-    	assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
+        //Relative path notation - for EXCEL lib folder - fallback
+        record = new SupBookRecord(startMarker +""+ CH_LIB_DIR + "test.xls", sheetNames);
+        assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
 
-    	//Relative path notation - for alternative EXCEL.exe - fallback
-    	record = new SupBookRecord(startMarker +""+ CH_ALT_STARTUP_DIR+ "test.xls", sheetNames);
-    	assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
+        //Relative path notation - for alternative EXCEL.exe - fallback
+        record = new SupBookRecord(startMarker +""+ CH_ALT_STARTUP_DIR+ "test.xls", sheetNames);
+        assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
     }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestTableRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestTableRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestTableRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestTableRecord.java Sat May 22 20:56:44 2021
@@ -29,69 +29,69 @@ import org.junit.jupiter.api.Test;
  * Excel file.
  */
 final class TestTableRecord {
-	byte[] header = new byte[] {
-			0x36, 02, 0x10, 00, // sid=x236, 16 bytes long
-	};
-	byte[] data = new byte[] {
-			03, 00,  // from row 3
-			8, 00,   // to row 8
-			04,      // from col 4
-			06,      // to col 6
-			00, 00,  // no flags set
-			04, 00,  // row inp row 4
-			01, 00,  // col inp row 1
-			0x76, 0x40, // row inp col 0x4076 (!)
-			00, 00   // col inp col 0
-	};
-
-	@Test
-	void testLoad() {
-
-		TableRecord record = new TableRecord(TestcaseRecordInputStream.create(0x236, data));
-
-		CellRangeAddress8Bit range = record.getRange();
-		assertEquals(3, range.getFirstRow());
-		assertEquals(8, range.getLastRow());
-		assertEquals(4, range.getFirstColumn());
-		assertEquals(6, range.getLastColumn());
-		assertEquals(0, record.getFlags());
-		assertEquals(4, record.getRowInputRow());
-		assertEquals(1, record.getColInputRow());
-		assertEquals(0x4076, record.getRowInputCol());
-		assertEquals(0, record.getColInputCol());
+    byte[] header = new byte[] {
+            0x36, 02, 0x10, 00, // sid=x236, 16 bytes long
+    };
+    byte[] data = new byte[] {
+            03, 00,  // from row 3
+            8, 00,   // to row 8
+            04,      // from col 4
+            06,      // to col 6
+            00, 00,  // no flags set
+            04, 00,  // row inp row 4
+            01, 00,  // col inp row 1
+            0x76, 0x40, // row inp col 0x4076 (!)
+            00, 00   // col inp col 0
+    };
+
+    @Test
+    void testLoad() {
+
+        TableRecord record = new TableRecord(TestcaseRecordInputStream.create(0x236, data));
+
+        CellRangeAddress8Bit range = record.getRange();
+        assertEquals(3, range.getFirstRow());
+        assertEquals(8, range.getLastRow());
+        assertEquals(4, range.getFirstColumn());
+        assertEquals(6, range.getLastColumn());
+        assertEquals(0, record.getFlags());
+        assertEquals(4, record.getRowInputRow());
+        assertEquals(1, record.getColInputRow());
+        assertEquals(0x4076, record.getRowInputCol());
+        assertEquals(0, record.getColInputCol());
 
-		assertEquals( 16 + 4, record.getRecordSize() );
-	}
+        assertEquals( 16 + 4, record.getRecordSize() );
+    }
 
-	@SuppressWarnings("squid:S2699")
-	@Test
+    @SuppressWarnings("squid:S2699")
+    @Test
     void testStore()
     {
-//    	Offset 0x3bd9 (15321)
-//    	recordid = 0x236, size = 16
-//    	[TABLE]
-//    	    .row from      = 3
-//    	    .row to        = 8
-//    	    .column from   = 4
-//    	    .column to     = 6
-//    	    .flags         = 0
-//    	        .always calc     =false
-//    	    .reserved      = 0
-//    	    .row input row = 4
-//    	    .col input row = 1
-//    	    .row input col = 4076
-//    	    .col input col = 0
-//    	[/TABLE]
-
-		CellRangeAddress8Bit crab = new CellRangeAddress8Bit(3, 8, 4, 6);
-		TableRecord record = new TableRecord(crab);
-		record.setFlags((byte)0);
-		record.setRowInputRow(4);
-		record.setColInputRow(1);
-		record.setRowInputCol(0x4076);
-		record.setColInputCol(0);
-
-		byte [] recordBytes = record.serialize();
-		confirmRecordEncoding(TableRecord.sid, data, recordBytes);
-	}
+//      Offset 0x3bd9 (15321)
+//      recordid = 0x236, size = 16
+//      [TABLE]
+//          .row from      = 3
+//          .row to        = 8
+//          .column from   = 4
+//          .column to     = 6
+//          .flags         = 0
+//              .always calc     =false
+//          .reserved      = 0
+//          .row input row = 4
+//          .col input row = 1
+//          .row input col = 4076
+//          .col input col = 0
+//      [/TABLE]
+
+        CellRangeAddress8Bit crab = new CellRangeAddress8Bit(3, 8, 4, 6);
+        TableRecord record = new TableRecord(crab);
+        record.setFlags((byte)0);
+        record.setRowInputRow(4);
+        record.setColInputRow(1);
+        record.setRowInputCol(0x4076);
+        record.setColInputCol(0);
+
+        byte [] recordBytes = record.serialize();
+        confirmRecordEncoding(TableRecord.sid, data, recordBytes);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java Sat May 22 20:56:44 2021
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
  * Excel file.
  */
 final class TestTextObjectBaseRecord {
-	/** data for one TXO rec and two continue recs */
+    /** data for one TXO rec and two continue recs */
     private static final byte[] data = HexRead.readFromString(
         "B6 01 " + // TextObjectRecord.sid
         "12 00 " + // size 18

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestUnicodeNameRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestUnicodeNameRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestUnicodeNameRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestUnicodeNameRecord.java Sat May 22 20:56:44 2021
@@ -29,12 +29,12 @@ import org.junit.jupiter.api.Test;
 
 final class TestUnicodeNameRecord {
 
-	@Test
-	void testReadBook() throws IOException {
-		// This bit used to crash
-		try (HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("unicodeNameRecord.xls")) {
-			HSSFSheet sheet = book.getSheetAt(0);
-			assertNotNull(sheet);
-		}
-	}
+    @Test
+    void testReadBook() throws IOException {
+        // This bit used to crash
+        try (HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("unicodeNameRecord.xls")) {
+            HSSFSheet sheet = book.getSheetAt(0);
+            assertNotNull(sheet);
+        }
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestWriteAccessRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestWriteAccessRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestWriteAccessRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestWriteAccessRecord.java Sat May 22 20:56:44 2021
@@ -28,69 +28,69 @@ import org.junit.jupiter.api.Test;
  */
 final class TestWriteAccessRecord {
 
-	private static final String HEX_SIXTYFOUR_SPACES = ""
-		+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
-		+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
-		+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
-		+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20";
-
-	@Test
-	void testMissingStringHeader_bug47001a() {
-		/*
-		 * Data taken from offset 0x0224 in
-		 * attachment 23468 from bugzilla 47001
-		 */
-		byte[] data = HexRead.readFromString(""
-				+ "5C 00 70 00 "
-				+ "4A 61 76 61 20 45 78 63 65 6C 20 41 50 49 20 76 "
-				+ "32 2E 36 2E 34"
-				+                "20 20 20 20 20 20 20 20 20 20 20 "
-				+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
-				+ HEX_SIXTYFOUR_SPACES);
-
-		RecordInputStream in = TestcaseRecordInputStream.create(data);
-
-		// bug 47001a - Not enough data (0) to read requested (1) bytes
-		WriteAccessRecord rec = new WriteAccessRecord(in);
-		assertEquals("Java Excel API v2.6.4", rec.getUsername());
-
-
-		byte[] expectedEncoding = HexRead.readFromString(""
-				+ "15 00 00 4A 61 76 61 20 45 78 63 65 6C 20 41 50 "
-				+ "49 20 76 32 2E 36 2E 34"
-				+                         "20 20 20 20 20 20 20 20 "
-				+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
-				+ HEX_SIXTYFOUR_SPACES);
-
-		confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
-	}
-
-	@Test
-	void testShortRecordWrittenByMSAccess() {
-		/*
-		 * Data taken from two example files
-		 * ex42564-21435.xls
-		 * bug_42794.xls (from bug 42794 attachment 20429)
-		 * In both cases, this data is found at offset 0x0C1C.
-		 */
-		byte[] data = HexRead.readFromString(""
-				+ "5C 00 39 00 "
-				+ "36 00 00 41 20 73 61 74 69 73 66 69 65 64 20 4D "
-				+ "69 63 72 6F 73 6F 66 74 20 4F 66 66 69 63 65 39 "
-				+ "20 55 73 65 72"
-				+                "20 20 20 20 20 20 20 20 20 20 20 "
-				+ "20 20 20 20 20 20 20 20 20");
-
-		RecordInputStream in = TestcaseRecordInputStream.create(data);
-		WriteAccessRecord rec = new WriteAccessRecord(in);
-		assertEquals("A satisfied Microsoft Office9 User", rec.getUsername());
-		byte[] expectedEncoding = HexRead.readFromString(""
-				+ "22 00 00 41 20 73 61 74 69 73 66 69 65 64 20 4D "
-				+ "69 63 72 6F 73 6F 66 74 20 4F 66 66 69 63 65 39 "
-				+ "20 55 73 65 72"
-				+                "20 20 20 20 20 20 20 20 20 20 20 "
-				+ HEX_SIXTYFOUR_SPACES);
+    private static final String HEX_SIXTYFOUR_SPACES = ""
+        + "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
+        + "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
+        + "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
+        + "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20";
+
+    @Test
+    void testMissingStringHeader_bug47001a() {
+        /*
+         * Data taken from offset 0x0224 in
+         * attachment 23468 from bugzilla 47001
+         */
+        byte[] data = HexRead.readFromString(""
+                + "5C 00 70 00 "
+                + "4A 61 76 61 20 45 78 63 65 6C 20 41 50 49 20 76 "
+                + "32 2E 36 2E 34"
+                +                "20 20 20 20 20 20 20 20 20 20 20 "
+                + "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
+                + HEX_SIXTYFOUR_SPACES);
+
+        RecordInputStream in = TestcaseRecordInputStream.create(data);
+
+        // bug 47001a - Not enough data (0) to read requested (1) bytes
+        WriteAccessRecord rec = new WriteAccessRecord(in);
+        assertEquals("Java Excel API v2.6.4", rec.getUsername());
+
+
+        byte[] expectedEncoding = HexRead.readFromString(""
+                + "15 00 00 4A 61 76 61 20 45 78 63 65 6C 20 41 50 "
+                + "49 20 76 32 2E 36 2E 34"
+                +                         "20 20 20 20 20 20 20 20 "
+                + "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
+                + HEX_SIXTYFOUR_SPACES);
+
+        confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
+    }
+
+    @Test
+    void testShortRecordWrittenByMSAccess() {
+        /*
+         * Data taken from two example files
+         * ex42564-21435.xls
+         * bug_42794.xls (from bug 42794 attachment 20429)
+         * In both cases, this data is found at offset 0x0C1C.
+         */
+        byte[] data = HexRead.readFromString(""
+                + "5C 00 39 00 "
+                + "36 00 00 41 20 73 61 74 69 73 66 69 65 64 20 4D "
+                + "69 63 72 6F 73 6F 66 74 20 4F 66 66 69 63 65 39 "
+                + "20 55 73 65 72"
+                +                "20 20 20 20 20 20 20 20 20 20 20 "
+                + "20 20 20 20 20 20 20 20 20");
+
+        RecordInputStream in = TestcaseRecordInputStream.create(data);
+        WriteAccessRecord rec = new WriteAccessRecord(in);
+        assertEquals("A satisfied Microsoft Office9 User", rec.getUsername());
+        byte[] expectedEncoding = HexRead.readFromString(""
+                + "22 00 00 41 20 73 61 74 69 73 66 69 65 64 20 4D "
+                + "69 63 72 6F 73 6F 66 74 20 4F 66 66 69 63 65 39 "
+                + "20 55 73 65 72"
+                +                "20 20 20 20 20 20 20 20 20 20 20 "
+                + HEX_SIXTYFOUR_SPACES);
 
-		confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
-	}
+        confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestcaseRecordInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestcaseRecordInputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestcaseRecordInputStream.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hssf/record/TestcaseRecordInputStream.java Sat May 22 20:56:44 2021
@@ -35,65 +35,65 @@ import org.apache.poi.util.LittleEndianI
  */
 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 LittleEndianInput createLittleEndian(byte[] data) {
-		return new LittleEndianByteArrayInputStream(data);
-
-	}
-	public static RecordInputStream create(int sid, byte[] data) {
-		return create(mergeDataAndSid(sid, data.length, data));
-	}
-	/**
-	 * First 4 bytes of {@code data} are assumed to be record identifier and length. The supplied
-	 * {@code data} 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;
-	}
-
-	public static byte[] mergeDataAndSid(int sid, int length, byte[] data) {
-	  byte[] result = new byte[data.length + 4];
-	  LittleEndian.putUShort(result, 0, sid);
-	  LittleEndian.putUShort(result, 2, length);
-	  System.arraycopy(data, 0, result, 4, data.length);
-	  return result;
-	}
-	/**
-	 * Confirms data sections are equal
-	 * @param expectedData - just raw data (without sid or size short ints)
-	 * @param actualRecordBytes this includes 4 prefix bytes (sid & size)
-	 */
-	public static void confirmRecordEncoding(int expectedSid, byte[] expectedData, byte[] actualRecordBytes) {
-		confirmRecordEncoding(null, expectedSid, expectedData, actualRecordBytes);
-	}
-	/**
-	 * Confirms data sections are equal
-	 * @param msgPrefix message prefix to be displayed in case of failure
-	 * @param expectedData - just raw data (without ushort sid, ushort size)
-	 * @param actualRecordBytes this includes 4 prefix bytes (sid & size)
-	 */
-	public static void confirmRecordEncoding(String msgPrefix, int expectedSid, byte[] expectedData, byte[] actualRecordBytes) {
-		int expectedDataSize = expectedData.length;
-		assertEquals(actualRecordBytes.length - 4, expectedDataSize, "Size of encode data mismatch");
-		assertEquals(expectedSid, LittleEndian.getShort(actualRecordBytes, 0));
-		assertEquals(expectedDataSize, LittleEndian.getShort(actualRecordBytes, 2));
-		assertArrayEquals(expectedData, cut(actualRecordBytes, 4));
-	}
-
-	public static byte[] cut( byte[] data, int fromInclusive ) {
-		return cut(data, fromInclusive, data.length);
-	}
-
-	public static byte[] cut(byte[] data, int fromInclusive, int toExclusive) {
-		return Arrays.copyOfRange(data, fromInclusive, toExclusive);
-	}
+    private TestcaseRecordInputStream() {
+        // no instances of this class
+    }
+
+    /**
+     * Prepends a mock record identifier to the supplied data and opens a record input stream
+     */
+    public static LittleEndianInput createLittleEndian(byte[] data) {
+        return new LittleEndianByteArrayInputStream(data);
+
+    }
+    public static RecordInputStream create(int sid, byte[] data) {
+        return create(mergeDataAndSid(sid, data.length, data));
+    }
+    /**
+     * First 4 bytes of {@code data} are assumed to be record identifier and length. The supplied
+     * {@code data} 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;
+    }
+
+    public static byte[] mergeDataAndSid(int sid, int length, byte[] data) {
+      byte[] result = new byte[data.length + 4];
+      LittleEndian.putUShort(result, 0, sid);
+      LittleEndian.putUShort(result, 2, length);
+      System.arraycopy(data, 0, result, 4, data.length);
+      return result;
+    }
+    /**
+     * Confirms data sections are equal
+     * @param expectedData - just raw data (without sid or size short ints)
+     * @param actualRecordBytes this includes 4 prefix bytes (sid & size)
+     */
+    public static void confirmRecordEncoding(int expectedSid, byte[] expectedData, byte[] actualRecordBytes) {
+        confirmRecordEncoding(null, expectedSid, expectedData, actualRecordBytes);
+    }
+    /**
+     * Confirms data sections are equal
+     * @param msgPrefix message prefix to be displayed in case of failure
+     * @param expectedData - just raw data (without ushort sid, ushort size)
+     * @param actualRecordBytes this includes 4 prefix bytes (sid & size)
+     */
+    public static void confirmRecordEncoding(String msgPrefix, int expectedSid, byte[] expectedData, byte[] actualRecordBytes) {
+        int expectedDataSize = expectedData.length;
+        assertEquals(actualRecordBytes.length - 4, expectedDataSize, "Size of encode data mismatch");
+        assertEquals(expectedSid, LittleEndian.getShort(actualRecordBytes, 0));
+        assertEquals(expectedDataSize, LittleEndian.getShort(actualRecordBytes, 2));
+        assertArrayEquals(expectedData, cut(actualRecordBytes, 4));
+    }
+
+    public static byte[] cut( byte[] data, int fromInclusive ) {
+        return cut(data, fromInclusive, data.length);
+    }
+
+    public static byte[] cut(byte[] data, int fromInclusive, int toExclusive) {
+        return Arrays.copyOfRange(data, fromInclusive, toExclusive);
+    }
 }



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