當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。