OfflineEditsViewer extends Configured implements Tool { public int go(String inputFileName, String outputFileName, String processor, Flags flags, OfflineEditsVisitor visitor) { if (flags.getPrintToScreen()) { System.out.println("input [" + inputFileName + "]"); System.out.println("output [" + outputFileName + "]"); } boolean xmlInput = StringUtils.toLowerCase(inputFileName).endsWith(".xml"); if (xmlInput && StringUtils.equalsIgnoreCase("xml", processor)) { System.err.println("XML format input file is not allowed" + " to be processed by XML processor."); return -1; } else if(!xmlInput && StringUtils.equalsIgnoreCase("binary", processor)) { System.err.println("Binary format input file is not allowed" + " to be processed by Binary processor."); return -1; } try { if (visitor == null) { visitor = OfflineEditsVisitorFactory.getEditsVisitor( outputFileName, processor, flags.getPrintToScreen()); } OfflineEditsLoader loader = OfflineEditsLoaderFactory. createLoader(visitor, inputFileName, xmlInput, flags); loader.loadEdits(); } catch(Exception e) { System.err.println("Encountered exception. Exiting: " + e.getMessage()); e.printStackTrace(System.err); return -1; } return 0; }  static Options buildOptions(); int go(String inputFileName, String outputFileName, String processor,
      Flags flags, OfflineEditsVisitor visitor); @Override int run(String[] argv); static void main(String[] argv);  }
@Test public void testStatisticsStrWithNullOpCodeCount() throws IOException { String editFilename = nnHelper.generateEdits(); String outFilename = editFilename + ".stats"; FileOutputStream fout = new FileOutputStream(outFilename); StatisticsEditsVisitor visitor = new StatisticsEditsVisitor(fout); OfflineEditsViewer oev = new OfflineEditsViewer(); String statisticsStr = null; if (oev.go(editFilename, outFilename, "stats", new Flags(), visitor) == 0) { statisticsStr = visitor.getStatisticsString(); } Assert.assertNotNull(statisticsStr); String str; Long count; Map<FSEditLogOpCodes, Long> opCodeCount = visitor.getStatistics(); for (FSEditLogOpCodes opCode : FSEditLogOpCodes.values()) { count = opCodeCount.get(opCode); if (count == null) { str = String.format(" %-30.30s (%3d): %d%n", opCode.toString(), opCode.getOpCode(), Long.valueOf(0L)); assertTrue(statisticsStr.contains(str)); } } }