本文整理汇总了Java中org.xmlunit.diff.Diff类的典型用法代码示例。如果您正苦于以下问题:Java Diff类的具体用法?Java Diff怎么用?Java Diff使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Diff类属于org.xmlunit.diff包,在下文中一共展示了Diff类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testUnMarshal
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public final void testUnMarshal() throws Exception {
// PREPARE
final String expectedXml = IOUtils.toString(this.getClass().getResourceAsStream("/esc-events.xml"));
// TEST
final EscEvents testee = unmarshal(expectedXml, EscEvents.class, MyMeta.class, MyEvent.class,
Base64Data.class);
// VERIFY
assertThat(testee).isNotNull();
assertThat(testee.getList()).isNotNull();
assertThat(testee.getList().size()).isEqualTo(2);
assertThat(testee.getList().get(0).getEventId()).isEqualTo("68616d90-cf72-4c2a-b913-32bf6e6506ed");
assertThat(testee.getList().get(1).getEventId()).isEqualTo("c198a02e-126e-4fbb-910c-918abf39a4a6");
// TEST
final String xml = marshal(testee, EscEvents.class, MyMeta.class, MyEvent.class, Base64Data.class);
// VERIFY
final Diff documentDiff = DiffBuilder.compare(expectedXml).withTest(xml).ignoreWhitespace().build();
assertThat(documentDiff.hasDifferences()).describedAs(documentDiff.toString()).isFalse();
}
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:26,代码来源:EscEventsTest.java
示例2: xmlContent
import org.xmlunit.diff.Diff; //导入依赖的package包/类
private Condition<File> xmlContent(URL expected) {
return new Condition<File>("XML Content") {
@Override
public boolean matches(File actual) {
Diff diff = DiffBuilder.compare(Input.from(expected))
.withTest(Input.from(actual)).checkForSimilar().ignoreWhitespace()
.build();
if (diff.hasDifferences()) {
try {
String content = new String(
FileCopyUtils.copyToByteArray(actual));
throw new AssertionError(diff.toString() + "\n" + content);
}
catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
return true;
}
};
}
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:24,代码来源:MavenMetadataGeneratorTests.java
示例3: assertPreservationInformationIdenticalTo
import org.xmlunit.diff.Diff; //导入依赖的package包/类
public SipFileValidator assertPreservationInformationIdenticalTo(String resource) throws IOException {
ZipEntry entry = zipFile.getEntry("eas_pdi.xml");
Assert.assertNotNull("Missing Preservation Information", entry);
try (InputStream expectedIn = owner.getClass()
.getResourceAsStream(resource); InputStream actualIn = zipFile.getInputStream(entry)) {
Diff myDiff = DiffBuilder.compare(Input.fromStream(expectedIn))
.withTest(Input.fromStream(actualIn))
.checkForSimilar()
.ignoreWhitespace()
.ignoreComments()
.build();
Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());
}
return this;
}
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:20,代码来源:SipFileValidator.java
示例4: executeOnReceive
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Override
public void executeOnReceive(MediatorHTTPRequest request) {
assertEquals(testConfig.getDynamicConfig().get("upstream-scheme"), request.getScheme());
assertEquals(testConfig.getDynamicConfig().get("upstream-host"), request.getHost());
assertEquals(testConfig.getDynamicConfig().get("upstream-port"), new Double(request.getPort()));
assertEquals(Constants.FHIR_MIME_XML, request.getHeaders().get("Content-Type"));
if (request.getParams()!=null) {
for (Pair<String, String> param : request.getParams()) {
if (param.getKey().equals("_format")) {
fail("Mediator should not forward _format param");
}
}
}
Diff diff = DiffBuilder
.compare(Input.fromString(patientXML))
.withTest(Input.fromString(request.getBody()))
.ignoreComments()
.ignoreWhitespace()
.build();
assertFalse(diff.hasDifferences());
}
开发者ID:jembi,项目名称:openhim-mediator-fhir-proxy,代码行数:24,代码来源:FhirProxyHandlerTest.java
示例5: testMarshalUnmarshalXML
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public final void testMarshalUnmarshalXML() throws Exception {
// PREPARE
final Data original = testee;
// TEST
final String xml = marshalToStr(original, createXmlAdapter(),
Data.class);
// VERIFY
final String expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ "<data type=\"MyEvent\" mime-type=\"application/xml; version=1; encoding=utf-8\">"
+ " <![CDATA[" + CONTENT + "]]>" + "</data>";
final Diff documentDiff = DiffBuilder.compare(expectedXml).withTest(xml)
.ignoreWhitespace().build();
assertThat(documentDiff.hasDifferences())
.describedAs(documentDiff.toString()).isFalse();
}
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:21,代码来源:DataTest.java
示例6: testUnMarshal
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public final void testUnMarshal() throws Exception {
// PREPARE
final String expectedXml = IOUtils.toString(this.getClass().getResourceAsStream("/esc-meta.xml"));
// TEST
final EscMeta testee = unmarshal(expectedXml, EscMeta.class, MyMeta.class, Base64Data.class);
final String actualXml = marshal(testee, EscMeta.class, MyMeta.class, Base64Data.class);
// VERIFY
final Diff documentDiff = DiffBuilder.compare(expectedXml).withTest(actualXml).ignoreWhitespace()
.build();
assertThat(documentDiff.hasDifferences()).describedAs(documentDiff.toString()).isFalse();
}
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:17,代码来源:EscMetaTest.java
示例7: testUnMarshal
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public final void testUnMarshal() throws Exception {
// PREPARE
final String expectedXml = IOUtils.toString(this.getClass().getResourceAsStream("/events.xml"));
// TEST
final Events testee = unmarshal(expectedXml, Events.class);
// VERIFY
assertThat(testee).isNotNull();
assertThat(testee.getEvents()).isNotNull();
assertThat(testee.getEvents().size()).isEqualTo(2);
assertThat(testee.getEvents().get(0).getId()).isEqualTo(new EventId("7ab8e400-373b-4f65-96e1-96b78a791a42"));
assertThat(testee.getEvents().get(1).getId()).isEqualTo(new EventId("35ae2b63-c820-4cea-8ad6-0d25e4519390"));
// TEST
final String xml = marshalToStr(testee, createXmlAdapter(), Events.class);
System.out.println(xml);
// VERIFY
final Diff documentDiff = DiffBuilder.compare(expectedXml).withTest(xml).ignoreWhitespace().build();
assertThat(documentDiff.hasDifferences()).describedAs(documentDiff.toString()).isFalse();
}
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:26,代码来源:EventsTest.java
示例8: testMarshalUnmarshalXML
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public final void testMarshalUnmarshalXML() throws Exception {
// PREPARE
final Event original = testee;
// TEST
final String xml = marshalToStr(original, createXmlAdapter(), Event.class);
// VERIFY
final String expectedXml =
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<event id=\""
+ ID.asBaseType() + "\">"
+ " <data type=\"MyEvent\" mime-type=\"application/xml; version=1; encoding=utf-8\">"
+ " <![CDATA[<myEvent/>]]>" + " </data>"
+ " <meta type=\"MyMeta\" mime-type=\"application/json; encoding=utf-8\">"
+ " <![CDATA[{ \"a\" : \"1\" }]]>" + " </meta>" + "</event>";
// @formatter:on
final Diff documentDiff = DiffBuilder.compare(expectedXml).withTest(xml).ignoreWhitespace().build();
assertThat(documentDiff.hasDifferences()).describedAs(documentDiff.toString()).isFalse();
}
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:24,代码来源:EventTest.java
示例9: testMarshalEventXML
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testMarshalEventXML() throws IOException {
// PREPARE
final String expectedXml = IOUtils.toString(
this.getClass().getResourceAsStream("/" + this.getClass().getSimpleName() + "_Event.xml"));
final UUID uuid = UUID.fromString("a07d6a1a-715d-4d8e-98fa-b158e3339303");
final CommonEvent commonEvent = new SimpleCommonEvent(new EventId(uuid), MyEvent.TYPE,
new MyEvent(uuid, "Whatever..."));
final ESHttpMarshaller testee = new ESHttpMarshaller();
// TEST
final String currentXml = testee.marshal(createXmlRegistry(), commonEvent);
// VERIFY
final Diff documentDiff = DiffBuilder.compare(expectedXml).withTest(currentXml).ignoreWhitespace()
.build();
assertThat(documentDiff.hasDifferences()).describedAs(documentDiff.toString()).isFalse();
}
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:21,代码来源:ESHttpMarshallerTest.java
示例10: testMarshalUnmarshalXML
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public final void testMarshalUnmarshalXML() throws Exception {
// PREPARE
final Slice original = testee;
// TEST
final String xml = marshalToStr(original, createXmlAdapter(), Slice.class);
// VERIFY
final String expectedXml =
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ "<slice from-stream-no=\"0\" next-stream-no=\"1\" end-of-stream=\"true\">"
+ "<event id=\"" + ID + "\">"
+ " <data type=\"MyEvent\" mime-type=\"application/xml; version=2; encoding=utf-8\">"
+ " <![CDATA[<my-event/>]]>" + " </data>" + "</event>" + "</slice>";
// @formatter:on
final Diff documentDiff = DiffBuilder.compare(expectedXml).withTest(xml).ignoreWhitespace().build();
assertThat(documentDiff.hasDifferences()).describedAs(documentDiff.toString()).isFalse();
}
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:23,代码来源:SliceTest.java
示例11: compareTmx
import org.xmlunit.diff.Diff; //导入依赖的package包/类
protected void compareTmx(File orig, File created, int count) throws Exception {
Set<String> tmxOrig = readTmxSegments(orig);
Set<String> tmxCreated = readTmxSegments(created);
assertEquals(count, tmxCreated.size());
assertEquals(tmxOrig.size(), tmxCreated.size());
List<String> listOrig = new ArrayList<>(tmxOrig);
List<String> listCreated = new ArrayList<>(tmxCreated);
for (int i = 0; i < listOrig.size(); i++) {
Diff myDiff = DiffBuilder.compare(Input.fromString(listOrig.get(i)))
.withTest(Input.fromString(listCreated.get(i)))
.checkForSimilar()
.ignoreWhitespace()
.build();
assertFalse(myDiff.hasDifferences());
}
}
开发者ID:miurahr,项目名称:tmpotter,代码行数:18,代码来源:TmxTestBase.java
示例12: compareXML
import org.xmlunit.diff.Diff; //导入依赖的package包/类
public static void compareXML(String expectedXML, String actualXML) throws SAXException, IOException {
Diff xmlDiff = DiffBuilder.compare(expectedXML).withTest(actualXML)
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName))
.ignoreWhitespace().normalizeWhitespace()
.checkForSimilar()
.build();
try {
assertFalse("pieces of XML are not similar\n" + xmlDiff, xmlDiff.hasDifferences());
} catch (AssertionError ae) {
System.out.println("--------------- ActualXML ---------------");
System.out.println(actualXML);
System.out.println("=========================================");
System.out.println("-------------- ExpectedXML --------------");
System.out.println(expectedXML);
System.out.println("=========================================");
throw ae;
}
}
开发者ID:fduminy,项目名称:jtestplatform,代码行数:20,代码来源:JUnitXMLReportWriterTest.java
示例13: testDiff_withIgnoreWhitespaces_shouldSucceed
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testDiff_withIgnoreWhitespaces_shouldSucceed() {
// prepare testData
String controlXml = "<a><b>Test Value</b></a>";
String testXml = "<a>\n <b>\n Test Value\n </b>\n</a>";
// run test
Diff myDiff = DiffBuilder.compare(Input.fromString(controlXml).build())
.withTest(Input.fromString(testXml).build())
.ignoreWhitespace()
.build();
// validate result
Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());
}
开发者ID:xmlunit,项目名称:xmlunit,代码行数:17,代码来源:DiffBuilderTest.java
示例14: testDiff_withNormalizeWhitespaces_shouldSucceed
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testDiff_withNormalizeWhitespaces_shouldSucceed() {
// prepare testData
String controlXml = "<a><b>Test Value</b></a>";
String testXml = "<a>\n <b>\n Test\n Value\n </b>\n</a>";
// run test
Diff myDiff = DiffBuilder.compare(Input.fromString(controlXml).build())
.withTest(Input.fromString(testXml).build())
.normalizeWhitespace()
.build();
// validate result
Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());
}
开发者ID:xmlunit,项目名称:xmlunit,代码行数:17,代码来源:DiffBuilderTest.java
示例15: testDiff_withNormalizeAndIgnoreWhitespaces_shouldSucceed
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testDiff_withNormalizeAndIgnoreWhitespaces_shouldSucceed() {
// prepare testData
String controlXml = "<a><b>Test Value</b></a>";
String testXml = "<a>\n <b>\n Test\n Value\n </b>\n</a>";
// run test
Diff myDiff = DiffBuilder.compare(Input.fromString(controlXml).build())
.withTest(Input.fromString(testXml).build())
.normalizeWhitespace()
.ignoreWhitespace()
.build();
// validate result
Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());
}
开发者ID:xmlunit,项目名称:xmlunit,代码行数:18,代码来源:DiffBuilderTest.java
示例16: testDiff_withCheckForIdentical_shouldFail
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testDiff_withCheckForIdentical_shouldFail() {
// prepare testData
String controlXml = "<a>Test Value</a>";
String testXml = "<a><![CDATA[Test Value]]></a>";
// run test
Diff myDiff = DiffBuilder.compare(Input.fromString(controlXml).build())
.withTest(Input.fromString(testXml).build())
.checkForIdentical()
.build();
// validate result
Assert.assertTrue(myDiff.toString(), myDiff.hasDifferences());
}
开发者ID:xmlunit,项目名称:xmlunit,代码行数:17,代码来源:DiffBuilderTest.java
示例17: testDiff_withCheckForSimilar_shouldSucceed
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testDiff_withCheckForSimilar_shouldSucceed() {
// prepare testData
String controlXml = "<a>Test Value</a>";
String testXml = "<a><![CDATA[Test Value]]></a>";
// run test
Diff myDiff = DiffBuilder.compare(Input.fromString(controlXml).build())
.withTest(Input.fromString(testXml).build())
.checkForSimilar()
.build();
// validate result
Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());
}
开发者ID:xmlunit,项目名称:xmlunit,代码行数:17,代码来源:DiffBuilderTest.java
示例18: testDiff_withIgnoreComments_shouldSucceed
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testDiff_withIgnoreComments_shouldSucceed() {
// prepare testData
String controlXml = "<a><b><!-- A comment -->Test Value</b></a>";
String testXml = "<a><b><!-- An other comment -->Test Value</b></a>";
// run test
Diff myDiff = DiffBuilder.compare(Input.fromString(controlXml).build())
.withTest(Input.fromString(testXml).build())
.ignoreComments()
.build();
// validate result
Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());
}
开发者ID:xmlunit,项目名称:xmlunit,代码行数:17,代码来源:DiffBuilderTest.java
示例19: testDiff_withIgnoreComments2_0_shouldSucceed
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testDiff_withIgnoreComments2_0_shouldSucceed() {
// prepare testData
String controlXml = "<a><b><!-- A comment -->Test Value</b></a>";
String testXml = "<a><b><!-- An other comment -->Test Value</b></a>";
// run test
Diff myDiff = DiffBuilder.compare(Input.fromString(controlXml).build())
.withTest(Input.fromString(testXml).build())
.ignoreCommentsUsingXSLTVersion("2.0")
.build();
// validate result
Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());
}
开发者ID:xmlunit,项目名称:xmlunit,代码行数:17,代码来源:DiffBuilderTest.java
示例20: testDiff_withIgnoreComments1_0_shouldSucceed
import org.xmlunit.diff.Diff; //导入依赖的package包/类
@Test
public void testDiff_withIgnoreComments1_0_shouldSucceed() {
// prepare testData
String controlXml = "<a><b><!-- A comment -->Test Value</b></a>";
String testXml = "<a><b><!-- An other comment -->Test Value</b></a>";
// run test
Diff myDiff = DiffBuilder.compare(Input.fromString(controlXml).build())
.withTest(Input.fromString(testXml).build())
.ignoreCommentsUsingXSLTVersion("1.0")
.build();
// validate result
Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());
}
开发者ID:xmlunit,项目名称:xmlunit,代码行数:17,代码来源:DiffBuilderTest.java
注:本文中的org.xmlunit.diff.Diff类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论