GzipModule extends ModuleBase { @Override public void checkSignatures (File file, InputStream stream, RepInfo info) throws IOException { info.setFormat (_format[0]); info.setMimeType (_mimeType[0]); info.setModule (this); boolean checkIsGzip = GzipReader.isGzipped(new ByteCountingPushBackInputStream(stream, GzipReader.DEFAULT_INPUT_BUFFER_SIZE)); if (checkIsGzip) { info.setSigMatch(_name); } else { info.setWellFormed (false); } } GzipModule(); @Override void resetParams(); @Override void checkSignatures(File file,
            InputStream stream, 
            RepInfo info); @Override void checkSignatures(File file,
            RandomAccessFile raf, 
            RepInfo info); @Override void parse(RandomAccessFile file, RepInfo info); @Override int parse(InputStream stream, RepInfo info, int parseIndex);  }
@Test public void checkSignatureSampleTextGzipFile() throws Exception { File gzipFile = new File(TXT_GZIP_SAMPLE_FILE); GzipModule gzm = new GzipModule(); RepInfo info = new RepInfo(gzipFile.getAbsolutePath()); gzm.checkSignatures(null, new FileInputStream(gzipFile), info); assertEquals(RepInfo.TRUE, info.getWellFormed()); assertEquals(GzipModule.class, info.getModule().getClass()); assertEquals(Arrays.asList(gzm.getName()), info.getSigMatch()); }
@Test public void checkSignaturThreeFilesGzipFile() throws Exception { File gzipFile = new File(THREE_FILES_GZIP_SAMPLE_FILE); GzipModule gzm = new GzipModule(); RepInfo info = new RepInfo(gzipFile.getAbsolutePath()); gzm.checkSignatures(null, new FileInputStream(gzipFile), info); assertEquals(RepInfo.TRUE, info.getWellFormed()); assertEquals(GzipModule.class, info.getModule().getClass()); assertEquals(Arrays.asList(gzm.getName()), info.getSigMatch()); }