### Question:
JobHistoryFileParserBase implements JobHistoryFileParser { public static long getSubmitTimeMillisFromJobHistory(byte[] jobHistoryRaw) { long submitTimeMillis = 0; if (null == jobHistoryRaw) { return submitTimeMillis; } HadoopVersion hv = JobHistoryFileParserFactory.getVersion(jobHistoryRaw); switch (hv) { case TWO: int startIndex = ByteUtil.indexOf(jobHistoryRaw, Constants.JOB_SUBMIT_EVENT_BYTES, 0); if (startIndex != -1) { int secondQuoteIndex = ByteUtil.indexOf(jobHistoryRaw, Constants.SUBMIT_TIME_PREFIX_HADOOP2_BYTES, startIndex); if (secondQuoteIndex != -1) { String submitTimeMillisString = Bytes.toString(jobHistoryRaw, secondQuoteIndex + Constants.EPOCH_TIMESTAMP_STRING_LENGTH, Constants.EPOCH_TIMESTAMP_STRING_LENGTH); try { submitTimeMillis = Long.parseLong(submitTimeMillisString); } catch (NumberFormatException nfe) { LOG.error(" caught NFE during conversion of submit time " + submitTimeMillisString + " " + nfe.getMessage()); submitTimeMillis = 0; } } } break; case ONE: default: startIndex = ByteUtil.indexOf(jobHistoryRaw, Constants.SUBMIT_TIME_PREFIX_BYTES, 0); if (startIndex != -1) { int prefixEndIndex = startIndex + Constants.SUBMIT_TIME_PREFIX_BYTES.length; int secondQuoteIndex = ByteUtil.indexOf(jobHistoryRaw, Constants.QUOTE_BYTES, prefixEndIndex); if (secondQuoteIndex != -1) { int numberLength = secondQuoteIndex - prefixEndIndex; String submitTimeMillisString = Bytes.toString(jobHistoryRaw, prefixEndIndex, numberLength); try { submitTimeMillis = Long.parseLong(submitTimeMillisString); } catch (NumberFormatException nfe) { LOG.error(" caught NFE during conversion of submit time " + submitTimeMillisString + " " + nfe.getMessage()); submitTimeMillis = 0; } } } break; } return submitTimeMillis; } protected  JobHistoryFileParserBase(Configuration conf); Put getHadoopVersionPut(HadoopVersion historyFileVersion, byte[] jobKeyBytes); static long getXmxValue(String javaChildOptsStr); static long getXmxTotal(final long xmx75); static long getSubmitTimeMillisFromJobHistory(byte[] jobHistoryRaw); static double calculateJobCost(long mbMillis, double computeTco, long machineMemory);  }### Answer:
@Test public void testGetSubmitTimeMillisFromJobHistory2() throws IOException { String JOB_HISTORY_FILE_NAME = "src/test/resources/job_1329348432655_0001-1329348443227-user-Sleep+job-1329348468601-10-1-SUCCEEDED-default.jhist"; File jobHistoryfile = new File(JOB_HISTORY_FILE_NAME); byte[] contents = Files.toByteArray(jobHistoryfile); long actualts = JobHistoryFileParserBase.getSubmitTimeMillisFromJobHistory(contents); long expts = 1329348443227L; assertEquals(expts, actualts); JOB_HISTORY_FILE_NAME = "src/test/resources/job_1329348432999_0003-1329348443227-user-Sleep+job-1329348468601-10-1-SUCCEEDED-default.jhist"; jobHistoryfile = new File(JOB_HISTORY_FILE_NAME); contents = Files.toByteArray(jobHistoryfile); actualts = JobHistoryFileParserBase.getSubmitTimeMillisFromJobHistory(contents); expts = 1328218696000L; assertEquals(expts, actualts); }
@Test(expected=IllegalArgumentException.class) public void testIncorrectSubmitTime() { byte[] jobHistoryBytes = Bytes.toBytes(""); JobHistoryFileParserBase.getSubmitTimeMillisFromJobHistory(jobHistoryBytes); }