Skip to content

Commit

Permalink
Merge pull request #480 from metafacture/inputUsed
Browse files Browse the repository at this point in the history
Reset `inputUsed` after processing to fix reusing opener
  • Loading branch information
fsteeg authored Mar 10, 2023
2 parents 3d01453 + dc636b8 commit 59ea7e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ public void process(final String input) {
catch (final IOException e) {
throw new MetafactureException(e);
}
finally {
inputUsed = false;
}
}

private String getInput(final String input, final String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

import static org.mockito.Mockito.times;

import java.io.IOException;
import java.io.Reader;
import java.util.Arrays;
Expand Down Expand Up @@ -318,11 +320,15 @@ private void shouldPerformRequest(final String input, final HttpOpener.Method me
WireMock.stubFor(stub);

opener.process(String.format(input, baseUrl));

// use the opener a second time in a workflow:
opener.process(String.format(input, baseUrl));

opener.closeStream();

WireMock.verify(request);

Mockito.verify(receiver).process(processedObject.capture());
Mockito.verify(receiver, times(2)).process(processedObject.capture());
Assert.assertEquals(responseBody, ResourceUtil.readAll(processedObject.getValue()));
}

Expand Down

0 comments on commit 59ea7e4

Please sign in to comment.