/*
* 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;