当前位置: 首页>>代码示例>>Java>>正文


Java DetailedDiff.similar方法代码示例

本文整理汇总了Java中org.custommonkey.xmlunit.DetailedDiff.similar方法的典型用法代码示例。如果您正苦于以下问题:Java DetailedDiff.similar方法的具体用法?Java DetailedDiff.similar怎么用?Java DetailedDiff.similar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.custommonkey.xmlunit.DetailedDiff的用法示例。


在下文中一共展示了DetailedDiff.similar方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertMetadataEquals

import org.custommonkey.xmlunit.DetailedDiff; //导入方法依赖的package包/类
private void assertMetadataEquals( String expectedMetadataXml, File actualFile )
    throws Exception
{
    assertNotNull( "Actual File should not be null.", actualFile );

    assertTrue( "Actual file exists.", actualFile.exists() );

    StringWriter actualContents = new StringWriter();
    ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( actualFile );
    RepositoryMetadataWriter.write( metadata, actualContents );

    DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadataXml, actualContents.toString() ) );
    if ( !detailedDiff.similar() )
    {
        assertEquals( expectedMetadataXml, actualContents );
    }

    // assertEquals( "Check file contents.", expectedMetadataXml, actualContents );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:20,代码来源:MetadataTransferTest.java

示例2: assertMetadataEquals

import org.custommonkey.xmlunit.DetailedDiff; //导入方法依赖的package包/类
private void assertMetadataEquals( String expectedMetadataXml, Path actualFile )
    throws Exception
{
    assertNotNull( "Actual File should not be null.", actualFile );

    assertTrue( "Actual file exists.", Files.exists(actualFile) );

    StringWriter actualContents = new StringWriter();
    ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( actualFile );
    RepositoryMetadataWriter.write( metadata, actualContents );

    DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadataXml, actualContents.toString() ) );
    if ( !detailedDiff.similar() )
    {
        assertEquals( expectedMetadataXml, actualContents );
    }

    // assertEquals( "Check file contents.", expectedMetadataXml, actualContents );
}
 
开发者ID:apache,项目名称:archiva,代码行数:20,代码来源:MetadataTransferTest.java

示例3: validate

import org.custommonkey.xmlunit.DetailedDiff; //导入方法依赖的package包/类
public boolean validate(Document value) {
    if (value == null) return false;
    try {
        Document expectedValue = getValue();

        logger.debug("Expected XML Value: {},\nActual XML Value: {}", xmlUtilities.getDocumentAsString(expectedValue).trim()
                , xmlUtilities.getDocumentAsString(value).trim());

        DetailedDiff difference = new DetailedDiff(new Diff(expectedValue, value));
        if (!difference.similar())
            logger.warn("Differences exist between two documents: {}", difference.getAllDifferences());
        else
            logger.debug("No differences exist for input");
        return difference.similar();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:uoa-group-applications,项目名称:morc,代码行数:19,代码来源:XmlTestResource.java

示例4: assertExpectedMetadata

import org.custommonkey.xmlunit.DetailedDiff; //导入方法依赖的package包/类
protected void assertExpectedMetadata( String expectedMetadata, String actualMetadata )
    throws Exception
{
    DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
    if ( !detailedDiff.similar() )
    {
        // If it isn't similar, dump the difference.
        assertEquals( expectedMetadata, actualMetadata );
    }
    // XMLAssert.assertXMLEqual( "Expected Metadata:", expectedMetadata, actualMetadata );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:12,代码来源:AbstractRepositoryServletProxiedMetadataTestCase.java

示例5: assertMetadata

import org.custommonkey.xmlunit.DetailedDiff; //导入方法依赖的package包/类
private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
                             ProjectReference reference )
    throws LayoutException, IOException, SAXException, ParserConfigurationException
{
    File metadataFile = new File( repository.getRepoRoot(), tools.toPath( reference ) );
    String actualMetadata = FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );

    DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
    if ( !detailedDiff.similar() )
    {
        // If it isn't similar, dump the difference.
        assertEquals( expectedMetadata, actualMetadata );
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:15,代码来源:MetadataToolsTest.java

示例6: assertMetadata

import org.custommonkey.xmlunit.DetailedDiff; //导入方法依赖的package包/类
private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
                             ProjectReference reference )
    throws LayoutException, IOException, SAXException, ParserConfigurationException
{
    Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
    String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );

    DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
    if ( !detailedDiff.similar() )
    {
        // If it isn't similar, dump the difference.
        assertEquals( expectedMetadata, actualMetadata );
    }
}
 
开发者ID:apache,项目名称:archiva,代码行数:15,代码来源:MetadataToolsTest.java

示例7: assertSimilar

import org.custommonkey.xmlunit.DetailedDiff; //导入方法依赖的package包/类
/**
 * Check if the HTML is similar to the expected. The HTML strings are parsed
 * into {@link Document}s. Two documents are considered to be "similar" if
 * they contain the same elements and attributes regardless of order.
 * <p>
 * For each difference, the difference will be logged with error level. It
 * will generate a {@link ComparisonFailure} with the expected string and
 * actual string in order to be able to visualize the differences on sources
 * directly in the IDE.
 * </p>
 * 
 * @param expected
 *            the expected HTML
 * @param actual
 *            the HTML content to check
 */
public static void assertSimilar(String expected, String actual) {
	try {
		HTMLDocumentBuilder builder = new HTMLDocumentBuilder(new TolerantSaxDocumentBuilder(XMLUnit.newTestParser()));
		Document expectedDoc = builder.parse(expected);
		Document actualDoc = builder.parse(actual);
		DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedDoc, actualDoc));
		if (!diff.similar()) {
			logUnrecoverableDifferences(diff);
			throw new ComparisonFailure("HTML element different to expected one. See logs for details about found differences.\n", expected, actual);
		}
	} catch (SAXException | IOException | ConfigurationException | ParserConfigurationException e) {
		throw new ComparisonException("Failed to compare HTML", e);
	}
}
 
开发者ID:groupe-sii,项目名称:ogham,代码行数:31,代码来源:AssertHtml.java


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