Use try-with-resources which also allows us to test close()
@@ -161,9 +161,8 @@ private void startWriter(final String name,
}
@Test
- public void testInputStream()
- throws Exception {
- final DemuxInputStream input = new DemuxInputStream();
+ public void testInputStream() throws Exception {
+ try (final DemuxInputStream input = new DemuxInputStream()) {
startReader(T1, DATA1, input);
startReader(T2, DATA2, input);
startReader(T3, DATA3, input);
@@ -177,11 +176,11 @@ public void testInputStream()
assertEquals(DATA3, getInput(T3), "Data3");
assertEquals(DATA4, getInput(T4), "Data4");
}
+ }
@Test
- public void testOutputStream()
- throws Exception {
- final DemuxOutputStream output = new DemuxOutputStream();
+ public void testOutputStream() throws Exception {
+ try (final DemuxOutputStream output = new DemuxOutputStream()) {
startWriter(T1, DATA1, output);
startWriter(T2, DATA2, output);
startWriter(T3, DATA3, output);
@@ -196,4 +195,5 @@ public void testOutputStream()
assertEquals(DATA4, getOutput(T4), "Data4");
}
}
+}
