Skip to content

Commit

Permalink
[TEST] Fix test bug in ChainingInputStreamTests (elastic#72595)
Browse files Browse the repository at this point in the history
This fixes a test bug in ChainingInputStreamTests.testResetForDoubleMarkAnywhere.
The component input stream does not advance, and mockito rightfully intercepts two
invocations instead of a single one.
  • Loading branch information
albertzaharovits authored May 2, 2021
1 parent 79fc6ce commit 6b116df
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ InputStream nextComponent(InputStream currentComponentIn) throws IOException {
verify(lastCurrentIn).close();
}
verify(currentIn).reset();
final InputStream firstResetStream = currentIn;
// assert the "nextComponet" arg is the current component
nextComponentArg.set(currentIn);
// possibly skips over several components
Expand Down Expand Up @@ -991,7 +992,11 @@ InputStream nextComponent(InputStream currentComponentIn) throws IOException {
if (lastCurrentIn != currentIn) {
verify(lastCurrentIn).close();
}
verify(currentIn).reset();
if (currentIn != firstResetStream) {
verify(currentIn).reset();
} else {
verify(currentIn, times(2)).reset();
}
}

public void testMarkAfterResetNoMock() throws Exception {
Expand Down

0 comments on commit 6b116df

Please sign in to comment.