CDXIndexer extends IndexerBase { @Override public void indexFiles(Long harvestResultOid) { log.info("Generating indexes for " + getResult().getTargetInstanceOid()); File[] fileList = directory.listFiles(new ARCFilter()); if(fileList == null) { log.error("Could not find any archive files in directory: " + directory.getAbsolutePath() ); } else { for(File f: fileList) { try { log.info("Indexing " + f.getName()); writeCDXIndex(f); log.info("Completed indexing of " + f.getName()); } catch(IOException ex) { log.error("Could not index file " + f.getName() + ". Ignoring and continuing with other files. "+ex.getClass().getCanonicalName()+": "+ ex.getMessage()); } } } log.info("Completed indexing for job " + getResult().getTargetInstanceOid()); } CDXIndexer(); protected  CDXIndexer(CDXIndexer original); @Override void indexFiles(Long harvestResultOid); @Override Long begin(); @Override String getName(); @Override void initialise(ArcHarvestResultDTO result, File directory); @Override RunnableIndex getCopy(); void setEnabled(boolean enabled); @Override boolean isEnabled();  }
@Ignore @Test public final void testIndexFiles() { try { testInstance.indexFiles(testInstance.getResult().getOid()); File cdxFile = new File(archivePath+"/"+TestCARC_CDX); assertTrue(cdxFile.exists()); int count = 0; FileInputStream fstream = new FileInputStream(cdxFile); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); while (br.readLine() != null) { count++; } in.close(); assertEquals(NumARCResources, count-1); cdxFile.delete(); cdxFile = new File(archivePath+"/"+TestCWARC_CDX); assertTrue(cdxFile.exists()); count = 0; fstream = new FileInputStream(cdxFile); in = new DataInputStream(fstream); br = new BufferedReader(new InputStreamReader(in)); while (br.readLine() != null) { count++; } in.close(); assertEquals(NumWARCResources, (count-3)/3); cdxFile.delete(); } catch (Exception e) { fail(e.getMessage()); } }