Package org.custommonkey.xmlunit

Examples of org.custommonkey.xmlunit.Diff


    public void invokeQueryPushMode() throws XQueryException, XMLStreamException, XPathException,
            SAXException, IOException {
        String query = "declare namespace hoge=\"http://www.hoge.jp/dtd\"; <records xmlns:hoge=\"http://www.hoge.jp/dtd\"> {for $t in doc(\"./main/test/java/scenario/multithread/data-s.xml\")/records/record return <record>{$t/@*}{$t/author/text()}{ fn:concat(\"《\", $t/title/text() , \"》\") }</record>} </records>";
        String xbirdOut = invokeQueryPushModeUsingSAX(query);
        String saxonOut = invokeQueryBySaxon(query);
        Diff diff = new Diff(saxonOut, xbirdOut);
        if(!diff.identical()) {
            if(!diff.similar()) {
                Assert.fail(diff.toString());
            } else {               
                System.out.println(diff.toString());
            }
        }
    }
View Full Code Here


                            println(expectedStr);
                        }

                        final String compareForm = output.getAttribute("compare");
                        if("XML".equals(compareForm)) {
                            Diff diff = new Diff(expectedStr, resString);
                            if(diff.similar()) {
                                reportTestResult(testName, "pass", null);
                                break;
                            } else {
                                if(oi == lastoi) {
                                    String errmsg = diff.toString();
                                    reportTestResult(testName, "fail", errmsg);
                                    Assert.fail(errmsg);
                                }
                            }
                        } else if("Fragment".equals(compareForm)) {
                            Document expectedDoc = _expectedDocumentCache.get(expFileName);
                            if(expectedDoc == null) {
                                expectedDoc = buildFragment(expectedStr);
                                _expectedDocumentCache.put(expFileName, expectedDoc);
                            }
                            String actual = "<doc>" + resString + "</doc>";
                            Document actualDoc = buildDocument(new ByteArrayInputStream(actual.getBytes("UTF-8")));
                            Diff diff = new Diff(expectedDoc, actualDoc);
                            if(diff.similar()) {
                                reportTestResult(testName, "pass", null);
                                break;
                            } else {
                                if(oi == lastoi) {
                                    String errmsg = diff.toString();
                                    reportTestResult(testName, "fail", errmsg);
                                    Assert.fail(errmsg);
                                }
                            }
                        } else if("Text".equals(compareForm)) {
                            if(expectedStr.equals(resString)) {
                                reportTestResult(testName, "pass", null);
                                break;
                            } else {
                                Document expectedDoc = _expectedDocumentCache.get(expFileName);
                                if(expectedDoc == null) {
                                    expectedDoc = buildFragment(expectedStr);
                                    _expectedDocumentCache.put(expFileName, expectedDoc);
                                }
                                String actual = "<doc>" + XMLUtils.escapeXML(resString) + "</doc>";
                                Document actualDoc = buildDocument(new ByteArrayInputStream(actual.getBytes("UTF-8")));
                                Diff diff = new Diff(expectedDoc, actualDoc);
                                if(diff.identical()) {
                                    reportTestResult(testName, "pass", null);
                                    break;
                                } else {
                                    if(oi == lastoi) {
                                        String errmsg = new ComparisonFailure("[Text comparison]", expectedStr, resString).getMessage();
                                        reportTestResult(testName, "fail", errmsg);
                                        Assert.assertEquals("[Text comparison]", expectedStr, resString);
                                    }
                                }
                            }
                        } else if("Ignore".equals(compareForm)) {
                            // no comparison needs to be applied; the result is always true
                            // if the implementation successfully executes the test case.
                            reportTestResult(testName, "pass", null);
                            break;
                        } else if("Inspect".equals(compareForm)) {
                            System.err.println("#" + i + " Inspection is required");
                            Document expectedDoc = _expectedDocumentCache.get(expFileName);
                            if(expectedDoc == null) {
                                expectedDoc = buildFragment(expectedStr);
                                _expectedDocumentCache.put(expFileName, expectedDoc);
                            }
                            String actual = "<doc>" + resString + "</doc>";
                            Document actualDoc = buildDocument(new ByteArrayInputStream(actual.getBytes("UTF-8")));
                            Diff diff = new Diff(expectedDoc, actualDoc);
                            if(diff.similar()) {
                                reportTestResult(testName, "pass", null);
                                break;
                            } else {
                                if(oi == lastoi) {
                                    reportTestResult(testName, "not tested", "Inspectection is required");
                                }
                            }
                            if(ispect && !diff.similar()) {
                                if(oi == lastoi) {
                                    Assert.fail("Inspectection is required: \n" + diff.toString());
                                }
                            }
                        } else {
                            String errmsg = "[BUG] could'nt compare in " + compareForm;
                            reportTestResult(testName, "fail", errmsg);
View Full Code Here

   *
   * @return Diff object describing differences in documents
   */
  public final Diff compareXML(Document control, Document test)
  {
    return new Diff(control, test);
  }
View Full Code Here

  public final void assertEqual(String msg, Document expected, Document actual)
  {
    expected.getDocumentElement().normalize();
    actual.getDocumentElement().normalize();

    Diff diff = compareXML(expected, actual);

    if (!diff.similar())
    {
      try
      {
        System.out.println("expected:");
        print(expected);
        System.out.println("actual:");
        print(actual);
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }

    assertEquals(msg+", "+diff.toString(), true, diff.similar());
  }
View Full Code Here

  public final void assertEqual(Document expected, Document actual)
  {
    expected.getDocumentElement().normalize();
    actual.getDocumentElement().normalize();

    Diff diff = compareXML(expected, actual);

    if (!diff.similar())
    {
      try
      {
        System.out.println("expected:");
        print(expected);
        System.out.println("actual:");
        print(actual);
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }

    assertEquals("Test if the assertion document is equal, "+diff.toString(), true, diff.similar());
  }
View Full Code Here

   *
   * @return Diff object describing differences in documents
   */
  public final Diff compareXML(Document control, Document test)
  {
    return new Diff(control, test);
  }
View Full Code Here

  public final void assertEqual(String msg, Document expected, Document actual)
  {
    expected.getDocumentElement().normalize();
    actual.getDocumentElement().normalize();

    Diff diff = compareXML(expected, actual);

    assertEquals(msg+", "+diff.toString(), true, diff.similar());
  }
View Full Code Here

  public final void assertEqual(Document expected, Document actual)
  {
    expected.getDocumentElement().normalize();
    actual.getDocumentElement().normalize();

    Diff diff = compareXML(expected, actual);

    try
    {
      System.out.println("expected:");
      print(expected);
      System.out.println("actual:");
      print(actual);
    }
    catch (Exception e) {}

    assertEquals("Test if the assertion document is equal, "+diff.toString(), true, diff.similar());
  }
View Full Code Here

   *
   * @return Diff object describing differences in documents
   */
  public final Diff compareXML(Document control, Document test)
  {
    return new Diff(control, test);
  }
View Full Code Here

  public final void assertEqual(String msg, Document expected, Document actual)
  {
    expected.getDocumentElement().normalize();
    actual.getDocumentElement().normalize();

    Diff diff = compareXML(expected, actual);

    if (!diff.similar())
    {
      try
      {
        System.out.println("expected:");
        print(expected);
        System.out.println("actual:");
        print(actual);
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }

    assertEquals(msg+", "+diff.toString(), true, diff.similar());
  }
View Full Code Here

TOP

Related Classes of org.custommonkey.xmlunit.Diff

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.