### Changed
+
+## [0.8.1] - 2015-4-29
### Fixed
- Gradle: github and bintray release error.
+- [#21] fixed unexpected EOFException when readFully() called after seek().
## [0.8.0] - 2015-4-29
### Add
### Added
- Start project.
-[Unreleased]: https://github.com/miurahr/dictzip-java/compare/v0.8.0...HEAD
+[Unreleased]: https://github.com/miurahr/dictzip-java/compare/v0.8.1...HEAD
+[0.8.1]: https://github.com/miurahr/dictzip-java/compare/v0.8.0...v0.8.1
[0.8.0]: https://github.com/miurahr/dictzip-java/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/miurahr/dictzip-java/compare/v0.6.1...v0.7.0
[0.6.1]: https://github.com/miurahr/dictzip-java/compare/v0.6.0...v0.6.1
import org.testng.annotations.*;
import java.io.EOFException;
+import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
+import static tokyo.northside.io.IOUtils2.contentEquals;
/**
* Test of DictZipInputStream.
* Test close of stream.
* @throws Exception if I/O error occurred.
*/
- @Test (dependsOnGroups = { "test" })
+ @Test (groups = "exit", dependsOnGroups = { "test" })
public void testClose() throws Exception {
din.close();
+ din = null;
}
/**
int len = 512;
byte[] buf = new byte[len];
int size = din.read(buf, 0, 0);
- throw new SkipException("Unknown bug.");
- //assertEquals(size, 0);
+ assertEquals(size, 0);
}
/**
assertEquals(din.getFilename(), "results.dict");
}
+ /**
+ * Test readFully with large seek
+ */
+ @Test (groups = "test", dependsOnMethods = { "testConstructor" })
+ public void testReadFully_seek2() throws Exception {
+ System.out.println("readFully_seek2");
+ int start = 56003;
+ int len = 195;
+ try {
+ din.seek(start);
+ } catch (IOException ioe) {
+ fail("Unexpected IOException");
+ }
+ byte[] buf = new byte[len];
+ try {
+ din.readFully(buf);
+ } catch (EOFException eofe) {
+ fail("Unexpected EOF");
+ }
+ }
+ /**
+ * Test with large seek
+ */
+ @Test (groups = "test", dependsOnMethods = { "testConstructor" })
+ public void testRead_seek2() throws Exception {
+ System.out.println("read_seek2");
+ int start = 56003;
+ int len = 195;
+ try {
+ din.seek(start);
+ } catch (IOException ioe) {
+ fail("Unexpected IOException");
+ }
+ byte[] buf = new byte[len];
+ int result=0;
+ try {
+ result = din.read(buf, 0, len);
+ } catch (EOFException eofe) {
+ fail("Unexpected EOF");
+ }
+ assertEquals(result, len);
+ }
+ /**
+ * Test with large seek comparison content
+ */
+ @Test (groups = "test", dependsOnMethods = { "testConstructor"})
+ public void testRead_seek3() throws Exception {
+ System.out.println("read_seek2");
+ int start = 56003;
+ int len = 195;
+ try {
+ din.seek(start);
+ } catch (IOException ioe) {
+ fail("Unexpected IOException");
+ }
+ FileInputStream in2 = new FileInputStream(this.getClass().getResource("/test.dict.expected").getFile());
+ in2.skip(start);
+ assertTrue(contentEquals(din, in2, 0, len));
+ }
}