@@ -109,13 +109,26 @@ private void test_write_insensitive_policy(boolean compress) throws Exception {
109109 Mockito .verify (policy , Mockito .never ()).acceptWrite (Mockito .anyLong ());
110110
111111 // Trigger rotation.
112+ LOGGER .trace ("triggering rotation" );
112113 stream .rotate (policy , now );
113114
115+ // Close the stream.
116+ LOGGER .trace ("closing stream" );
117+ stream .close ();
118+
114119 // Verify the rotation trigger.
115120 inOrder
116121 .verify (callback )
117122 .onTrigger (Mockito .same (policy ), Mockito .same (now ));
118123
124+ // Verify the rotation file close.
125+ inOrder
126+ .verify (callback )
127+ .onClose (
128+ Mockito .same (policy ),
129+ Mockito .same (now ),
130+ Mockito .any (OutputStream .class ));
131+
119132 // Verify the rotation file open.
120133 inOrder
121134 .verify (callback )
@@ -137,6 +150,16 @@ private void test_write_insensitive_policy(boolean compress) throws Exception {
137150 assertThat (rotatedFileLength ).isEqualTo (expectedRotatedFileLength );
138151 assertThat (file .length ()).isEqualTo (0 );
139152
153+ // Verify the stream close. (We cannot use InOrder here since we don't
154+ // know whether the rotation background task or the user-invoked close()
155+ // will finish earlier.)
156+ Mockito
157+ .verify (callback )
158+ .onClose (
159+ Mockito .isNull (),
160+ Mockito .any (Instant .class ),
161+ Mockito .any (OutputStream .class ));
162+
140163 // Verify no more interactions.
141164 Mockito .verifyNoMoreInteractions (callback );
142165 Mockito .verifyNoMoreInteractions (policy );
@@ -209,6 +232,14 @@ public void test_write_sensitive_policy() throws Exception {
209232 Mockito .same (policy ),
210233 Mockito .any (Instant .class ));
211234
235+ // Verify the rotation file close.
236+ callbackInOrder
237+ .verify (callback )
238+ .onClose (
239+ Mockito .same (policy ),
240+ Mockito .any (Instant .class ),
241+ Mockito .any (OutputStream .class ));
242+
212243 // Verify the rotation file open.
213244 callbackInOrder
214245 .verify (callback )
@@ -375,7 +406,7 @@ public void test_adding_file_header() throws IOException {
375406 stream .write (payload2 );
376407
377408 // Close the stream.
378- LOGGER .trace ("closing" );
409+ LOGGER .trace ("closing stream " );
379410 stream .close ();
380411
381412 // Verify the rotation trigger.
0 commit comments