/** * 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"); }
/** Test if using Naomi's approach with next() works as well as weird way of duplicating code */ @Test public void testMergeToStdOut2() throws IOException { String mhldRecFileName = testDataParentPath + File.separator + "summaryHld_1-1000.mrc"; String bibRecFileName = testDataParentPath + File.separator + "u335.mrc"; ByteArrayOutputStream sysBAOS = new ByteArrayOutputStream(); PrintStream sysMsgs = new PrintStream(sysBAOS); MergeSummaryHoldings.mergeMhldRecsIntoBibRecsAsStdOut2( bibRecFileName, mhldRecFileName, sysMsgs); RecordTestingUtils.assertMarcRecsEqual(mergedSummaryHoldingsOutput, sysBAOS); System.out.println("Test testMergeToStdOut2() successful"); }