Use try-with-resources to fix a random failure seen on Java 12.
This commit is contained in:
parent
bd8e77d607
commit
a53127e3a5
|
@ -247,18 +247,26 @@ public class EmptyPropertiesTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSave() {
|
public void testSave() throws IOException {
|
||||||
final String comments = "Hello world!";
|
final String comments = "Hello world!";
|
||||||
// actual
|
// actual
|
||||||
final ByteArrayOutputStream actual = new ByteArrayOutputStream();
|
try (final ByteArrayOutputStream actual = new ByteArrayOutputStream()) {
|
||||||
PropertiesFactory.EMPTY_PROPERTIES.save(new PrintStream(actual), comments);
|
try (final PrintStream out = new PrintStream(actual)) {
|
||||||
// expected
|
PropertiesFactory.EMPTY_PROPERTIES.save(out, comments);
|
||||||
final ByteArrayOutputStream expected = new ByteArrayOutputStream();
|
}
|
||||||
PropertiesFactory.INSTANCE.createProperties().save(new PrintStream(expected), comments);
|
// expected
|
||||||
Assert.assertArrayEquals(expected.toByteArray(), actual.toByteArray());
|
try (final ByteArrayOutputStream expected = new ByteArrayOutputStream()) {
|
||||||
expected.reset();
|
try (final PrintStream out = new PrintStream(expected)) {
|
||||||
new Properties().save(new PrintStream(expected), comments);
|
PropertiesFactory.INSTANCE.createProperties().save(out, comments);
|
||||||
Assert.assertArrayEquals(expected.toByteArray(), actual.toByteArray());
|
}
|
||||||
|
Assert.assertArrayEquals(expected.toByteArray(), actual.toByteArray());
|
||||||
|
expected.reset();
|
||||||
|
try (final PrintStream out = new PrintStream(expected)) {
|
||||||
|
new Properties().save(out, comments);
|
||||||
|
}
|
||||||
|
Assert.assertArrayEquals(expected.toByteArray(), actual.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = UnsupportedOperationException.class)
|
@Test(expected = UnsupportedOperationException.class)
|
||||||
|
|
Loading…
Reference in New Issue