public void addDoc(String filename) {
   String name = filename.substring(filename.lastIndexOf('/') + 1);
   try {
     JuxtaDocument document = documentManager.addDocument(name, filename);
     if (document != null) {
       comparisonSet.addCollation(document);
     }
   } catch (LoggedException e) {
     e.printStackTrace();
     fail();
   }
 }
  void getDiffs(Node node) throws ReportedException {
    int baseIndex = Integer.parseInt(getAttr(node, "base"));
    int witnessIndex = Integer.parseInt(getAttr(node, "witness"));
    Log(
        "<test id=\""
            + getAttr(node, "id")
            + "\" base=\""
            + baseIndex
            + "\" witness=\""
            + witnessIndex
            + "\" >");

    LinkedList docs = documentManager.getDocumentList();
    JuxtaDocument baseDoc = (JuxtaDocument) docs.get(baseIndex);
    JuxtaDocument witnessDoc = (JuxtaDocument) docs.get(witnessIndex);
    String str = "";
    Collation collation = comparisonSet.getCollation(baseDoc);
    List list = collation.getDifferences(witnessDoc);
    if (list == null) list = new LinkedList();
    dumpAllDifferences(list, baseDoc.getDocumentText(), witnessDoc.getDocumentText());
    int count = 0;
    NodeList nlResult = node.getChildNodes();

    int numResults = (createXml ? list.size() : nlResult.getLength());

    for (int i = 0; i < numResults; ++i) {
      Node nodeResult = (createXml ? null : nlResult.item(i));
      if (createXml
          || nodeResult.getNodeType() == Node.ELEMENT_NODE
              && nodeResult.getNodeName().equals("result")) {
        if (count >= list.size()) {
          DoAssert("Not enough difference entries returned", -1, list.size());
          break;
        }
        Difference difference = (Difference) list.get(count);
        ++count;
        String strBaseFilename =
            documentManager.lookupDocument(difference.getBaseDocumentID()).getDocumentName();
        String strWitnessFilename =
            documentManager.lookupDocument(difference.getWitnessDocumentID()).getDocumentName();
        int iBaseOfs = difference.getOffset(Difference.BASE);
        int iBaseLen = difference.getLength(Difference.BASE);
        int iWitnessOfs = difference.getOffset(Difference.WITNESS);
        int iWitnessLen = difference.getLength(Difference.WITNESS);

        str = "\t<result ";
        str += "basename=\"" + strBaseFilename;
        str += "\" baseoffset=\"" + Integer.toString(iBaseOfs);
        str += "\" baselength=\"" + Integer.toString(iBaseLen);
        str += "\" witnessname=\"" + strWitnessFilename;
        str += "\" witnessoffset=\"" + Integer.toString(iWitnessOfs);
        str += "\" witnesslength=\"" + Integer.toString(iWitnessLen);
        str += "\" type=\"" + Difference.getTypeName(difference.getType());
        str += "\" distance=\"" + Integer.toString(difference.getDistance());
        str += "\" />";
        Log(str);

        if (!createXml) {
          DoAssert(
              "",
              "",
              difference.testContents(
                  Difference.getTypeValue(getAttr(nodeResult, "type")),
                  getAttrInt(nodeResult, "baseoffset"),
                  getAttrInt(nodeResult, "baselength"),
                  getAttrInt(nodeResult, "witnessoffset"),
                  getAttrInt(nodeResult, "witnesslength")));
          DoAssert("basename", getAttr(nodeResult, "basename"), strBaseFilename);
          DoAssert("witnessname", getAttr(nodeResult, "witnessname"), strWitnessFilename);
          DoAssert(
              "distance",
              getAttr(nodeResult, "distance"),
              Integer.toString(difference.getDistance()));
        }
      }
    }
    DoAssert("count", count, (list == null) ? 0 : list.size());

    Log("</test>");
  }