本文整理匯總了Java中org.custommonkey.xmlunit.XMLAssert.assertXpathsEqual方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLAssert.assertXpathsEqual方法的具體用法?Java XMLAssert.assertXpathsEqual怎麽用?Java XMLAssert.assertXpathsEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.custommonkey.xmlunit.XMLAssert
的用法示例。
在下文中一共展示了XMLAssert.assertXpathsEqual方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: compareWSDL
import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
/**
* Due to the different behavior on Element ordering between JDK8 and older,
* assertXMLEqual() doesn't work OOTB. Instead just verify some parts of WSDL using XPath.
*/
private void compareWSDL(Reader expected, Reader actual) throws Exception {
Schema wsdlSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
.newSchema(new URL("http://schemas.xmlsoap.org/wsdl/"));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setSchema(wsdlSchema);
factory.setIgnoringComments(true);
factory.setIgnoringElementContentWhitespace(true);
factory.setNamespaceAware(true);
factory.setValidating(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document expectedDoc = builder.parse(new InputSource(expected));
Document actualDoc = builder.parse(new InputSource(actual));
XMLAssert.assertXpathsEqual(
"//definitions/types", expectedDoc,
"//definitions/types", actualDoc);
XMLAssert.assertXpathsEqual(
"//definitions/message[@name=submitOrder]", expectedDoc,
"//definitions/message[@name=submitOrder]", actualDoc);
XMLAssert.assertXpathsEqual(
"//definitions/message[@name=submitOrderResponse]", expectedDoc,
"//definitions/message[@name=submitOrderResponse]", actualDoc);
XMLAssert.assertXpathsEqual(
"//definitions/portType", expectedDoc,
"//definitions/portType", actualDoc);
XMLAssert.assertXpathsEqual(
"//definitions/binding", expectedDoc,
"//definitions/binding", actualDoc);
XMLAssert.assertXpathsEqual(
"//definitions/service", expectedDoc,
"//definitions/service", actualDoc);
}
示例2: testReleasedSnapshotsExistsInSameRepo
import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
public void testReleasedSnapshotsExistsInSameRepo()
throws Exception
{
applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, true );
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
// test listeners for the correct artifacts
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins",
"maven-plugin-plugin", "2.3-SNAPSHOT", "maven-plugin-plugin-2.3-SNAPSHOT.jar" );
listenerControl.replay();
repoPurge.process( PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
listenerControl.verify();
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
// check if the snapshot was removed
assertDeleted( projectRoot + "/2.3-SNAPSHOT" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );
// check if the released version was not removed
assertExists( projectRoot + "/2.3" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3-sources.jar" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3-sources.jar.md5" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3-sources.jar.sha1" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.jar" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.jar.md5" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.jar.sha1" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.pom" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.pom.md5" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.pom.sha1" );
// check if metadata file was updated
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
String expectedVersions =
"<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/release", metadataXml );
XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
}
示例3: testHigherSnapshotExistsInSameRepo
import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
@Test
public void testHigherSnapshotExistsInSameRepo()
throws Exception
{
applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
// test listeners for the correct artifacts - no deletions
listenerControl.replay();
repoPurge.process( CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_HIGHER_SNAPSHOT_EXISTS_IN_SAME_REPO );
listenerControl.verify();
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-source-plugin";
// check if the snapshot was not removed
assertExists( projectRoot + "/2.0.3-SNAPSHOT" );
assertExists( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar" );
assertExists( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar.md5" );
assertExists( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar.sha1" );
assertExists( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom" );
assertExists( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom.md5" );
assertExists( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom.sha1" );
// check if the released version was not removed
assertExists( projectRoot + "/2.0.4-SNAPSHOT" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar.md5" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar.sha1" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom.md5" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom.sha1" );
// check if metadata file was not updated (because nothing was removed)
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
String expectedVersions = "<expected><versions><version>2.0.3-SNAPSHOT</version>"
+ "<version>2.0.4-SNAPSHOT</version></versions></expected>";
XMLAssert.assertXpathEvaluatesTo( "2.0.4-SNAPSHOT", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
XMLAssert.assertXpathEvaluatesTo( "20070427033345", "//metadata/versioning/lastUpdated", metadataXml );
}
示例4: testReleasedSnapshotsWereNotCleaned
import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
/**
* Test the snapshot clean consumer on a repository set to NOT clean/delete snapshots based on released versions.
*
* @throws Exception
*/
@Test
public void testReleasedSnapshotsWereNotCleaned()
throws Exception
{
KnownRepositoryContentConsumer repoPurgeConsumer =
applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-retention-count",
KnownRepositoryContentConsumer.class );
ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
repoConfiguration.setDeleteReleasedSnapshots( false ); // Set to NOT delete released snapshots.
addRepoToConfiguration( "retention-count", repoConfiguration );
repoPurgeConsumer.beginScan( repoConfiguration, null );
String repoRoot = prepareTestRepos();
repoPurgeConsumer.processFile(
CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
// check if the snapshot wasn't removed
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
assertExists( projectRoot + "/2.3-SNAPSHOT" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );
// check if metadata file wasn't updated
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
String expectedVersions = "<expected><versions><version>2.3-SNAPSHOT</version></versions></expected>";
XMLAssert.assertXpathEvaluatesTo( "2.3-SNAPSHOT", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
removeRepoFromConfiguration( "retention-count", repoConfiguration );
}
示例5: testReleasedSnapshotsWereCleaned
import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
@Test
public void testReleasedSnapshotsWereCleaned()
throws Exception
{
KnownRepositoryContentConsumer repoPurgeConsumer =
applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-days-old",
KnownRepositoryContentConsumer.class );
ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
repoConfiguration.setDeleteReleasedSnapshots( true );
addRepoToConfiguration( "days-old", repoConfiguration );
repoPurgeConsumer.beginScan( repoConfiguration, null );
String repoRoot = prepareTestRepos();
repoPurgeConsumer.processFile(
CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
// check if the snapshot was removed
assertDeleted( projectRoot + "/2.3-SNAPSHOT" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );
// check if metadata file was updated
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
String expectedVersions =
"<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
removeRepoFromConfiguration( "days-old", repoConfiguration );
}