本文整理了Java中org.xmlunit.diff.Diff.toString()
方法的一些代码示例,展示了Diff.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Diff.toString()
方法的具体详情如下:
包路径:org.xmlunit.diff.Diff
类名称:Diff
方法名:toString
暂无
代码示例来源:origin: spring-projects/spring-framework
@Override
public String toString() {
return this.diff.toString();
}
代码示例来源:origin: jamesdbloom/mockserver
public boolean matches(final HttpRequest context, NottableString matched) {
boolean result = false;
if (diffBuilder != null) {
try {
Diff diff = diffBuilder.withTest(Input.fromString(normaliseXmlString(matched.getValue()))).build();
result = !diff.hasDifferences();
if (!result) {
mockServerLogger.trace("Failed to match [{}] with schema [{}] because [{}]", matched, this.matcher, diff.toString());
}
} catch (Exception e) {
mockServerLogger.trace(context, "Failed to match [{}] with schema [{}] because [{}]", matched, this.matcher, e.getMessage());
}
}
return matcher.isNot() != (not != result);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test
@Override
public String toString() {
return this.diff.toString();
}
代码示例来源:origin: org.xmlunit/xmlunit-core
@Override
public String toString() {
return toString(formatter);
}
代码示例来源:origin: nl.vpro.shared/vpro-shared-test
public static void similar(InputStream input, InputStream expected) throws IOException, SAXException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
IOUtils.copy(input, bytes);
ByteArrayOutputStream expectedBytes = new ByteArrayOutputStream();
IOUtils.copy(expected, expectedBytes);
Diff diff = DiffBuilder
.compare(expected)
.withTest(input)
.checkForSimilar()
.build();
if (diff.hasDifferences()) {
throw new ComparisonFailure(diff.toString(), expectedBytes.toString(), bytes.toString());
}
}
代码示例来源:origin: nl.vpro.shared/vpro-shared-test
public static void similar(InputStream input, String expected) throws IOException, SAXException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Diff diff = DiffBuilder
.compare(expected)
.withTest(input)
.ignoreComments()
.checkForSimilar()
.build();
if (diff.hasDifferences()) {
throw new ComparisonFailure(diff.toString(), expected, bytes.toString());
}
}
代码示例来源:origin: nl.vpro.shared/vpro-shared-test
public static void similar(String input, String expected, Consumer<DiffBuilder>... build) throws IOException, SAXException {
DiffBuilder builder = DiffBuilder
.compare(expected)
.withTest(input)
.ignoreWhitespace()
.checkForSimilar()
;
for (Consumer<DiffBuilder> b : build) {
b.accept(builder);
}
try {
Diff diff = builder.build();
if (diff.hasDifferences()) {
throw new ComparisonFailure(diff.toString(), expected, input);
} else {
assertThat(diff.hasDifferences()).isFalse();
}
} catch (XMLUnitException xue) {
throw new ComparisonFailure(xue.getMessage(), expected, input);
}
}
代码示例来源:origin: dita-ot/dita-ot
private void assertXMLEqual(Document exp, Document act) {
final Diff d = DiffBuilder
.compare(exp)
.withTest(act)
.build();
if (d.hasDifferences()) {
throw new AssertionError(d.toString());
}
}
代码示例来源:origin: dita-ot/dita-ot
public static void assertXMLEqual(InputSource exp, InputSource act) {
try {
final Diff d;
d = DiffBuilder
.compare(ignoreComments(builderFactory.newDocumentBuilder().parse(exp)))
.withTest(ignoreComments(builderFactory.newDocumentBuilder().parse(act)))
.ignoreWhitespace()
.withNodeFilter(node -> node.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE)
.build();
if (d.hasDifferences()) {
throw new AssertionError(d.toString());
}
} catch (SAXException | IOException | ParserConfigurationException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.mock-server/mockserver-core
public boolean matches(final HttpRequest context, NottableString matched) {
boolean result = false;
if (diffBuilder != null) {
try {
Diff diff = diffBuilder.withTest(Input.fromString(normaliseXmlString(matched.getValue()))).build();
result = !diff.hasDifferences();
if (!result) {
mockServerLogger.trace("Failed to match [{}] with schema [{}] because [{}]", matched, this.matcher, diff.toString());
}
} catch (Exception e) {
mockServerLogger.trace(context, "Failed to match [{}] with schema [{}] because [{}]", matched, this.matcher, e.getMessage());
}
}
return matcher.isNot() != (not != result);
}
代码示例来源:origin: dita-ot/dita-ot
public static void assertHtmlEqual(InputSource exp, InputSource act) {
final DocumentBuilderFactory builderFactory = new HTMLDocumentBuilderFactory();
try {
final Diff d = DiffBuilder
.compare(ignoreComments(builderFactory.newDocumentBuilder().parse(exp)))
.withTest(ignoreComments(builderFactory.newDocumentBuilder().parse(act)))
.ignoreWhitespace()
.normalizeWhitespace()
.withNodeFilter(node -> node.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE)
.build();
if (d.hasDifferences()) {
throw new AssertionError(d.toString());
}
} catch (SAXException | IOException | ParserConfigurationException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: dita-ot/dita-ot
public static void assertXMLEqual(Document exp, Document act) {
final Diff d = DiffBuilder
.compare(ignoreComments(exp))
.withTest(ignoreComments(act))
.ignoreWhitespace()
.normalizeWhitespace()
.withNodeFilter(node -> node.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE)
.build();
if (d.hasDifferences()) {
throw new AssertionError(d.toString());
}
}
代码示例来源:origin: com.powsybl/powsybl-commons
protected static void compareXml(InputStream expected, InputStream actual) {
Source control = Input.fromStream(expected).build();
Source test = Input.fromStream(actual).build();
Diff myDiff = DiffBuilder.compare(control).withTest(test).ignoreWhitespace().ignoreComments().build();
boolean hasDiff = myDiff.hasDifferences();
if (hasDiff) {
System.err.println(myDiff.toString());
}
assertFalse(hasDiff);
}
代码示例来源:origin: de.juplo.yourshouter.api/data-model
public void assertXmlEquals(String path, ByteArrayOutputStream os)
{
Diff diff =
DiffBuilder
.compare(Input.fromStream(TestData.get(path)))
.withTest(Input.fromByteArray(os.toByteArray()))
.ignoreComments()
.ignoreWhitespace()
.withComparisonFormatter(new ShowDiffComparisonFormatter())
.build();
assertFalse(diff.toString(), diff.hasDifferences());
}
代码示例来源:origin: de.juplo.yourshouter.api/data-model
@Override
public void compareTo(String path, ByteArrayOutputStream os)
{
Diff diff =
DiffBuilder
.compare(Input.fromStream(TestData.get(path + ".xml")))
.withTest(Input.fromByteArray(os.toByteArray()))
.ignoreComments()
.ignoreWhitespace()
.withComparisonFormatter(new ShowDiffComparisonFormatter())
.build();
assertFalse(diff.toString(), diff.hasDifferences());
}
}
内容来源于网络,如有侵权,请联系作者删除!