OSDN Git Service

Adjust for checkstyle warnings
[dictzip-java/dictzip-java.git] / dictzip-lib / src / test / java / org / dict / zip / DictZipFileUtilsTest.java
1 package org.dict.zip;
2
3 import org.junit.jupiter.api.Assertions;
4 import org.junit.jupiter.api.Test;
5
6 import java.io.IOException;
7
8 import static org.junit.jupiter.api.Assertions.assertTrue;
9
10 /**
11  * Test of DictZipFileUtils.
12  * @author Hiroshi Miura
13  */
14 public class DictZipFileUtilsTest {
15
16     /**
17      * Check dictzip inputstream.
18      * @throws Exception when fails.
19      */
20     @Test
21     public void testCheckDictZipInputStreamString() throws Exception {
22         String targetFile = this.getClass().getResource("/test.dict.dz").getFile();
23         Assertions.assertTrue(DictZipFileUtils.checkDictZipInputStream(targetFile));
24     }
25
26     /**
27      * Check dictzip input streasm which is not exist.
28      */
29     @Test
30     public void testCheckDictZipInputStreamStringNoExist() {
31         String targetFile = "false.dict.dz";
32         boolean result;
33         try {
34             DictZipFileUtils.checkDictZipInputStream(targetFile);
35             result = false;
36         } catch (IOException e) {
37             // expected.
38             result = true;
39         }
40         assertTrue(result);
41     }
42
43     /**
44      * Check dictzip input stream.
45      * @throws Exception when fails.
46      */
47     @Test
48     public void testCheckDictZipInputStream() throws Exception {
49         String targetFile = this.getClass().getResource("/test.dict.dz").getFile();
50         try (DictZipInputStream dzin = new DictZipInputStream(new
51                 RandomAccessInputStream(targetFile, "r"))) {
52             Assertions.assertTrue(DictZipFileUtils.checkDictZipInputStream(dzin));
53         }
54     }
55 }