@@ -2125,7 +2125,7 @@ void createWriteRead() throws IOException {
2125
2125
// Check the header has the right points in it
2126
2126
assertEquals (1 , header .getBATCount ());
2127
2127
assertEquals (1 , header .getBATArray ()[0 ]);
2128
- assertEquals (2 , header .getPropertyCount ());
2128
+ assertEquals (0 , header .getPropertyCount ());
2129
2129
assertEquals (0 , header .getPropertyStart ());
2130
2130
assertEquals (1 , header .getSBATCount ());
2131
2131
assertEquals (21 , header .getSBATStart ());
@@ -2236,7 +2236,7 @@ void addBeforeWrite() throws IOException {
2236
2236
// Will have fat then properties stream
2237
2237
assertEquals (1 , hdr .getBATCount ());
2238
2238
assertEquals (1 , hdr .getBATArray ()[0 ]);
2239
- assertEquals (1 , hdr .getPropertyCount ());
2239
+ assertEquals (0 , hdr .getPropertyCount ());
2240
2240
assertEquals (0 , hdr .getPropertyStart ());
2241
2241
assertEquals (POIFSConstants .END_OF_CHAIN , hdr .getSBATStart ());
2242
2242
assertEquals (POIFSConstants .END_OF_CHAIN , hdr .getXBATIndex ());
@@ -2295,7 +2295,7 @@ void addBeforeWrite() throws IOException {
2295
2295
assertEquals (1 , hdr .getBATCount ());
2296
2296
assertEquals (1 , hdr .getBATArray ()[0 ]);
2297
2297
assertEquals (2 , hdr .getSBATStart ());
2298
- assertEquals (2 , hdr .getPropertyCount ());
2298
+ assertEquals (0 , hdr .getPropertyCount ());
2299
2299
assertEquals (0 , hdr .getPropertyStart ());
2300
2300
assertEquals (POIFSConstants .END_OF_CHAIN , hdr .getXBATIndex ());
2301
2301
@@ -2494,6 +2494,38 @@ void writeZeroLengthEntries() throws IOException {
2494
2494
}
2495
2495
}
2496
2496
2497
+ /**
2498
+ * Test that the property count is always 0 when writing files with a block size of 512 bytes.
2499
+ */
2500
+ @ Test
2501
+ void testWritePropertyCount512 () throws Exception {
2502
+ try (POIFSFileSystem fs = new POIFSFileSystem (_inst .openResourceAsStream ("BlockSize512.zvi" ))) {
2503
+ assertEquals (0 , fs .getHeaderBlock ().getPropertyCount (), "Property count" );
2504
+
2505
+ for (int i = 1 ; i <= 100 ; i ++) {
2506
+ fs .getRoot ().createOrUpdateDocument ("Entry " + i , new ByteArrayInputStream (new byte [8192 ]));
2507
+ }
2508
+
2509
+ assertEquals (0 , writeOutAndReadBack (fs ).getHeaderBlock ().getPropertyCount (), "Property count" );
2510
+ }
2511
+ }
2512
+
2513
+ /**
2514
+ * Test that the property count is updated when writing files with a block size of 4096 bytes.
2515
+ */
2516
+ @ Test
2517
+ void testWritePropertyCount4096 () throws Exception {
2518
+ try (POIFSFileSystem fs = new POIFSFileSystem (_inst .openResourceAsStream ("BlockSize4096.zvi" ))) {
2519
+ assertEquals (0 , fs .getHeaderBlock ().getPropertyCount (), "Property count" );
2520
+
2521
+ for (int i = 1 ; i <= 100 ; i ++) {
2522
+ fs .getRoot ().createOrUpdateDocument ("Entry " + i , new ByteArrayInputStream (new byte [8192 ]));
2523
+ }
2524
+
2525
+ assertEquals (5 , writeOutAndReadBack (fs ).getHeaderBlock ().getPropertyCount (), "Property count" );
2526
+ }
2527
+ }
2528
+
2497
2529
/**
2498
2530
* Test that we can read a file with POIFS, create a new POIFS instance,
2499
2531
* write it out, read it with POIFS, and see the original data
0 commit comments