Package org.custommonkey.xmlunit

Examples of org.custommonkey.xmlunit.Diff


    }

    @Test
    public void testArrayOfArraysOfObjects() throws Exception {
        String xml = convertToXml("{\"root\":[[{\"a\":1, \"e\":true}, {\"b\":2}],[{\"c\":3}, {\"d\":4}]]}");
        Diff diff = XMLUnit.compareXML(
                "<root>\n" +
                "   <root>\n" +
                "      <root>\n" +
                "         <a>1</a>\n" +
                "         <e>true</e>\n" +
                "      </root>\n" +
                "      <root>\n" +
                "         <b>2</b>\n" +
                "      </root>\n" +
                "   </root>\n" +
                "   <root>\n" +
                "      <root>\n" +
                "         <c>3</c>\n" +
                "      </root>\n" +
                "      <root>\n" +
                "         <d>4</d>\n" +
                "      </root>\n" +
                "   </root>\n" +
                "</root>", xml);
        assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here


        assertTrue(diff.toString(), diff.similar());
    }
    @Test
    public void testArrayOfArraysOfObjectsInRoot() throws Exception {
        String xml = convertToXml("[[{\"a\":1, \"e\":true}, {\"b\":2}],[{\"c\":3}, {\"d\":4}]]", new JsonXmlReader("", false, "root"));
        Diff diff = XMLUnit.compareXML(
                "<root>\n" +
                "   <root>\n" +
                "      <root>\n" +
                "         <a>1</a>\n" +
                "         <e>true</e>\n" +
                "      </root>\n" +
                "      <root>\n" +
                "         <b>2</b>\n" +
                "      </root>\n" +
                "   </root>\n" +
                "   <root>\n" +
                "      <root>\n" +
                "         <c>3</c>\n" +
                "      </root>\n" +
                "      <root>\n" +
                "         <d>4</d>\n" +
                "      </root>\n" +
                "   </root>\n" +
                "</root>", xml);
        assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here


    @Test
    public void testArrayOfScalars() throws Exception {
        String xml = convertToXml("{\"a\":[1,2,3]}");
        Diff diff = XMLUnit.compareXML("<a><a>1</a><a>2</a><a>3</a></a>", xml);
        assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here

    }

    @Test
    public void testMapOfObjects() throws Exception {
        String xml = convertToXml("{\"root\":{\"a\":1, \"b\":2}}");
        Diff diff = XMLUnit.compareXML("<root><a>1</a><b>2</b></root>", xml);
        assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here

    }

    @Test
    public void testArrayOfComplexObjects() throws Exception {
        String xml = convertToXml("{\"root\":[{\"a\":{\"a1\":1}}, {\"b\":2}]}");
        Diff diff = XMLUnit.compareXML("<root><root><a><a1>1</a1></a></root><root><b>2</b></root></root>", xml);
        assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here

    }

    @Test
    public void testXmlEscaping() throws Exception {
        String xml = convertToXml("{\"root\":\"<a>\"}");
        Diff diff = XMLUnit.compareXML("<root>&lt;a&gt;</root>", xml);
        assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here

      String expectedStr = sw.toString();
     
      //get the file name in case of a failure
      FitsMetadataElement item = fitsOut.getMetadataElement("filename");
        DifferenceListener myDifferenceListener = new IgnoreAttributeValuesDifferenceListener();
        Diff diff = new Diff(expectedStr,actualStr);
        diff.overrideDifferenceListener(myDifferenceListener);

        if(diff.similar()) {
          System.out.println("PASS: "+item.getValue());
          passed++;
        }
        else {
          System.err.println("FAIL: "+item.getValue());
View Full Code Here

        bean.map.put("key1", "value1");
        bean.map.put("key2", "value2");
        XMLStreamReader reader = new BeanXMLStreamReaderImpl(null, bean);
        XMLStreamReader2String t3 = new XMLStreamReader2String();
        String xml = t3.transform(reader, null);
        Diff diff = new Diff(XML_RESULT, xml);
        Diff diff1 = new Diff(XML_RESULT1, xml);
        assertTrue(diff.similar() || diff1.similar());
    }
View Full Code Here

    final Reader reader = new InputStreamReader(new ByteArrayInputStream(goldData), "UTF-8");
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(reportOutput);
    final Reader report = new InputStreamReader(inputStream, "UTF-8");
    try
    {
      XMLAssert.assertXMLEqual("File " + goldSample + " failed", new Diff(reader, report), true);
    }
    catch (AssertionFailedError afe)
    {
      debugOutput(reportOutput, goldSample);
      throw afe;
View Full Code Here

    }

    protected Diff createDiff(Source payload) {
        Document expectedDocument = createDocumentFromSource(expected);
        Document actualDocument = createDocumentFromSource(payload);
        return new Diff(expectedDocument, actualDocument);
    }
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.