<!-- 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"/>
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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
+}
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;
*/
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
* @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";
* @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";
+/*
+ * 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;
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");
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;
assertTrue(result);
}
+ /**
+ * Check dictzip input stream.
+ * @throws Exception when fails.
+ */
@Test
public void testCheckDictZipInputStream() throws Exception {
System.out.println("checkDictZipInputStream");
/*
* 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.annotations.Test;
import java.io.File;
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;
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";
}
/**
* @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);
* @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);
* @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);
* @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);
* @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);
* @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);
* @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);
* @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);
* @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);
* @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;
/**
* Test of getMemberLength method.
+ * @throws Exception when fails.
*/
@Test
public void testGetMemberLength() throws Exception {
/*
* 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;
/**
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) {
/**
* 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);
}
/**
* Test of read method, of class DictZipInputStream.
+ * @throws Exception when i/o error.
*/
@Test (groups = "test", dependsOnMethods = { "testConstructor" })
public void testRead() throws Exception {
/**
* 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;
/**
* 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;
/**
* 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];
/**
* 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];
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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 {
/**
* Test getComplength method.
- * @throws IOException
+ * @throws IOException when i/o error.
*/
@Test (groups = "test", dependsOnMethods = { "testConstructor" })
public void testGetCompLength() throws IOException {
/**
* Test getMtime method.
+ * @throws IOException when i/o error.
*/
@Test (groups = "test", dependsOnMethods = { "testConstructor" })
public void testGetMtime() throws IOException {
/**
* Test getChunkLength method.
+ * @throws IOException when i/o error.
*/
@Test (groups = "test", dependsOnMethods = { "testConstructor" })
public void testGetChunkLength() throws IOException {
/**
* Test getChunkCount method.
+ * @throws IOException when i/o error.
*/
@Test (groups = "test", dependsOnMethods = { "testConstructor" })
public void testGetChunkCount() throws IOException {
/**
* Test getFilename method.
+ * @throws IOException when i/o error.
*/
@Test (groups = "test", dependsOnMethods = { "testConstructor" })
public void testGetFilename() throws IOException {
}
/**
- * 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;
}
/**
- * 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;
fail("Unexpected IOException");
}
byte[] buf = new byte[len];
- int result=0;
+ int result = 0;
try {
result = din.read(buf, 0, len);
} catch (EOFException eofe) {
}
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;
/*
* 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 static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
import org.testng.annotations.Test;
import java.io.File;
* 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();
/**
* 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(
/**
* 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");
* Test of write method, of class DictZipOutputStream.
*/
@Test
- public void testWrite_int() {
+ public void testWriteInt() {
System.out.println("write");
int b = 100;
TestDictZipOutputStream instance;
@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");
}
/**
- * 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);
}
/*
* 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.
/**
* Test of available method, of class RandomAccessInputStream.
+ * @throws Exception when i/o error.
*/
@Test
public void testAvailable() throws Exception {
/**
* Test of close method, of class RandomAccessInputStream.
+ * @throws Exception when error.
*/
@Test
public void testClose() throws Exception {
/**
* Test of getLength method, of class RandomAccessInputStream.
+ * @throws Exception when error.
*/
@Test
public void testGetLength() throws Exception {
/**
* Test of getPos method, of class RandomAccessInputStream.
+ * @throws Exception when error.
*/
@Test
public void testGetPos() throws Exception {
/**
* 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");
/**
* 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;
/**
* Test of readFully method, of class RandomAccessInputStream.
+ * @throws Exception when error.
*/
@Test
public void testReadFully() throws Exception {
/**
* Test of reset method, of class RandomAccessInputStream.
+ * @throws Exception when error.
*/
@Test
public void testReset() throws Exception {
/**
* Test of seek method, of class RandomAccessInputStream.
+ * @throws Exception when error.
*/
@Test
public void testSeek() throws Exception {
/**
* Test of skip method, of class RandomAccessInputStream.
+ * @throws Exception when error.
*/
@Test
public void testSkip() throws Exception {