当前位置: 首页>>代码示例>>Java>>正文


Java XMLUnit.setIgnoreAttributeOrder方法代码示例

本文整理汇总了Java中org.custommonkey.xmlunit.XMLUnit.setIgnoreAttributeOrder方法的典型用法代码示例。如果您正苦于以下问题:Java XMLUnit.setIgnoreAttributeOrder方法的具体用法?Java XMLUnit.setIgnoreAttributeOrder怎么用?Java XMLUnit.setIgnoreAttributeOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.custommonkey.xmlunit.XMLUnit的用法示例。


在下文中一共展示了XMLUnit.setIgnoreAttributeOrder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compare

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Override
protected boolean compare(File baselineFile, File comparisonFile) {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

        factory.setNamespaceAware(true);
        factory.setCoalescing(true);
        factory.setIgnoringElementContentWhitespace(true);
        factory.setIgnoringComments(true);

        DocumentBuilder builder = factory.newDocumentBuilder();
        Document baselineXml = builder.parse(baselineFile);
        Document comparisonXml = builder.parse(comparisonFile);

        baselineXml.normalizeDocument();
        comparisonXml.normalizeDocument();

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

        return XMLUnit.compareXML(baselineXml, comparisonXml).similar();
    } catch (SAXException | IOException | ParserConfigurationException e) {
        throw new TransformationUtilityException("An exception happened when comparing the two XML files", e);
    }
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:27,代码来源:CompareXMLFiles.java

示例2: assertEqualsXml

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
/**
 * Assert that the specified XML file has not semantically changed,
 * although it might be identical to the original one due to format
 * changes, comments not being present, etc
 *
 * @param relativeFilePath relative path to file to be evaluated
 * @throws ParserConfigurationException
 * @throws IOException
 * @throws SAXException
 */
protected void assertEqualsXml(String relativeFilePath) throws ParserConfigurationException, IOException, SAXException {
    File originalFile = new File(appFolder, relativeFilePath);
    File transformedFile = new File(transformedAppFolder, relativeFilePath);

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

    factory.setNamespaceAware(true);
    factory.setCoalescing(true);
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);

    DocumentBuilder builder = factory.newDocumentBuilder();
    Document originalXml = builder.parse(originalFile);
    Document transformedXml = builder.parse(transformedFile);

    originalXml.normalizeDocument();
    transformedXml.normalizeDocument();

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

    Assert.assertTrue(XMLUnit.compareXML(originalXml, transformedXml).similar());
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:35,代码来源:TransformationUtilityTestHelper.java

示例3: testCreateElement

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void testCreateElement() throws Exception {
    final Document document = XmlUtil.newDocument();
    final Element top = XmlUtil.createElement(document, "top", Optional.of("namespace"));

    top.appendChild(XmlUtil.createTextElement(document, "innerText", "value", Optional.of("namespace")));
    top.appendChild(XmlUtil.createTextElementWithNamespacedContent(document, "innerPrefixedText", "pref", "prefixNamespace", "value", Optional.of("namespace")));
    top.appendChild(XmlUtil.createTextElementWithNamespacedContent(document, "innerPrefixedText", "pref", "prefixNamespace", "value", Optional.of("randomNamespace")));

    document.appendChild(top);
    assertEquals("top", XmlUtil.createDocumentCopy(document).getDocumentElement().getTagName());

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

    final Diff diff = XMLUnit.compareXML(XMLUnit.buildControlDocument(xml), document);
    assertTrue(diff.toString(), diff.similar());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:XmlUtilTest.java

示例4: testMarshalAsByteArrayOutputStream

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void testMarshalAsByteArrayOutputStream()
        throws SimpleMarshallerException, SAXException, IOException {
    // Arrange
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreWhitespace(true);
    final String expectedOutput = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ruleExecutionContainer><executionResponseList/></ruleExecutionContainer>";
    final RuleExecutionContainer r = createRuleExecutionContainer();

    // Act
    final ByteArrayOutputStream output = marshaller
            .marshalAsByteArrayOutputStream(r);

    assertNotNull(output);
    assertXMLEqual(expectedOutput, output.toString());
}
 
开发者ID:bhits,项目名称:common-libraries,代码行数:18,代码来源:SimpleMarshallerImplTest.java

示例5: testOrders

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void testOrders() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();

    httpMixIn.initialize();
    try {
        XMLUnit.setIgnoreWhitespace(true);
        XMLUnit.setIgnoreAttributeOrder(true);
        String wsdl = httpMixIn.sendString("http://localhost:8080/quickstart-bean/OrderService?wsdl", "", HTTPMixIn.HTTP_GET);
        compareWSDL(new InputStreamReader(Classes.getResourceAsStream("OrderService.wsdl")), new StringReader(wsdl));
        String response = httpMixIn.postString("http://localhost:8080/quickstart-bean/OrderService", SOAP_REQUEST);
        XMLAssert.assertXpathEvaluatesTo("PO-19838-XYZ", "//orderAck/orderId", response);
        XMLAssert.assertXpathEvaluatesTo("true", "//orderAck/accepted", response);
        XMLAssert.assertXpathEvaluatesTo("Order Accepted [intercepted]", "//orderAck/status", response);
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:19,代码来源:BeanServiceQuickstartTest.java

示例6: setUp

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
  // Initialise the GATE library and creole register
  Gate.init();

  XMLUnit.setIgnoreComments(true);
  XMLUnit.setIgnoreWhitespace(true);
  XMLUnit.setIgnoreAttributeOrder(true);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:10,代码来源:TestCreoleAnnotationHandler.java

示例7: assertXMLEquals

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
public static void assertXMLEquals(String expectedXML, String actualXML) throws Exception {
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
    XMLUnit.setIgnoreAttributeOrder(true);

    DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedXML, actualXML));

    List<?> allDifferences = diff.getAllDifferences();
    Assert.assertEquals("Differences found: "+ diff.toString(), 0, allDifferences.size());
}
 
开发者ID:hashmapinc,项目名称:WitsmlObjectsLibrary,代码行数:11,代码来源:TestUtilities.java

示例8: assertXMLEquals

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
private void assertXMLEquals(String expectedXML, String actualXML) throws SAXException, IOException {
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setNormalize(true);
    DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedXML, actualXML));
    List<?> allDifferences = diff.getAllDifferences();
    Assert.assertEquals("XML differences found: " + diff.toString(), 0, allDifferences.size());
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:9,代码来源:DLNAServiceTest.java

示例9: assertXmlEqual

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
/**
 * Parse the expected and actual content strings as XML and assert that the
 * two are "similar" -- i.e. they contain the same elements and attributes
 * regardless of order.
 * <p>Use of this method assumes the
 * <a href="http://xmlunit.sourceforge.net/">XMLUnit<a/> library is available.
 * @param expected the expected XML content
 * @param actual the actual XML content
 * @see org.springframework.test.web.servlet.result.MockMvcResultMatchers#xpath(String, Object...)
 * @see org.springframework.test.web.servlet.result.MockMvcResultMatchers#xpath(String, Map, Object...)
 */
public void assertXmlEqual(String expected, String actual) throws Exception {
	XMLUnit.setIgnoreWhitespace(true);
	XMLUnit.setIgnoreComments(true);
	XMLUnit.setIgnoreAttributeOrder(true);

	Document control = XMLUnit.buildControlDocument(expected);
	Document test = XMLUnit.buildTestDocument(actual);
	Diff diff = new Diff(control, test);
	if (!diff.similar()) {
		AssertionErrors.fail("Body content " + diff.toString());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:XmlExpectationsHelper.java

示例10: setUp

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    // Arrange
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
    fileReader = new FileReaderImpl();
    xacmlResult = "<xacmlResult><pdpDecision>Permit</pdpDecision><purposeOfUse>TREATMENT</purposeOfUse><messageId>4617a579-1881-4e40-9f98-f85bd81d6502</messageId><homeCommunityId>2.16.840.1.113883.3.467</homeCommunityId><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:org:us-privacy-law:42CFRPart2</pdpObligation><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:org:refrain-policy:NORDSLCD</pdpObligation><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:patient:redact:ETH</pdpObligation><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:patient:redact:PSY</pdpObligation><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:patient:mask:HIV</pdpObligation></xacmlResult>";
    xmlTransformer = new XmlTransformerImpl(new SimpleMarshallerImpl());
    documentFactModelExtractor = new DocumentFactModelExtractorImpl(
            xmlTransformer);
}
 
开发者ID:bhits,项目名称:dss-api,代码行数:13,代码来源:DocumentFactModelExtractorImplTest.java

示例11: assertXMLIgnorePrefix

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
public static void assertXMLIgnorePrefix(String aMessage, Document aExpected, Document aActual) throws Exception {
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);

    Diff diff = new Diff(aExpected, aActual);
    diff.overrideDifferenceListener(new DifferenceListener() {

        public void skippedComparison(Node aArg0, Node aArg1) {
        }

        public int differenceFound(Difference aDifference) {
            if (aDifference.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) {
                return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
            }
            return DifferenceListener.RETURN_ACCEPT_DIFFERENCE;
        }
    });
    try {
        XMLAssert.assertXMLEqual(diff, true);
    } catch (Throwable t) {
        dump(aActual);
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        fail(sw.toString());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:XmlFixture.java

示例12: isXMLEqual

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
protected void isXMLEqual(Document control, Document test)
		throws SAXException, IOException {
	XMLUnit.setIgnoreWhitespace(true);
	XMLUnit.setIgnoreAttributeOrder(true);
	XMLUnit.setIgnoreComments(true);
	XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
	// XMLUnit.setNormalize(true);

	// Diff diff = compareXML (control, test);

	assertXMLEqual(control, test);
}
 
开发者ID:EXIficient,项目名称:exificient,代码行数:13,代码来源:DOMRoundtrip.java

示例13: isXMLEqual

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
protected void isXMLEqual(String sXMLDecoded) throws SAXException,
		IOException {
	StringReader control = new StringReader(xml);
	StringReader test = new StringReader(sXMLDecoded);

	XMLUnit.setIgnoreWhitespace(true);

	// Diff diff = compareXML ( control, test );
	// XMLUnit.setNormalize ( true );

	XMLUnit.setIgnoreAttributeOrder(true);

	assertXMLEqual(control, test);
}
 
开发者ID:EXIficient,项目名称:exificient,代码行数:15,代码来源:AbstractProperties.java

示例14: beforeClass

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
	XMLUnit.setIgnoreAttributeOrder(true);
	XMLUnit.setIgnoreComments(true);
	XMLUnit.setIgnoreWhitespace(true);
	ourCtx = new FhirContext();
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:8,代码来源:XmlParserTest.java

示例15: initializeXMLUnit

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@BeforeClass (description = "Initialize XMLUnit")
public void initializeXMLUnit() {
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
}
 
开发者ID:Technolords,项目名称:microservice-mock,代码行数:7,代码来源:ConfigCommandTest.java


注:本文中的org.custommonkey.xmlunit.XMLUnit.setIgnoreAttributeOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。