LongObjectIdTest: Open OutputStreamWriter in try-with-resource
Change-Id: Ic7c2109204f94c70b933191b46d4a8f2c16a1533 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
ee4dd50b3f
commit
658c7c179d
|
@ -392,9 +392,10 @@ public void testCopyToOutputStream() throws IOException {
|
||||||
public void testCopyToWriter() throws IOException {
|
public void testCopyToWriter() throws IOException {
|
||||||
AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
|
AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
|
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
|
||||||
OutputStreamWriter w = new OutputStreamWriter(os, Constants.CHARSET);
|
try (OutputStreamWriter w = new OutputStreamWriter(os,
|
||||||
id1.copyTo(w);
|
Constants.CHARSET)) {
|
||||||
w.close();
|
id1.copyTo(w);
|
||||||
|
}
|
||||||
assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
|
assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,10 +403,11 @@ public void testCopyToWriter() throws IOException {
|
||||||
public void testCopyToWriterWithBuf() throws IOException {
|
public void testCopyToWriterWithBuf() throws IOException {
|
||||||
AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
|
AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
|
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
|
||||||
OutputStreamWriter w = new OutputStreamWriter(os, Constants.CHARSET);
|
try (OutputStreamWriter w = new OutputStreamWriter(os,
|
||||||
char[] buf = new char[64];
|
Constants.CHARSET)) {
|
||||||
id1.copyTo(buf, w);
|
char[] buf = new char[64];
|
||||||
w.close();
|
id1.copyTo(buf, w);
|
||||||
|
}
|
||||||
assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
|
assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue