• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultNodeMatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.xmlunit.diff.DefaultNodeMatcher的典型用法代码示例。如果您正苦于以下问题:Java DefaultNodeMatcher类的具体用法?Java DefaultNodeMatcher怎么用?Java DefaultNodeMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: compareXML

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的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


示例2: testPerformExport

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public final void testPerformExport() throws IOException, SaveException {
    String xmlFileName = filename.replace(".bib", ".xml");
    Path importFile = resourceDir.resolve(filename);

    List<BibEntry> entries = testImporter.importDatabase(importFile, StandardCharsets.UTF_8).getDatabase()
            .getEntries();

    msBibExportFormat.export(databaseContext, tempFile, charset, entries);

    Builder control = Input.from(Files.newInputStream(resourceDir.resolve(xmlFileName)));
    Builder test = Input.from(Files.newInputStream(tempFile));

    assertThat(test, CompareMatcher.isSimilarTo(control)
            .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:17,代码来源:MSBibExportFormatTestFiles.java


示例3: testPerformExport

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public final void testPerformExport() throws IOException, SaveException {
    String xmlFileName = filename.replace(".bib", ".xml");
    Path importFile = resourceDir.resolve(filename);
    String tempFilename = tempFile.getCanonicalPath();

    List<BibEntry> entries = testImporter.importDatabase(importFile, StandardCharsets.UTF_8).getDatabase()
            .getEntries();

    bibtexmlExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);

    Builder control = Input.from(Files.newInputStream(resourceDir.resolve(xmlFileName)));
    Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));

    Assert.assertThat(test, CompareMatcher.isSimilarTo(control)
            .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:18,代码来源:BibTeXMLExporterTestFiles.java


示例4: testImportAsModsAndExportAsMods

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public final void testImportAsModsAndExportAsMods() throws Exception {
    String xmlFileName = filename.replace(".bib", ".xml");
    String tempFilename = tempFile.getCanonicalPath();
    Path xmlFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI());

    List<BibEntry> entries = modsImporter.importDatabase(xmlFile, charset).getDatabase().getEntries();

    modsExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);

    Builder control = Input.from(Files.newInputStream(xmlFile));
    Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));

    Assert.assertThat(test, CompareMatcher.isSimilarTo(control)
            .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:17,代码来源:ModsExportFormatTestFiles.java


示例5: compare

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
public XMLFileAssertion compare(Builder in1, Builder in2) {

		diffBuilder = DiffBuilder.compare(in1).withTest(in2).withNodeFilter(new Predicate<Node>() {
			public boolean test(Node node) {
				LOGGER.trace("current node " + node.getNodeName() + " result "
						+ String.valueOf(!tokens.contains(node.getNodeName())));
				
				return !tokens.contains(node.getNodeName());
			}
		}).withAttributeFilter(new Predicate<Attr>() {
			public boolean test(Attr a) {
				LOGGER.trace("current attr " + a.getName() + " result "
						+ String.valueOf(!attrs.contains(a.getName())));
				
				return !attrs.contains(a.getName());
			}
		
		});

		if(context.ignoreWhitespaces){
			diffBuilder.ignoreWhitespace();
		}if(context.checkForIdentical){
			diffBuilder.checkForIdentical();
		}if(context.checkForSimilar){
			diffBuilder.checkForSimilar();
		}if(context.selector!=null){
			diffBuilder.withNodeMatcher(new DefaultNodeMatcher(context.selector));
		}
		
		return this;
	}
 
开发者ID:rockitconsulting,项目名称:test.rockitizer,代码行数:32,代码来源:XMLFileAssertion.java


示例6: valueCompositeXmlEquality

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public void valueCompositeXmlEquality()
{
    // START SNIPPET: xml-serialization
    try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
    {
        Some valueInstance = buildSomeValue( moduleInstance, uow, "42" );

        // Serialize using injected service
        String serializedXml = xmlSerialization.serialize( valueInstance );
        System.out.println( serializedXml );

        // Deserialize using Module API
        Some valueFromSerializedState = moduleInstance.newValueFromSerializedState( Some.class, serializedXml );
        assertThat( "Deserialized Value equality", valueInstance, equalTo( valueFromSerializedState ) );
        // END SNIPPET: xml-serialization

        // value.toString()
        // Need to loosely compare because of HashMaps not retaining order
        String valueXmlWithoutTypeInfo = xmlSerialization.serialize( Serializer.Options.NO_TYPE_INFO, valueFromSerializedState );
        assertThat( "value.toString() XML equality",
                    valueFromSerializedState.toString(),
                    isSimilarTo( valueXmlWithoutTypeInfo )
                        .withNodeMatcher( new DefaultNodeMatcher( ElementSelectors.byNameAndAllAttributes ) ) );
        // START SNIPPET: xml-serialization
    }
    // END SNIPPET: xml-serialization
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:29,代码来源:JavaxXmlValueCompositeSerializationTest.java


示例7: compareXml

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
public static void compareXml(String content, String reEncoded) {
	Diff d = DiffBuilder.compare(Input.fromString(content))
		.withTest(Input.fromString(reEncoded))
		.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
		.checkForSimilar()
		.ignoreWhitespace() // this is working with newest Saxon 9.8.0-2 (not worked with 9.7.0-15
		.ignoreComments() // this is not working even with newest Saxon 9.8.0-2
		.withComparisonController(ComparisonControllers.Default)
		.build();

	assertTrue(d.toString(), !d.hasDifferences());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:13,代码来源:XmlParserDstu3Test.java


示例8: compareXml

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
public static void compareXml(String content, String reEncoded) {
	Diff d = DiffBuilder.compare(Input.fromString(content))
			.withTest(Input.fromString(reEncoded))
			.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
			.checkForSimilar()
			.ignoreWhitespace()
			.ignoreComments()
			.withComparisonController(ComparisonControllers.Default)
			.build();

	assertTrue(d.toString(), !d.hasDifferences());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:13,代码来源:XmlParserDstu2_1Test.java


示例9: testPerformExport

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public final void testPerformExport() throws Exception {
    String xmlFileName = filename.replace(".bib", ".xml");
    String tempFilename = tempFile.getCanonicalPath();
    List<BibEntry> entries = bibtexImporter.importDatabase(importFile, charset).getDatabase().getEntries();
    Path xmlFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI());

    modsExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);

    Builder control = Input.from(Files.newInputStream(xmlFile));
    Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));

    Assert.assertThat(test, CompareMatcher.isSimilarTo(control)
            .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:16,代码来源:ModsExportFormatTestFiles.java


示例10: testIsIdenticalTo_withAssertionErrorForElementOrder_throwsReadableMessage

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public void testIsIdenticalTo_withAssertionErrorForElementOrder_throwsReadableMessage() {
    // Expected Exception
    expect(AssertionError.class);
    expectMessage("Expected child nodelist sequence '0' but was '1'");
    expectMessage("comparing <b...> at /a[1]/b[1] to <b...> at /a[1]/b[1]");

    // run test:
    assertThat("<a><c/><b/></a>", isIdenticalTo("<a><b/><c/></a>")
        .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)));
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:12,代码来源:CompareMatcherTest.java


示例11: tryToSelectMatchingChildNodesUsingXPath

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public void tryToSelectMatchingChildNodesUsingXPath() throws Exception {
    ElementSelector childSelector = selectorForElementNamed("child", byXPath("./*[1]", byName));
    assertThat(fromString(test1),
               isSimilarTo(fromString(test2))
               .withNodeMatcher(new DefaultNodeMatcher(childSelector, byName)));
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:8,代码来源:SelectElementsByNameOfChildTest.java


示例12: tryToSelectMatchingChildNodesUsingXPathAlpha02

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
@Ignore("doesn't work with XMLUnit > 2.0.0-alpha-02")
public void tryToSelectMatchingChildNodesUsingXPathAlpha02() throws Exception {
    ElementSelector childSelector = selectorForElementNamed("child", byXPath("./child/*[1]", byName));
    assertThat(fromString(test1),
               isSimilarTo(fromString(test2))
               .withNodeMatcher(new DefaultNodeMatcher(childSelector, byName)));
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:9,代码来源:SelectElementsByNameOfChildTest.java


示例13: tryToSelectMatchingChildNodesUsingCustomElementSelector

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public void tryToSelectMatchingChildNodesUsingCustomElementSelector() throws Exception {
    ElementSelector childSelector = selectorForElementNamed("child", new FirstChildElementNameSelector());
    assertThat(fromString(test1),
               isSimilarTo(fromString(test2))
               .withNodeMatcher(new DefaultNodeMatcher(childSelector, byName)));
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:8,代码来源:SelectElementsByNameOfChildTest.java


示例14: testIsSimilarTo_withAssertionErrorForElementOrder_throwsReadableMessage

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public void testIsSimilarTo_withAssertionErrorForElementOrder_throwsReadableMessage() {
    // run test:
    assertThat("<a><c/><b/></a>", isSimilarTo("<a><b/><c/></a>")
        .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)));
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:7,代码来源:CompareMatcherTest.java


示例15: canBeCombinedWithPassingMatcher

import org.xmlunit.diff.DefaultNodeMatcher; //导入依赖的package包/类
@Test
public void canBeCombinedWithPassingMatcher() {
    assertThat("<a><c/><b/></a>", both(not(isEmptyString()))
               .and(isSimilarTo("<a><b/><c/></a>")
                    .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))));
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:7,代码来源:CompareMatcherTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Toolable类代码示例发布时间:2022-05-23
下一篇:
Java Test类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap