private void verifyResponse(Document response, Document template)
      throws IOException, TransformerException {
    DetailedDiff dd = new DetailedDiff(new Diff(response, template));
    dd.overrideElementQualifier(new NetconfXmlUnitRecursiveQualifier());

    printDocument(response);
    printDocument(template);

    assertTrue(dd.toString(), dd.similar());
  }
 protected boolean checkDocs(Document doc1, Document doc2) {
   XMLUnit.setIgnoreAttributeOrder(true);
   XMLUnit.setIgnoreWhitespace(true);
   DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(doc1, doc2));
   boolean result = diff.similar();
   if (!result) {
     for (Difference d : (List<Difference>) diff.getAllDifferences()) {
       System.out.println(d);
     }
   }
   return result;
 }
Exemplo n.º 3
0
  private void compareXmlFiles(String path, ElementQualifier qualifier) throws BrutException {
    DetailedDiff diff;
    try {
      Reader control = new FileReader(new File(sTestOrigDir, path));
      Reader test = new FileReader(new File(sTestNewDir, path));

      diff = new DetailedDiff(new Diff(control, test));
    } catch (SAXException | IOException ex) {
      throw new BrutException(ex);
    }

    if (qualifier != null) {
      diff.overrideElementQualifier(qualifier);
    }

    assertTrue(path + ": " + diff.getAllDifferences().toString(), diff.similar());
  }
  @Test
  public void testTransform() throws Exception {
    ArrayList<URL> tmapList = new ArrayList<URL>();
    URL tmap = TMapProcessor.class.getResource("tmap1.xml");
    tmapList.add(tmap);
    TMapProcessor proc = new TMapProcessor(tmapList);

    Document inputDocument = loadMessage("messageIn.xml");
    OpenEngSBMessage inputMessage = new OpenEngSBMessage(inputDocument);
    OpenEngSBMessage outputMessage = proc.transform(inputMessage);

    Document expectedDocument = loadMessage("messageOut.xml");
    Document realDocument = outputMessage.toXML();

    DetailedDiff myDiff =
        new DetailedDiff(new Diff(expectedDocument.asXML(), realDocument.asXML()));
    Assert.assertTrue(myDiff.toString(), myDiff.similar());
  }
Exemplo n.º 5
0
  public void testRoundTrip() throws Exception {
    StringWriter sw = new StringWriter();
    InputStream original = getClass().getClassLoader().getResourceAsStream("testmodel_data.xml");
    XMLUnit.setIgnoreWhitespace(true);
    Collection unmarshalled = (Collection) binding.unmarshal(original);
    setIds(unmarshalled);
    binding.marshal(unmarshalled, sw);

    String expected =
        IOUtils.toString(getClass().getClassLoader().getResourceAsStream("testmodel_data.xml"));

    Diff diff = new Diff(expected, sw.toString());
    DetailedDiff detail = new DetailedDiff(diff);
    detail.overrideElementQualifier(new ElementNameAndAttributeQualifier());
    assertTrue(
        detail.getAllDifferences().toString()
            + ": Original: "
            + expected
            + ", Generated: "
            + sw.toString(),
        detail.similar());
  }