本文整理汇总了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 );
}
示例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 );
}
示例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);
}
}
示例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 );
}
示例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 );
}
}
示例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 );
}
}
示例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);
}
}