@@ -80,6 +80,7 @@ public void testAboveThreshold(final int initialBufferSize) throws IOException {
8080 dfos .close ();
8181 assertFalse (dfos .isInMemory ());
8282 assertNull (dfos .getData ());
83+ assertEquals (testFile .length (), dfos .getByteCount ());
8384
8485 verifyResultFile (testFile );
8586
@@ -107,6 +108,7 @@ public void testAboveThresholdGetInputStream(final int initialBufferSize, final
107108 dfos .write (testBytes , 0 , testBytes .length );
108109 dfos .close ();
109110 assertFalse (dfos .isInMemory ());
111+ assertEquals (testFile .length (), dfos .getByteCount ());
110112
111113 try (InputStream is = dfos .toInputStream ()) {
112114 assertArrayEquals (testBytes , IOUtils .toByteArray (is ));
@@ -131,6 +133,7 @@ public void testAtThreshold(final int initialBufferSize) throws IOException {
131133 dfos .write (testBytes , 0 , testBytes .length );
132134 dfos .close ();
133135 assertTrue (dfos .isInMemory ());
136+ assertEquals (testBytes .length , dfos .getByteCount ());
134137
135138 final byte [] resultBytes = dfos .getData ();
136139 assertEquals (testBytes .length , resultBytes .length );
@@ -153,6 +156,7 @@ public void testBelowThreshold(final int initialBufferSize) throws IOException {
153156 dfos .write (testBytes , 0 , testBytes .length );
154157 dfos .close ();
155158 assertTrue (dfos .isInMemory ());
159+ assertEquals (testBytes .length , dfos .getByteCount ());
156160
157161 final byte [] resultBytes = dfos .getData ();
158162 assertEquals (testBytes .length , resultBytes .length );
@@ -175,6 +179,7 @@ public void testBelowThresholdGetInputStream(final int initialBufferSize) throws
175179 dfos .write (testBytes , 0 , testBytes .length );
176180 dfos .close ();
177181 assertTrue (dfos .isInMemory ());
182+ assertEquals (testBytes .length , dfos .getByteCount ());
178183
179184 try (InputStream is = dfos .toInputStream ()) {
180185 assertArrayEquals (testBytes , IOUtils .toByteArray (is ));
@@ -205,6 +210,7 @@ public void testTempFileAboveThreshold(final int initialBufferSize) throws IOExc
205210 dfos .write (testBytes , 0 , testBytes .length );
206211 dfos .close ();
207212 assertFalse (dfos .isInMemory ());
213+ assertEquals (testBytes .length , dfos .getByteCount ());
208214 assertNull (dfos .getData ());
209215 assertNotNull (dfos .getFile (), "Check file not null" );
210216 assertTrue (dfos .getFile ().exists (), "Check file exists" );
@@ -244,6 +250,7 @@ public void testTempFileAboveThresholdPrefixOnly(final int initialBufferSize) th
244250 dfos .close ();
245251 assertFalse (dfos .isInMemory ());
246252 assertNull (dfos .getData ());
253+ assertEquals (testBytes .length , dfos .getByteCount ());
247254 assertNotNull (dfos .getFile (), "Check file not null" );
248255 assertTrue (dfos .getFile ().exists (), "Check file exists" );
249256 assertTrue (dfos .getFile ().getName ().startsWith (prefix ), "Check prefix" );
@@ -272,6 +279,7 @@ public void testTempFileBelowThreshold(final int initialBufferSize) throws IOExc
272279 dfos .write (testBytes , 0 , testBytes .length );
273280 dfos .close ();
274281 assertTrue (dfos .isInMemory ());
282+ assertEquals (testBytes .length , dfos .getByteCount ());
275283 assertNull (dfos .getFile (), "Check file is null-B" );
276284 }
277285
@@ -315,6 +323,7 @@ public void testThresholdReached(final int initialBufferSize) throws IOException
315323 dfos .close ();
316324 assertFalse (dfos .isInMemory ());
317325 assertNull (dfos .getData ());
326+ assertEquals (testBytes .length , dfos .getByteCount ());
318327
319328 verifyResultFile (testFile );
320329
@@ -338,6 +347,7 @@ public void testWriteToLarge(final int initialBufferSize) throws IOException {
338347
339348 assertTrue (testFile .exists ());
340349 assertFalse (dfos .isInMemory ());
350+ assertEquals (testBytes .length , dfos .getByteCount ());
341351
342352 assertThrows (IOException .class , () -> dfos .writeTo (baos ));
343353
@@ -367,6 +377,7 @@ public void testWriteToLargeCtor(final int initialBufferSize) throws IOException
367377 assertFalse (dfos .isInMemory ());
368378
369379 assertThrows (IOException .class , () -> dfos .writeTo (baos ));
380+ assertEquals (testBytes .length , dfos .getByteCount ());
370381
371382 dfos .close ();
372383 dfos .writeTo (baos );
@@ -395,6 +406,7 @@ public void testWriteToSmall(final int initialBufferSize) throws IOException {
395406 assertTrue (dfos .isInMemory ());
396407
397408 assertThrows (IOException .class , () -> dfos .writeTo (baos ));
409+ assertEquals (testBytes .length , dfos .getByteCount ());
398410
399411 dfos .close ();
400412 dfos .writeTo (baos );
0 commit comments