/** test methods that return Map of ids to Records and no sysout stuff */
  @Test
  public void testGettingOutputAsMapOfRecords() throws IOException {
    String mhldRecFileName = testDataParentPath + File.separator + "summaryHld_1-1000.mrc";
    String bibRecFileName = testDataParentPath + File.separator + "u335.mrc";

    Map<String, Record> mergedRecs =
        MergeSummaryHoldings.mergeMhldsIntoBibRecordsAsMap(bibRecFileName, mhldRecFileName);

    junit.framework.Assert.assertEquals("results should have 1 record", 1, mergedRecs.size());
    String expId = "u335";
    assertTrue("Record with id " + expId + " should be in results", mergedRecs.containsKey(expId));

    Record resultRec = mergedRecs.get(expId);
    RecordTestingUtils.assertEqualsIgnoreLeader(mergedSummaryHoldingsOutputNoUmlaut, resultRec);
    System.out.println("Test testGettingOutputAsMapOfRecords() successful");
  }
Exemple #2
0
  @Test
  public void testDuplicates() throws Exception {
    // Check if we are running against motherlode or localhost, or what.
    String testserver = System.getProperty("testserver");
    if (testserver == null) testserver = DFALTTESTSERVER;

    List<Result> results = new ArrayList<Result>();
    if (true) {
      results.add(
          new Result(
              "Top and field vars have same names",
              "http://" + testserver + "/dts/structdupname",
              "netcdf dods://"
                  + testserver
                  + "/dts/structdupname {\n"
                  + " variables:\n"
                  + "   int time;\n"
                  + "Structure {\n"
                  + "   float time;\n"
                  + "} record;\n"
                  + "}"));
    }
    if (true) {
      results.add(
          new Result(
              "TestFailure",
              "http://" + testserver + "/dts/simplestruct",
              "netcdf dods://"
                  + testserver
                  + "/dts/simplestruct {\n"
                  + " variables:\n"
                  + "Structure {\n"
                  + "   int i32;\n"
                  + "} types;\n"
                  + "}"));
    }
    boolean pass = true;
    for (Result result : results) {
      System.out.println("TestDuplicates: " + result.url);
      boolean localpass = true;
      try {
        DODSNetcdfFile ncfile = new DODSNetcdfFile(result.url);
        if (ncfile == null) throw new Exception("Cannot read: " + result.url);
        StringWriter ow = new StringWriter();
        PrintWriter pw = new PrintWriter(ow);
        ncfile.writeCDL(pw, false);
        try {
          pw.close();
          ow.close();
        } catch (IOException ioe) {
        }
        ;
        StringReader baserdr = new StringReader(result.cdl);
        String captured = ow.toString();
        StringReader resultrdr = new StringReader(captured);
        // Diff the two files
        Diff diff = new Diff("Testing " + result.title);
        localpass = !diff.doDiff(baserdr, resultrdr);
        baserdr.close();
        resultrdr.close();
        // Dump the output for visual comparison
        if (System.getProperty("visual") != null) {
          System.out.println("Testing " + result.title + " visual:");
          System.out.println("---------------");
          System.out.print(captured);
          System.out.println("---------------");
        }
      } catch (IllegalArgumentException e) {
        localpass = false;
      }
      if (!localpass) pass = false;
    }
    System.out.flush();
    System.err.flush();
    junit.framework.Assert.assertTrue("Testing " + getTitle(), pass);
  }