本文整理汇总了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);
}
}
示例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());
}
示例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());
}
示例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());
}
示例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();
}
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
}
示例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);
}
示例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());
}
}
示例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);
}
示例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);
}
示例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();
}
示例15: initializeXMLUnit
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@BeforeClass (description = "Initialize XMLUnit")
public void initializeXMLUnit() {
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreComments(true);
}