當前位置: 首頁>>代碼示例>>Java>>正文


Java IgnoreTextAndAttributeValuesDifferenceListener類代碼示例

本文整理匯總了Java中org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener的典型用法代碼示例。如果您正苦於以下問題:Java IgnoreTextAndAttributeValuesDifferenceListener類的具體用法?Java IgnoreTextAndAttributeValuesDifferenceListener怎麽用?Java IgnoreTextAndAttributeValuesDifferenceListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IgnoreTextAndAttributeValuesDifferenceListener類屬於org.custommonkey.xmlunit包,在下文中一共展示了IgnoreTextAndAttributeValuesDifferenceListener類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: thenXMLResponseSimilarToFile

import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener; //導入依賴的package包/類
@Then("verify REST-XML response is similar to '$file'")
public void thenXMLResponseSimilarToFile(String file) throws IOException, SAXException {
    File fileFromResources = getFileFromResourcesByFilePath(file);
    List<String> expected = Files.readLines(fileFromResources, Charset.defaultCharset());
    String expectedXml = expected.stream()
            .map(StringUtils::chomp)
            .map(StringUtils::strip)
            .collect(Collectors.joining());
    Response response = getVariableValue(KEY);
    String actualXml = response.getBody().asString();
    Diff diff = new Diff(expectedXml, actualXml);
    diff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener());
    StringBuffer stringBuffer = diff.appendMessage(new StringBuffer());
    stringBuffer.append("\nExpected: ")
            .append(expectedXml)
            .append("\n     but: ")
            .append(actualXml)
            .append("\n");
    assertTrue(stringBuffer.toString(), diff.similar());
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:21,代碼來源:RestXMLOnlySteps.java

示例2: verifyThatResponseIsSimilarToFile

import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener; //導入依賴的package包/類
@Then("verify that response is similar to file '$filePath'")
public void verifyThatResponseIsSimilarToFile(String filePath) throws SOAPException, IOException, SAXException {
    FileReader expectedResponseXML = new FileReader(getFileFromResourcesByFilePath(filePath));
    SOAPMessage rawSoapResponse = (SOAPMessage) Thucydides.getCurrentSession().get(RESPONSE);
    String cleanResponse = getXmlPayload(rawSoapResponse);
    StringReader actualResponseXML = new StringReader(cleanResponse);
    Diff diff = new Diff(expectedResponseXML, actualResponseXML);
    diff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener());
    StringBuffer stringBuffer = diff.appendMessage(new StringBuffer());
    assertTrue(stringBuffer.toString(), diff.similar());
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:12,代碼來源:WebserviceSteps.java

示例3: verifyFileIsSimilarToFile

import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener; //導入依賴的package包/類
@Override
public void verifyFileIsSimilarToFile(String filePath, File lastDownloadedFile) throws IOException, SAXException, ParserConfigurationException {
    FileReader controlXML = new FileReader(getFileFromResourcesByFilePath(filePath));
    FileReader testXML = new FileReader(lastDownloadedFile);
    Diff diff = new Diff(controlXML, testXML);
    diff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener());
    XMLAssert.assertXMLEqual(diff, true);
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:9,代碼來源:XmlProvider.java

示例4: testTranslation

import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener; //導入依賴的package包/類
@Test
public void testTranslation() throws Exception {
    final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream(xmlPath);

    final XMLInputFactory factory = XMLInputFactory.newInstance();
    final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream);

    final NormalizedNodeResult result = new NormalizedNodeResult();
    final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);

    final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schema, containerNode);
    xmlParser.parse(reader);

    final NormalizedNode<?, ?> built = result.getResult();
    assertNotNull(built);

    if (expectedNode != null) {
        org.junit.Assert.assertEquals(expectedNode, built);
    }

    final Document document = UntrustedXML.newDocumentBuilder().newDocument();
    final DOMResult domResult = new DOMResult(document);

    final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);

    final XMLStreamWriter xmlStreamWriter = outputFactory.createXMLStreamWriter(domResult);

    final NormalizedNodeStreamWriter xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter
            .create(xmlStreamWriter, schema);

    final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
            xmlNormalizedNodeStreamWriter);

    normalizedNodeWriter.write(built);

    final Document doc = loadDocument(xmlPath);

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setNormalize(true);

    final String expectedXml = toString(doc.getDocumentElement());
    final String serializedXml = toString(domResult.getNode());

    final Diff diff = new Diff(expectedXml, serializedXml);
    diff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener());
    diff.overrideElementQualifier(new ElementNameAndTextQualifier());

    // FIXME the comparison cannot be performed, since the qualifiers supplied by XMlUnit do not work correctly in
    // this case
    // We need to implement custom qualifier so that the element ordering does not mess the DIFF
    // dd.overrideElementQualifier(new MultiLevelElementNameAndTextQualifier(100, true));
    // assertTrue(dd.toString(), dd.similar());

    //new XMLTestCase() {}.assertXMLEqual(diff, true);
}
 
開發者ID:opendaylight,項目名稱:yangtools,代碼行數:59,代碼來源:NormalizedNodeXmlTranslationTest.java

示例5: testEjbJar

import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener; //導入依賴的package包/類
/**
 * TODO Doesn't seem there are any asserts here
 *
 * @throws Exception
 */
public void testEjbJar() throws Exception {
    final String fileName = "ejb-jar-example1.xml";

    final Event test = Event.start("Test");

    final URL resource = this.getClass().getClassLoader().getResource(fileName);

    final String expected = IO.slurp(resource);

    final Event ejbJarJAXBCreate = Event.start("EjbJarJAXBCreate");
    ejbJarJAXBCreate.stop();

    final Event unmarshalEvent = Event.start("unmarshal");
    final Object value;

    final EjbJar$JAXB jaxbType = new EjbJar$JAXB();
    value = Sxc.unmarshalJavaee(resource, jaxbType);

    unmarshalEvent.stop();

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();

    final Event marshall = Event.start("marshall");
    Sxc.marshall(jaxbType, value, baos);
    marshall.stop();

    final String result = new String(baos.toByteArray(), "UTF-8");

    XMLUnit.setIgnoreComments(Boolean.TRUE);
    XMLUnit.setIgnoreWhitespace(Boolean.TRUE);
    XMLUnit.setIgnoreAttributeOrder(Boolean.TRUE);
    XMLUnit.setIgnoreDiffBetweenTextAndCDATA(Boolean.TRUE);

    final Diff diff = new Diff(expected.trim(), result.trim());
    final Diff myDiff = new DetailedDiff(diff);

    final AtomicInteger differenceNumber = new AtomicInteger(0); // just to get an int wrapper for the test
    myDiff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener() {
        @Override
        public int differenceFound(final Difference difference) {
            if (!difference.isRecoverable()) {
                differenceNumber.incrementAndGet();
                System.err.println(">>> " + difference.toString());
            }
            return 0;
        }
    });

    assertTrue("Files are not identical", myDiff.identical());
    test.stop();
}
 
開發者ID:apache,項目名稱:tomee,代碼行數:57,代碼來源:EjbJarXmlTest.java

示例6: testNormalizedNodeToXmlSerialization

import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener; //導入依賴的package包/類
@Test
public void testNormalizedNodeToXmlSerialization() throws XMLStreamException, IOException, SAXException {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/baz.yang");

    final Document doc = loadDocument("/baz.xml");

    final DOMResult domResult = new DOMResult(UntrustedXML.newDocumentBuilder().newDocument());

    final XMLOutputFactory factory = XMLOutputFactory.newInstance();
    factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);

    final XMLStreamWriter xmlStreamWriter = factory.createXMLStreamWriter(domResult);

    final NormalizedNodeStreamWriter xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(
            xmlStreamWriter, schemaContext);

    final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
            xmlNormalizedNodeStreamWriter);

    normalizedNodeWriter.write(buildOuterContainerNode());

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setNormalize(true);

    final String expectedXml = toString(doc.getDocumentElement());
    final String serializedXml = toString(domResult.getNode());
    final Diff diff = new Diff(expectedXml, serializedXml);

    final DifferenceListener differenceListener = new IgnoreTextAndAttributeValuesDifferenceListener();
    diff.overrideDifferenceListener(differenceListener);

    new XMLTestCase() {}.assertXMLEqual(diff, true);
}
 
開發者ID:opendaylight,項目名稱:yangtools,代碼行數:34,代碼來源:NormalizedNodesToXmlTest.java

示例7: testWrite

import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener; //導入依賴的package包/類
@Test
public void testWrite() throws XMLStreamException, IOException, SAXException {
    final Document doc = loadDocument("/foobar.xml");

    final DOMResult domResult = new DOMResult(UntrustedXML.newDocumentBuilder().newDocument());

    final XMLOutputFactory factory = XMLOutputFactory.newInstance();
    factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);

    final XMLStreamWriter xmlStreamWriter = factory.createXMLStreamWriter(domResult);

    final NormalizedNodeStreamWriter schemalessXmlNormalizedNodeStreamWriter =
            XMLStreamNormalizedNodeStreamWriter.createSchemaless(xmlStreamWriter);

    final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
            schemalessXmlNormalizedNodeStreamWriter);

    normalizedNodeWriter.write(buildOuterContainerNode());

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setNormalize(true);

    final String expectedXml = toString(doc.getDocumentElement());
    final String serializedXml = toString(domResult.getNode());
    final Diff diff = new Diff(expectedXml, serializedXml);

    final DifferenceListener differenceListener = new IgnoreTextAndAttributeValuesDifferenceListener();
    diff.overrideDifferenceListener(differenceListener);

    XMLAssert.assertXMLEqual(diff, true);
}
 
開發者ID:opendaylight,項目名稱:yangtools,代碼行數:32,代碼來源:SchemalessXMLStreamNormalizedNodeStreamWriterTest.java


注:本文中的org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。