id 'java-library'
id 'maven-publish'
id 'java-library-distribution'
- id "signing"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id 'com.palantir.git-version' version "0.12.3"
}
project(':dictzip-lib') {
apply plugin: 'java-library'
+ apply plugin: "signing"
version = rootProject.version
dependencies {
public DictZipInputStream(final RandomAccessInputStream in, final int size) throws IOException {
super(in, new Inflater(true), size);
header = readHeader();
+ in.mark(in.getLength());
readTrailer();
+ in.reset();
}
/**
* Get raw content offset in bytes.
* @return offset.
*/
- public final long getPos() {
+ public final long position() {
return rawOffset;
}
public class DictZipInputStreamTest {
private final String dataFile = this.getClass().getResource("/test.dict.dz").getFile();
+ private final String dataFile2 = this.getClass().getResource("/test.dsl.dz").getFile();
/**
* Test constructor @TestFactory.
byte[] buf = new byte[len];
byte[] expResult = {0x70, 0x72, (byte) 0xc3, (byte) 0xa9, 0x70, 0x2e, 0x20, 0x3a, 0x20, 0x2b};
try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) {
- din.seek(0);
+ din.read(buf, 0, len);
+ assertTrue(Arrays.equals(expResult, buf));
+ }
+ }
+
+ /**
+ * Test of read method with another file, of class DictZipInputStream.
+ * @throws Exception when i/o error.
+ */
+ @Test
+ public void testRead2() throws Exception {
+ int len = 10;
+ byte[] buf = new byte[len];
+ byte[] expResult = {(byte)0xFF, (byte)0xFE, 35, 0, 78, 0, 65, 0, 77, 0};
+ try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile2, "r"))) {
din.read(buf, 0, len);
assertTrue(Arrays.equals(expResult, buf));
}