Fix test failures on Windows
Since the move to JUnit 5, a number of tests were failing on Windows. The majority were failing due to open file handles preventing the clean up of the tests' temporary directory. This commit addresses these failures by updating the tests to close JarFiles, InputStreams, OutputStreams etc. A change has also been made to CachingOperationInvokerTests to make a flakey test more robust. Due to System.currentTimeMillis() being less precise on Windows than it is on *nix platforms, the test could fail as it would not sleep for long enough for the TTL period to have expired.
This commit is contained in:
@@ -18,6 +18,7 @@ package sample.parent.consumer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -94,7 +95,9 @@ class SampleIntegrationParentApplicationTests {
|
||||
private String readResources(Resource[] resources) throws IOException {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Resource resource : resources) {
|
||||
builder.append(new String(StreamUtils.copyToByteArray(resource.getInputStream())));
|
||||
try (InputStream input = resource.getInputStream()) {
|
||||
builder.append(new String(StreamUtils.copyToByteArray(input)));
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user