WarcModule 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); ByteCountingPushBackInputStream pbin = new ByteCountingPushBackInputStream(stream, GzipReader.DEFAULT_INPUT_BUFFER_SIZE); boolean checkIsWarc = WarcReaderFactory.isWarcFile(pbin); if (checkIsWarc) { info.setSigMatch(_name); return; } boolean checkIsGzip = GzipReader.isGzipped(pbin); if (checkIsGzip) { info.setSigMatch(_name); return; } info.setWellFormed (false); } WarcModule(); @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 checkSignatureValidUTF8File() throws Exception { File warcFile = new File("src/test/resources/warc/valid-warcfile-utf8.warc"); WarcModule wm = new WarcModule(); RepInfo info = new RepInfo(warcFile.getAbsolutePath()); wm.checkSignatures(null, new FileInputStream(warcFile), info); assertEquals(RepInfo.TRUE, info.getWellFormed()); assertEquals(WarcModule.class, info.getModule().getClass()); assertEquals(Arrays.asList(wm.getName()), info.getSigMatch()); }
@Test public void checkSignatureCompressWarc() throws Exception { File warcFile = new File("src/test/resources/warc/valid-warcfile-upper-lower-case.warc.gz"); WarcModule wm = new WarcModule(); RepInfo info = new RepInfo(warcFile.getAbsolutePath()); wm.checkSignatures(null, new FileInputStream(warcFile), info); assertEquals(RepInfo.TRUE, info.getWellFormed()); assertEquals(WarcModule.class, info.getModule().getClass()); assertEquals(Arrays.asList(wm.getName()), info.getSigMatch()); }