/** * This is Bob's original test, re-written only to allow it to execute as a normal junit test * within Eclipse. */ @Test public void origTestOfRewritingMHLDtoSameBib() throws IOException { String mhldRecFileName = testDataParentPath + File.separator + "summaryHld_1-1000.mrc"; String bibRecFileName = testDataParentPath + File.separator + "u335.mrc"; InputStream inStr = null; ByteArrayOutputStream resultMrcOutStream = new ByteArrayOutputStream(); String[] mergeMhldArgs = new String[] {"-s", mhldRecFileName, bibRecFileName}; // call the code for mhldfile summaryHld_1-1000.mrc and bibfile u335.mrc CommandLineUtils.runCommandLineUtil( MERGE_MHLD_CLASS_NAME, MAIN_METHOD_NAME, inStr, resultMrcOutStream, mergeMhldArgs); RecordTestingUtils.assertMarcRecsEqual(mergedSummaryHoldingsOutput, resultMrcOutStream); // Now merge record again to test the deleting of existing summary holdings info ByteArrayInputStream mergedMarcBibRecAsInStream = new ByteArrayInputStream(resultMrcOutStream.toByteArray()); resultMrcOutStream.close(); resultMrcOutStream = new ByteArrayOutputStream(); // do the merge by piping the bib record in to the merge class CommandLineUtils.runCommandLineUtil( MERGE_MHLD_CLASS_NAME, MAIN_METHOD_NAME, mergedMarcBibRecAsInStream, resultMrcOutStream, new String[] {"-s", mhldRecFileName}); RecordTestingUtils.assertMarcRecsEqual(mergedSummaryHoldingsOutput, resultMrcOutStream); System.out.println("Test origTestOfRewritingMHLDtoSameBib() successful"); }
/** code should end smoothly if it encounters no matches between bib and mhld */ @Test public void testNoOutputMessagesWhenNoMatches() throws IOException { // bib46, mhld235 String bibFilePath = testDataParentPath + File.separator + "mhldMergeBibs46.mrc"; String mhldFilePath = testDataParentPath + File.separator + "mhldMergeMhlds235.mrc"; // ensure no error message was printed ByteArrayOutputStream sysBAOS = new ByteArrayOutputStream(); mergeBibAndMhldFiles(bibFilePath, mhldFilePath, sysBAOS); // ensure no error message was printed assertTrue( "Output messages written when none were expected: " + sysBAOS.toString(), sysBAOS.size() == 0); System.out.println("Test testNoOutputMessagesWhenNoMatches() successful"); }