OSDN Git Service

Fix checkstyle warnings
authorHiroshi Miura <miurahr@linux.com>
Wed, 14 Aug 2019 02:38:12 +0000 (11:38 +0900)
committerHiroshi Miura <miurahr@linux.com>
Wed, 14 Aug 2019 03:16:53 +0000 (12:16 +0900)
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
config/checkstyle/checkstyle.xml
dictzip-cli/src/test/java/org/dict/zip/cli/CommandLineTest.java
dictzip-cli/src/test/java/org/dict/zip/cli/DictDataTest.java
dictzip-lib/src/test/java/org/dict/zip/DictZipFileUtilsTest.java
dictzip-lib/src/test/java/org/dict/zip/DictZipHeaderTest.java
dictzip-lib/src/test/java/org/dict/zip/DictZipInputStreamTest.java
dictzip-lib/src/test/java/org/dict/zip/DictZipOutputStreamTest.java
dictzip-lib/src/test/java/org/dict/zip/RandomAccessInputStreamTest.java

index a9b64e0..f115844 100644 (file)
         <!-- Checks for Size Violations.                    -->
         <!-- See http://checkstyle.sf.net/config_sizes.html -->
         <module name="LineLength">
-            <property name="max" value="100"/>
+            <property name="max" value="135"/>
         </module>
 
         <module name="MethodLength"/>
index 5012562..238e831 100644 (file)
@@ -5,62 +5,85 @@ import org.testng.annotations.Test;
 
 import java.util.ArrayList;
 
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
 
 /**
  * Created by miurahr on 16/04/09.
  */
 public class CommandLineTest {
+    /**
+     * Test Parser help.
+     */
     @Test
-    public void testParse_help() throws Exception {
+    public void testParseHelp() {
         final String[] argv = new String[1];
         argv[0] = "-h";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 1);
     }
 
+    /**
+     * Test parser helpLong.
+     */
     @Test
-    public void testParse_helpLong() throws Exception {
+    public void testParseHelpLong() {
         final String[] argv = new String[1];
         argv[0] = "--help";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 1);
     }
 
+    /**
+     * Test parser version.
+     */
     @Test
-    public void testParse_version() throws Exception {
+    public void testParseVersion() {
         final String[] argv = new String[1];
         argv[0] = "-v";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 1);
     }
 
+    /**
+     * Test parser VersionLong.
+     */
     @Test
-    public void testParse_versionLong() throws Exception {
+    public void testParseVersionLong() {
         final String[] argv = new String[1];
         argv[0] = "--version";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 1);
     }
 
+    /**
+     * Test parser License.
+     */
     @Test
-    public void testParse_license() throws Exception {
+    public void testParseLicense() {
         final String[] argv = new String[1];
         argv[0] = "-L";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 1);
     }
 
+    /**
+     * Test parser License long.
+     */
     @Test
-    public void testParse_licenseLong() throws Exception {
+    public void testParseLicenseLong() {
         final String[] argv = new String[1];
         argv[0] = "--license";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 1);
     }
 
+    /**
+     * Test parser Keep.
+     */
     @Test
-    public void testParse_keep() throws Exception {
+    public void testParseKeep() {
         final String[] argv = new String[1];
         argv[0] = "-k";
         CommandLine commandLine = new CommandLine();
@@ -68,8 +91,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isKeep());
     }
 
+    /**
+     * Test parser KeepLong.
+     */
     @Test
-    public void testParse_keepLong() throws Exception {
+    public void testParseKeepLong() {
         final String[] argv = new String[1];
         argv[0] = "--keep";
         CommandLine commandLine = new CommandLine();
@@ -77,8 +103,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isKeep());
     }
 
+    /**
+     * Test parser stdout.
+     */
     @Test
-    public void testParse_stdout() throws Exception {
+    public void testParseStdout() {
         final String[] argv = new String[1];
         argv[0] = "-c";
         CommandLine commandLine = new CommandLine();
@@ -86,8 +115,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isStdout());
     }
 
+    /**
+     * Test parser stdout long.
+     */
     @Test
-    public void testParse_stdoutLong() throws Exception {
+    public void testParseStdoutLong() {
         final String[] argv = new String[1];
         argv[0] = "--stdout";
         CommandLine commandLine = new CommandLine();
@@ -95,8 +127,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isStdout());
     }
 
+    /**
+     * Test parser force.
+     */
     @Test
-    public void testParse_force() throws Exception {
+    public void testParseForce() {
         final String[] argv = new String[1];
         argv[0] = "-f";
         CommandLine commandLine = new CommandLine();
@@ -104,8 +139,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isForce());
     }
 
+    /**
+     * Test parser force long.
+     */
     @Test
-    public void testParse_forceLong() throws Exception {
+    public void testParseForceLong() {
         final String[] argv = new String[1];
         argv[0] = "--force";
         CommandLine commandLine = new CommandLine();
@@ -113,8 +151,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isForce());
     }
 
+    /**
+     * Test parser decompresss.
+     */
     @Test
-    public void testParse_decompress() throws Exception {
+    public void testParseDecompress() {
         final String[] argv = new String[1];
         argv[0] = "-d";
         CommandLine commandLine = new CommandLine();
@@ -122,8 +163,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isDecompress());
     }
 
+    /**
+     * Test parser decompress long.
+     */
     @Test
-    public void testParse_decompressLong() throws Exception {
+    public void testParseDecompressLong() {
         final String[] argv = new String[1];
         argv[0] = "--decompress";
         CommandLine commandLine = new CommandLine();
@@ -131,8 +175,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isDecompress());
     }
 
+    /**
+     * Test parser List.
+     */
     @Test
-    public void testParse_list() throws Exception {
+    public void testParseList() {
         final String[] argv = new String[1];
         argv[0] = "-l";
         CommandLine commandLine = new CommandLine();
@@ -140,8 +187,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isList());
     }
 
+    /**
+     * Test parser list long version.
+     */
     @Test
-    public void testParse_listLong() throws Exception {
+    public void testParseListLong() {
         final String[] argv = new String[1];
         argv[0] = "--list";
         CommandLine commandLine = new CommandLine();
@@ -149,8 +199,11 @@ public class CommandLineTest {
         assertTrue(commandLine.options.isList());
     }
 
+    /**
+     * test parsre leve fast.
+     */
     @Test
-    public void testParse_levelFast() throws Exception {
+    public void testParseLevelFast() {
         final String[] argv = new String[1];
         argv[0] = "-1";
         CommandLine commandLine = new CommandLine();
@@ -158,8 +211,11 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getLevel(), DictZipHeader.CompressionLevel.BEST_SPEED);
     }
 
+    /**
+     * Test parser level fast long version.
+     */
     @Test
-    public void testParse_levelFastLong() throws Exception {
+    public void testParseLevelFastLong() {
         final String[] argv = new String[1];
         argv[0] = "--fast";
         CommandLine commandLine = new CommandLine();
@@ -167,8 +223,11 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getLevel(), DictZipHeader.CompressionLevel.BEST_SPEED);
     }
 
+    /**
+     * Test parser Level best.
+     */
     @Test
-    public void testParse_levelBest() throws Exception {
+    public void testParseLevelBest() {
         final String[] argv = new String[1];
         argv[0] = "-9";
         CommandLine commandLine = new CommandLine();
@@ -176,8 +235,11 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getLevel(), DictZipHeader.CompressionLevel.BEST_COMPRESSION);
     }
 
+    /**
+     * Test parser Level best long version.
+     */
     @Test
-    public void testParse_levelBestLong() throws Exception {
+    public void testParseLevelBestLong() {
         final String[] argv = new String[1];
         argv[0] = "--best";
         CommandLine commandLine = new CommandLine();
@@ -185,8 +247,11 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getLevel(), DictZipHeader.CompressionLevel.BEST_COMPRESSION);
     }
 
+    /**
+     * test parser level default.
+     */
     @Test
-    public void testParse_levelDefault() throws Exception {
+    public void testParseLevelDefault() {
         final String[] argv = new String[1];
         argv[0] = "-6";
         CommandLine commandLine = new CommandLine();
@@ -194,17 +259,29 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getLevel(), DictZipHeader.CompressionLevel.DEFAULT_COMPRESSION);
     }
 
+    /**
+     * test parser target.
+     */
     @Test
-    public void testParse_target() throws Exception {
+    public void testParseTarget() {
         final String[] argv = new String[1];
         argv[0] = "target_filename";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 0);
-        assertTrue(commandLine.getTargetFiles().equals(new ArrayList<String> (){{add("target_filename");}}));
+        assertTrue(commandLine.getTargetFiles().equals(new ArrayList<String>() {
+            {
+                add("target_filename");
+            }
+        }
+        ));
     }
 
+    /**
+     * Test parser number hex.
+     * @throws NumberFormatException when giving non-number argument.
+     */
     @Test
-    public void testParseNumber_hex() throws NumberFormatException {
+    public void testParseNumberHex() throws NumberFormatException {
         final String[] argv = new String[1];
         argv[0] = "-s 0x123A";
         CommandLine commandLine = new CommandLine();
@@ -212,8 +289,12 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getStart(), 0x123A);
     }
 
+    /**
+     * Test parser Number octet.
+     * @throws NumberFormatException when giving non-number argument.
+     */
     @Test
-    public void testParseNumber_oct() throws NumberFormatException {
+    public void testParseNumberOct() throws NumberFormatException {
         final String[] argv = new String[1];
         argv[0] = "-s 01237";
         CommandLine commandLine = new CommandLine();
@@ -221,8 +302,12 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getStart(), 671);
     }
 
+    /**
+     * Test parser number decimal.
+     * @throws NumberFormatException when giving non-number argument.
+     */
     @Test
-    public void testParseNumber_dec() throws NumberFormatException {
+    public void testParseNumberDec() throws NumberFormatException {
         final String[] argv = new String[1];
         argv[0] = "-s 1239";
         CommandLine commandLine = new CommandLine();
@@ -230,8 +315,12 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getStart(), 1239);
     }
 
+    /**
+     * Test parser size.
+     * @throws NumberFormatException when giving non-number argument.
+     */
     @Test
-    public void testParse_size() throws NumberFormatException {
+    public void testParseSize() throws NumberFormatException {
         final String[] argv = new String[1];
         argv[0] = "-e 1239";
         CommandLine commandLine = new CommandLine();
@@ -239,28 +328,39 @@ public class CommandLineTest {
         assertEquals(commandLine.options.getSize(), 1239);
     }
 
-
+    /**
+     * Test parser start bad number.
+     * @throws NumberFormatException when giving bad number.
+     */
     @Test
-    public void testParse_start_badnum() throws NumberFormatException {
+    public void testParseStartBadnum() throws NumberFormatException {
         final String[] argv = new String[1];
         argv[0] = "-s 123A";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 2);
     }
 
+    /**
+     * Test parser start badnum octet.
+     * @throws NumberFormatException when giving bad number.
+     */
     @Test
-    public void testParse_start_badnumOct() throws NumberFormatException {
+    public void testParseStartBadnumOct() throws NumberFormatException {
         final String[] argv = new String[1];
         argv[0] = "-s 0Q23A";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 2);
     }
 
+    /**
+     * Test parser start badnum hex.
+     * @throws NumberFormatException when giving bad number.
+     */
     @Test
-    public void testParse_start_badnumHex() throws NumberFormatException {
+    public void testParseStartBadnumHex() throws NumberFormatException {
         final String[] argv = new String[1];
         argv[0] = "-s 0xQ23A";
         CommandLine commandLine = new CommandLine();
         assertEquals(commandLine.parse(argv), 2);
     }
-}
\ No newline at end of file
+}
index 619cc11..17d509f 100644 (file)
@@ -22,12 +22,8 @@ package org.dict.zip.cli;
 
 import static org.testng.Assert.assertTrue;
 
-import java.io.BufferedInputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
 import java.net.URL;
-import java.util.Arrays;
 
 import static tokyo.northside.io.FileUtils2.contentEquals;
 import org.dict.zip.DictZipHeader;
@@ -41,7 +37,7 @@ import org.testng.annotations.Test;
  */
 public class DictDataTest {
     /**
-     * Test of printHeader method, of class DictData
+     * Test of printHeader method, of class DictData.
      * @throws java.lang.Exception if file operation failed.
      */
     @Test
@@ -75,7 +71,7 @@ public class DictDataTest {
      * @throws java.lang.Exception if file operation failed.
      */
     @Test
-    public void testDoZip_best() throws Exception {
+    public void testDoZipBest() throws Exception {
         System.out.println("doZip_best");
         String testFile = this.getClass().getResource("/test_dozip.dict").getFile();
         String zippedFile = testFile + "_best.dz";
@@ -93,7 +89,7 @@ public class DictDataTest {
      * @throws java.lang.Exception if file operation failed.
      */
     @Test
-    public void testDoZip_fast() throws Exception {
+    public void testDoZipFast() throws Exception {
         System.out.println("doZip_fast");
         String testFile = this.getClass().getResource("/test_dozip.dict").getFile();
         String zippedFile = testFile + "_fast.dz";
index 7b110d3..33f5e91 100644 (file)
@@ -1,3 +1,39 @@
+/*
+ * DictZip Library test.
+ *
+ * Copyright (C) 2016,2019 Hiroshi Miura
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Linking this library statically or dynamically with other modules is
+ * making a combined work based on this library.  Thus, the terms and
+ * conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on this library.  If you modify this library, you may extend
+ * this exception to your version of the library, but you are not
+ * obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
 package org.dict.zip;
 
 import org.testng.annotations.Test;
@@ -5,14 +41,18 @@ import org.testng.annotations.Test;
 import java.io.File;
 import java.io.IOException;
 
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
 import static tokyo.northside.io.FileUtils2.contentEquals;
 
-import static org.testng.Assert.*;
-
 /**
  * Created by Hiroshi Miura on 16/04/09.
  */
 public class DictZipFileUtilsTest {
+    /**
+     * Check equals two file contentss.
+     * @throws Exception when fails to open.
+     */
     @Test
     public void testContentEquals() throws Exception {
         System.out.println("isFileBinaryEquals");
@@ -21,47 +61,71 @@ public class DictZipFileUtilsTest {
         assertTrue(contentEquals(firstFile, secondFile));
     }
 
+    /**
+     * Check equals two file paths which is canonical path.
+     * @throws Exception when fails to open.
+     */
     @Test
-    public void testContentEquals_sameCanonicalPath() throws Exception {
+    public void testContentEqualsSameCanonicalPath() throws Exception {
         System.out.println("isFileBinaryEquals with same canonical path");
         File firstFile = new File(this.getClass().getResource("/test_util.txt").getFile());
         File secondFile = new File(this.getClass().getResource("/test_util.txt").getFile());
         assertTrue(contentEquals(firstFile, secondFile));
     }
 
+    /**
+     * Check not equals two file contents.
+     * @throws Exception when fails to open.
+     */
     @Test
-    public void testContentEquals_false() throws Exception {
+    public void testContentEqualsFalse() throws Exception {
         System.out.println("isFileBinaryEquals_false");
         File firstFile = new File(this.getClass().getResource("/test_util.txt").getFile());
         File secondFile = new File(this.getClass().getResource("/test_util2.txt").getFile());
         assertFalse(contentEquals(firstFile, secondFile));
     }
 
+    /**
+     * Check equals tow files content with range.
+     * @throws Exception when fails to open.
+     */
     @Test
-    public void testContentEquals_range() throws Exception {
+    public void testContentEqualsRange() throws Exception {
         System.out.println("isFileBinaryEquals_range");
         File firstFile = new File(this.getClass().getResource("/test_util.txt").getFile());
         File secondFile = new File(this.getClass().getResource("/test_util2.txt").getFile());
         assertTrue(contentEquals(firstFile, secondFile, 10, 64));
     }
 
+    /**
+     * Check not equals two file contents with range.
+     * @throws Exception when fails to open.
+     */
     @Test
-    public void testContentEquals_range_false() throws Exception {
+    public void testContentEqualsRangeFalse() throws Exception {
         System.out.println("isFileBinaryEquals_range_false");
         File firstFile = new File(this.getClass().getResource("/test_util.txt").getFile());
         File secondFile = new File(this.getClass().getResource("/test_util2.txt").getFile());
         assertFalse(contentEquals(firstFile, secondFile, 0, 64));
     }
 
+    /**
+     * Check dictzip inputstream.
+     * @throws Exception when fails.
+     */
     @Test
-    public void testCheckDictZipInputStream_string() throws Exception {
+    public void testCheckDictZipInputStreamString() throws Exception {
         System.out.println("checkDictZipInputStream_string");
         String targetFile = this.getClass().getResource("/test.dict.dz").getFile();
         assertTrue(DictZipFileUtils.checkDictZipInputStream(targetFile));
     }
 
+    /**
+     * Check dictzip input streasm which is not exist.
+     * @throws Exception when fails.
+     */
     @Test
-    public void testCheckDictZipInputStream_stringNoExist() throws Exception {
+    public void testCheckDictZipInputStreamStringNoExist() throws Exception {
         System.out.println("checkDictZipInputStream_string");
         String targetFile = "false.dict.dz";
         boolean result;
@@ -75,6 +139,10 @@ public class DictZipFileUtilsTest {
         assertTrue(result);
     }
 
+    /**
+     * Check dictzip input stream.
+     * @throws Exception when fails.
+     */
     @Test
     public void testCheckDictZipInputStream() throws Exception {
         System.out.println("checkDictZipInputStream");
index 5e73d9b..9061b29 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DictZip Library test.
  *
- * Copyright (C) 2016 Hiroshi Miura
+ * Copyright (C) 2016,2019 Hiroshi Miura
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -36,7 +36,6 @@
  */
 package org.dict.zip;
 
-import static org.testng.Assert.*;
 import org.testng.annotations.Test;
 
 import java.io.File;
@@ -45,6 +44,8 @@ import java.io.IOException;
 
 import org.dict.zip.DictZipHeader.CompressionLevel;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
 import static tokyo.northside.io.FileUtils2.contentEquals;
 
 
@@ -55,13 +56,9 @@ import static tokyo.northside.io.FileUtils2.contentEquals;
 public class DictZipHeaderTest {
 
     private String toStringExpResult() {
-        return "\nHeader length = 49" +
-                "\nSubfield ID = RA" +
-                "\nSubfield length = 20" +
-                "\nSubfield version = 1" +
-                "\nChunk length = 58315" +
-                "\nNumber of chunks = 7" +
-                "\nLength of member = 136856";
+        return "\nHeader length = 49" + "\nSubfield ID = RA" + "\nSubfield length = 20"
+               + "\nSubfield version = 1" + "\nChunk length = 58315" + "\nNumber of chunks = 7"
+               + "\nLength of member = 136856";
     }
 
     /**
@@ -70,7 +67,7 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReadHeader_String() throws Exception {
+    public void testReadHeaderString() throws Exception {
         System.out.println("readHeader toString");
         String dataFile = this.getClass().getResource("/test.dict.dz").getFile();
         DictZipHeader result = DictZipHeader.readHeader(dataFile);
@@ -83,7 +80,7 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReadHeader_type() throws Exception {
+    public void testReadHeaderType() throws Exception {
         System.out.println("readHeader");
         String dataFile = this.getClass().getResource("/test.dict.dz").getFile();
         DictZipHeader result = DictZipHeader.readHeader(dataFile);
@@ -96,7 +93,7 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReadHeader_filename() throws Exception {
+    public void testReadHeaderFilename() throws Exception {
         System.out.println("readHeader");
         String dataFile = this.getClass().getResource("/test.dict.dz").getFile();
         DictZipHeader result = DictZipHeader.readHeader(dataFile);
@@ -109,7 +106,7 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReadHeader_chunkCount() throws Exception {
+    public void testReadHeaderChunkCount() throws Exception {
         System.out.println("readHeader");
         String dataFile = this.getClass().getResource("/test.dict.dz").getFile();
         DictZipHeader result = DictZipHeader.readHeader(dataFile);
@@ -122,9 +119,9 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReadHeader_NonGZip() throws Exception {
+    public void testReadHeaderNonGZip() throws Exception {
         System.out.println("readHeader / not dictzip file");
-        byte b[] = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
+        byte[] b = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
         File testFile = File.createTempFile("DictZipOutCon", ".txt.dz");
         testFile.deleteOnExit();
         FileOutputStream outFile = new FileOutputStream(testFile);
@@ -146,9 +143,9 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReadHeader_GZipMagic() throws Exception {
+    public void testReadHeaderGZipMagic() throws Exception {
         System.out.println("readHeader / wrong gzip magic");
-        byte b[] = {(byte) 0x1f, (byte) 0x8b, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
+        byte[] b = {(byte) 0x1f, (byte) 0x8b, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
         File testFile = File.createTempFile("DictZipOutCon", ".txt.dz");
         testFile.deleteOnExit();
         FileOutputStream outFile = new FileOutputStream(testFile);
@@ -170,7 +167,7 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReaderHeader_DefaultCompression() throws Exception {
+    public void testReaderHeaderDefaultCompression() throws Exception {
         System.out.println("readHeader of default compression");
         String dataFile = this.getClass().getResource("/default.dict.dz").getFile();
         DictZipHeader result = DictZipHeader.readHeader(dataFile);
@@ -183,7 +180,7 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReaderHeader_FastCompression() throws Exception {
+    public void testReaderHeaderFastCompression() throws Exception {
         System.out.println("readHeader of fast compression");
         String dataFile = this.getClass().getResource("/fast.dict.dz").getFile();
         DictZipHeader result = DictZipHeader.readHeader(dataFile);
@@ -196,7 +193,7 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReaderHeader_BestCompression() throws Exception {
+    public void testReaderHeaderBestCompression() throws Exception {
         System.out.println("readHeader of best compression");
         String dataFile = this.getClass().getResource("/best.dict.dz").getFile();
         DictZipHeader result = DictZipHeader.readHeader(dataFile);
@@ -209,7 +206,7 @@ public class DictZipHeaderTest {
      * @throws java.lang.Exception if file I/O error occurred.
      */
     @Test
-    public void testReaderHeader_WrongCompression() throws Exception {
+    public void testReaderHeaderWrongCompression() throws Exception {
         System.out.println("readHeader of corrupted file in extra flag");
         String dataFile = this.getClass().getResource("/corrupt.dict.dz").getFile();
         boolean r = false;
@@ -224,6 +221,7 @@ public class DictZipHeaderTest {
 
     /**
      * Test of getMemberLength method.
+     * @throws Exception when fails.
      */
     @Test
     public void testGetMemberLength() throws Exception {
index 42fc811..3da397c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DictZip library test.
  *
- * Copyright (C) 2016 Hiroshi Miura
+ * Copyright (C) 2016,2019 Hiroshi Miura
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
 
 package org.dict.zip;
 
-import static org.testng.Assert.*;
-
-import org.testng.SkipException;
-import org.testng.annotations.*;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
 import java.io.EOFException;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.Arrays;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 import static tokyo.northside.io.IOUtils2.contentEquals;
 
 /**
@@ -58,6 +59,11 @@ public class DictZipInputStreamTest {
     private final String dataFile = this.getClass().getResource("/test.dict.dz").getFile();
     private DictZipInputStream din;
 
+    /**
+     * rewind dictionary file.
+     *
+     * @throws Exception when i/o error.
+     */
     @BeforeMethod
     public void rewind() throws Exception {
         if (din != null) {
@@ -67,29 +73,29 @@ public class DictZipInputStreamTest {
 
     /**
      * Test constructor.
-     * @throws Exception
+     * @throws Exception when i/o error.
      */
-    @Test (groups = "init", dependsOnMethods = { "testConstructor_fromFilename",
-            "testConstructor_defaultBufSize"})
+    @Test (groups = "init", dependsOnMethods = { "testConstructorFromFilename",
+            "testConstructorDefaultBufSize"})
     public void testConstructor() throws Exception {
         din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534);
     }
 
     /**
      * Test constructor.
-     * @throws Exception
+     * @throws Exception when i/o error.
      */
     @Test (groups = "init")
-    public void testConstructor_defaultBufSize() throws Exception {
+    public void testConstructorDefaultBufSize() throws Exception {
         din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"));
     }
 
     /**
      * Test constructor from filename.
-     * @throws Exception
+     * @throws Exception when i/o error.
      */
     @Test (groups = "init")
-    public void testConstructor_fromFilename() throws Exception {
+    public void testConstructorFromFilename() throws Exception {
         din = new DictZipInputStream(dataFile);
     }
 
@@ -105,6 +111,7 @@ public class DictZipInputStreamTest {
 
     /**
      * Test of read method, of class DictZipInputStream.
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
     public void testRead() throws Exception {
@@ -118,9 +125,10 @@ public class DictZipInputStreamTest {
 
     /**
      * Test of read method, of class DictZipInputStream.
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testRead_with_seek() throws Exception {
+    public void testReadWithSeek() throws Exception {
         System.out.println("read with seek");
         int start = 0x20;
         int len = 10;
@@ -135,9 +143,10 @@ public class DictZipInputStreamTest {
 
     /**
      * Test of read method, of class DictZipInputStream.
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testRead_null() throws Exception {
+    public void testReadNull() throws Exception {
         System.out.println("read null buffer");
         int len = 10;
         byte[] buf = null;
@@ -154,9 +163,10 @@ public class DictZipInputStreamTest {
 
     /**
      * Test of read method, of class DictZipInputStream.
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testRead_outOfBound() throws Exception {
+    public void testReadOutOfBound() throws Exception {
         System.out.println("read out of buffer size");
         int len = 10;
         byte[] buf = new byte[len];
@@ -173,9 +183,10 @@ public class DictZipInputStreamTest {
 
     /**
      * Test of read method, of class DictZipInputStream.
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testRead_zeroSize() throws Exception {
+    public void testReadZeroSize() throws Exception {
         System.out.println("read zero size");
         int len = 512;
         byte[] buf = new byte[len];
@@ -185,9 +196,10 @@ public class DictZipInputStreamTest {
 
     /**
      * Test of read method, of class DictZipInputStream.
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testRead_with_seekLast() throws Exception {
+    public void testReadWithSeekLast() throws Exception {
         System.out.println("read with seek to last");
         int start = 383273;
         int len = 512;
@@ -200,10 +212,10 @@ public class DictZipInputStreamTest {
 
    /**
      * Test of readFully method, of class DictZipInputStream.
-     * @throws java.lang.Exception
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testReadFully_byteArr() throws Exception {
+    public void testReadFullyByteArr() throws Exception {
         System.out.println("readFully");
         int start = 100;
         int len = 10;
@@ -214,10 +226,10 @@ public class DictZipInputStreamTest {
 
     /**
      * Test of readFully method, of class DictZipInputStream.
-     * @throws java.lang.Exception
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testReadFully_3args() throws Exception {
+    public void testReadFully3args() throws Exception {
         System.out.println("readFully");
         int start = 200;
         int len = 10;
@@ -228,10 +240,10 @@ public class DictZipInputStreamTest {
 
     /**
      * Test of readFully method, of class DictZipInputStream.
-     * @throws java.lang.Exception
+     * @throws IOException when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testReadFully_readTrailer() throws IOException {
+    public void testReadFullyReadTrailer() throws IOException {
         System.out.println("readFully and readTrailer");
         byte[] buf = new byte[512];
         try {
@@ -247,7 +259,7 @@ public class DictZipInputStreamTest {
 
     /**
      * Test getComplength method.
-     * @throws IOException
+     * @throws IOException when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
     public void testGetCompLength() throws IOException {
@@ -257,6 +269,7 @@ public class DictZipInputStreamTest {
 
     /**
      * Test getMtime method.
+     * @throws IOException when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
     public void testGetMtime() throws IOException {
@@ -266,6 +279,7 @@ public class DictZipInputStreamTest {
 
     /**
      * Test getChunkLength method.
+     * @throws IOException when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
     public void testGetChunkLength() throws IOException {
@@ -275,6 +289,7 @@ public class DictZipInputStreamTest {
 
     /**
      * Test getChunkCount method.
+     * @throws IOException when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
     public void testGetChunkCount() throws IOException {
@@ -284,6 +299,7 @@ public class DictZipInputStreamTest {
 
     /**
      * Test getFilename method.
+     * @throws IOException when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
     public void testGetFilename() throws IOException {
@@ -292,10 +308,11 @@ public class DictZipInputStreamTest {
     }
 
    /**
-     * Test readFully with large seek
+     * Test readFully with large seek.
+    * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testReadFully_seek2() throws Exception {
+    public void testReadFullySeek2() throws Exception {
         System.out.println("readFully_seek2");
         int start = 56003;
         int len = 195;
@@ -313,10 +330,11 @@ public class DictZipInputStreamTest {
     }
 
    /**
-     * Test with large  seek
-     */
+    * Test with large  seek.
+    * @throws Exception when i/o error.
+    */
     @Test (groups = "test", dependsOnMethods = { "testConstructor" })
-    public void testRead_seek2() throws Exception {
+    public void testReadSeek2() throws Exception {
         System.out.println("read_seek2");
         int start = 56003;
         int len = 195;
@@ -326,7 +344,7 @@ public class DictZipInputStreamTest {
             fail("Unexpected IOException");
         }
         byte[] buf = new byte[len];
-        int result=0;
+        int result = 0;
         try {
             result = din.read(buf, 0, len);
         } catch (EOFException eofe) {
@@ -334,11 +352,13 @@ public class DictZipInputStreamTest {
         }
         assertEquals(result, len);
     }
+
     /**
-     * Test with large seek comparison content
+     * Test with large seek comparison content.
+     * @throws Exception when i/o error.
      */
     @Test (groups = "test", dependsOnMethods = { "testConstructor"})
-    public void testRead_seek3() throws Exception {
+    public void testReadSeek3() throws Exception {
          System.out.println("read_seek2");
         int start = 56003;
         int len = 195;
index d506241..0afa48e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DictZip library test.
  *
- * Copyright (C) 2016 Hiroshi Miura
+ * Copyright (C) 2016,2019 Hiroshi Miura
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -37,7 +37,9 @@
 
 package org.dict.zip;
 
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
 import org.testng.annotations.Test;
 
 import java.io.File;
@@ -56,9 +58,9 @@ public class DictZipOutputStreamTest {
      * Test of close method, of class DictZipOutputStream.
      */
     @Test
-    public void testClose() throws Exception {
+    public void testClose() {
         System.out.println("close");
-        byte byteArray[] = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
+        byte[] byteArray = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
         try {
             File testOutFile = File.createTempFile("DictZipOutCon", ".txt");
             testOutFile.deleteOnExit();
@@ -80,11 +82,12 @@ public class DictZipOutputStreamTest {
 
     /**
      * Test of deflate method, of class DictZipOutputStream.
+     * @throws Exception when i/o error.
      */
     @Test
     public void testDeflate() throws Exception {
         System.out.println("deflate");
-        byte byteArray[] = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
+        byte[] byteArray = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
         File testOutFile = File.createTempFile("DictZipOutCon", ".txt");
         testOutFile.deleteOnExit();
         RandomAccessOutputStream outFile = new RandomAccessOutputStream(
@@ -95,11 +98,12 @@ public class DictZipOutputStreamTest {
 
     /**
      * Test of write method, of class DictZipOutputStream.
+     * @throws Exception when i/o error.
      */
     @Test
-    public void testWrite_3args() throws Exception {
+    public void testWrite3args() throws Exception {
         System.out.println("write");
-        byte b[] = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
+        byte[] b = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
         int off = 0;
         int len = 0;
         File testOutFile = File.createTempFile("DictZipOutCon", ".txt");
@@ -114,7 +118,7 @@ public class DictZipOutputStreamTest {
      * Test of write method, of class DictZipOutputStream.
      */
     @Test
-    public void testWrite_int() {
+    public void testWriteInt() {
         System.out.println("write");
         int b = 100;
         TestDictZipOutputStream instance;
@@ -136,7 +140,7 @@ public class DictZipOutputStreamTest {
     @Test
     public void testFinish() {
         System.out.println("finish");
-        byte byteArray[] = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
+        byte[] byteArray = {3, 5, 2, 'r', 'g', 'e', 'f', 'd', 'e', 'w'};
         TestDictZipOutputStream instance = null;
         try {
             File testOutFile = File.createTempFile("DictZipOutCon", ".txt");
@@ -171,15 +175,16 @@ public class DictZipOutputStreamTest {
     }
 
     /**
-     * Stub for DictZipOutputStream, for test
+     * Stub for DictZipOutputStream, for test.
      */
-    class TestDictZipOutputStream extends DictZipOutputStream {
+    static class TestDictZipOutputStream extends DictZipOutputStream {
 
-        TestDictZipOutputStream(RandomAccessOutputStream out, long dataSize) throws IOException {
+        TestDictZipOutputStream(final RandomAccessOutputStream out, final long dataSize) throws IOException {
             super(out, dataSize);
         }
 
-        TestDictZipOutputStream(RandomAccessOutputStream out, int size, long dataSize) throws IOException {
+        TestDictZipOutputStream(final RandomAccessOutputStream out, final int size, final long dataSize)
+                throws IOException {
             super(out, size, dataSize);
         }
 
index fad3344..4defd60 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DictZip library test.
  *
- * Copyright (C) 2016 Hiroshi Miura
+ * Copyright (C) 2016,2019 Hiroshi Miura
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
 package org.dict.zip;
 
 import org.testng.annotations.Test;
-import static org.testng.Assert.*;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 /**
  * Test for project.
@@ -51,6 +54,7 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of available method, of class RandomAccessInputStream.
+     * @throws Exception when i/o error.
      */
     @Test
     public void testAvailable() throws Exception {
@@ -63,6 +67,7 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of close method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
     public void testClose() throws Exception {
@@ -73,6 +78,7 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of getLength method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
     public void testGetLength() throws Exception {
@@ -85,6 +91,7 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of getPos method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
     public void testGetPos() throws Exception {
@@ -127,9 +134,10 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of read method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
-    public void testRead_0args() throws Exception {
+    public void testRead0args() throws Exception {
         System.out.println("read");
         try {
             RandomAccessInputStream instance = new RandomAccessInputStream(dataFile, "r");
@@ -143,9 +151,10 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of read method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
-    public void testRead_3args() throws Exception {
+    public void testRead3args() throws Exception {
         System.out.println("read");
         byte[] b = new byte[512];
         int off = 100;
@@ -158,6 +167,7 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of readFully method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
     public void testReadFully() throws Exception {
@@ -169,6 +179,7 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of reset method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
     public void testReset() throws Exception {
@@ -179,6 +190,7 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of seek method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
     public void testSeek() throws Exception {
@@ -190,6 +202,7 @@ public class RandomAccessInputStreamTest {
 
     /**
      * Test of skip method, of class RandomAccessInputStream.
+     * @throws Exception when error.
      */
     @Test
     public void testSkip() throws Exception {