Skip to content

Commit

Permalink
Test that the stream is resetted only once (#543)
Browse files Browse the repository at this point in the history
Test fails because the stream is resetted two times although
only one time called.
  • Loading branch information
dr0i committed Sep 27, 2024
1 parent 0ea6d23 commit f63b40e
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class MarcXmlEncoderTest {
private static final String RECORD_ID = "92005291";

private static StringBuilder resultCollector;
private static int resultCollectorsResetStreamCount;
private static MarcXmlEncoder encoder;

@Before
Expand All @@ -62,6 +63,11 @@ public void setUp() {
public void process(final String obj) {
resultCollector.append(obj);
}
@Override
public void resetStream() {
++resultCollectorsResetStreamCount;
}

});
resultCollector = new StringBuilder();
}
Expand Down Expand Up @@ -396,4 +402,19 @@ public void issue543_shouldNotWriteFooterWhenRecordIsEmpty() {
assertTrue(actual.isEmpty());
}

@Test
public void issue543_shouldOnlyResetStreamOnce() {
resultCollectorsResetStreamCount = 0;
encoder.resetStream();
assertEquals(resultCollectorsResetStreamCount, 1);
}

@Test
public void issue543_shouldOnlyResetStreamOnceUsingWrapper() {
resultCollectorsResetStreamCount = 0;
encoder.setEnsureCorrectMarc21Xml(true);
encoder.resetStream();
assertEquals(resultCollectorsResetStreamCount, 1);
}

}

0 comments on commit f63b40e

Please sign in to comment.