aboutsummaryrefslogtreecommitdiffstats
path: root/tools/dicttool/tests
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-06-11 17:34:59 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-06-22 23:20:37 -0700
commitfec4769e0b5eb43e1fad795a986acb0af8bb8a8f (patch)
tree2d27483c3af75109bc1cf2af1587c1a138f85793 /tools/dicttool/tests
parent593fe9b0cfcd5ffd0a33e3260358b192997d8347 (diff)
downloadlatinime-fec4769e0b5eb43e1fad795a986acb0af8bb8a8f.tar.gz
latinime-fec4769e0b5eb43e1fad795a986acb0af8bb8a8f.tar.xz
latinime-fec4769e0b5eb43e1fad795a986acb0af8bb8a8f.zip
Refactor dicttool with try-with-resource
This CL must be checked in together with Idd7c744d0f. Change-Id: Ia0ff09a054c1852b39cdce22a4377108afb254e2
Diffstat (limited to 'tools/dicttool/tests')
-rw-r--r--tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java
index fccb654b0..0236a446d 100644
--- a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java
+++ b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java
@@ -62,13 +62,13 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase {
final File dst = File.createTempFile("testGetRawDict", ".tmp");
dst.deleteOnExit();
-
- final OutputStream out = Compress.getCompressedStream(
+ try (final OutputStream out = Compress.getCompressedStream(
Compress.getCompressedStream(
Compress.getCompressedStream(
- new BufferedOutputStream(new FileOutputStream(dst)))));
- final DictEncoder dictEncoder = new Ver2DictEncoder(out);
- dictEncoder.writeDictionary(dict, new FormatOptions(2, false));
+ new BufferedOutputStream(new FileOutputStream(dst)))))) {
+ final DictEncoder dictEncoder = new Ver2DictEncoder(out);
+ dictEncoder.writeDictionary(dict, new FormatOptions(2, false));
+ }
// Test for an actually compressed dictionary and its contents
final BinaryDictOffdeviceUtils.DecoderChainSpec decodeSpec =
@@ -96,11 +96,11 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase {
// Randomly create some 4k file containing garbage
final File dst = File.createTempFile("testGetRawDict", ".tmp");
dst.deleteOnExit();
- final OutputStream out = new BufferedOutputStream(new FileOutputStream(dst));
- for (int i = 0; i < 1024; ++i) {
- out.write(0x12345678);
+ try (final OutputStream out = new BufferedOutputStream(new FileOutputStream(dst))) {
+ for (int i = 0; i < 1024; ++i) {
+ out.write(0x12345678);
+ }
}
- out.close();
// Test that a random data file actually fails
assertNull("Wrongly identified data file",
@@ -108,12 +108,12 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase {
final File gzDst = File.createTempFile("testGetRawDict", ".tmp");
gzDst.deleteOnExit();
- final OutputStream gzOut =
- Compress.getCompressedStream(new BufferedOutputStream(new FileOutputStream(gzDst)));
- for (int i = 0; i < 1024; ++i) {
- gzOut.write(0x12345678);
+ try (final OutputStream gzOut = Compress.getCompressedStream(
+ new BufferedOutputStream(new FileOutputStream(gzDst)))) {
+ for (int i = 0; i < 1024; ++i) {
+ gzOut.write(0x12345678);
+ }
}
- gzOut.close();
// Test that a compressed random data file actually fails
assertNull("Wrongly identified data file",