當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLAssert.assertXpathNotExists方法代碼示例

本文整理匯總了Java中org.custommonkey.xmlunit.XMLAssert.assertXpathNotExists方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLAssert.assertXpathNotExists方法的具體用法?Java XMLAssert.assertXpathNotExists怎麽用?Java XMLAssert.assertXpathNotExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.custommonkey.xmlunit.XMLAssert的用法示例。


在下文中一共展示了XMLAssert.assertXpathNotExists方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMarcAsMods_FrequencyAuthority_Issue181

import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
/**
     * Tests mapping of fields 310a and 008/18 to {@code [email protected]}.
     * See issue 118 and 181.
     */
    @Test
    public void testMarcAsMods_FrequencyAuthority_Issue181() throws Exception {
        InputStream xmlIS = TransformersTest.class.getResourceAsStream("frequencyAuthority.xml");
        assertNotNull(xmlIS);
        StreamSource streamSource = new StreamSource(xmlIS);
        Transformers mt = new Transformers();

        try {
            byte[] contents = mt.transformAsBytes(streamSource, Transformers.Format.MarcxmlAsMods3);
            assertNotNull(contents);
            String xmlResult = new String(contents, "UTF-8");
//            System.out.println(xmlResult);
            XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(new HashMap() {{
                put("m", ModsConstants.NS);
            }}));
            XMLAssert.assertXpathNotExists("/m:mods/m:originInfo/m:frequency[1]/@authority", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("2x ročně", "/m:mods/m:originInfo/m:frequency[1]", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("marcfrequency", "/m:mods/m:originInfo/m:frequency[2]/@authority", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("Semiannual", "/m:mods/m:originInfo/m:frequency[2]", xmlResult);
            validateMods(new StreamSource(new ByteArrayInputStream(contents)));
        } finally {
            close(xmlIS);
        }
    }
 
開發者ID:proarc,項目名稱:proarc,代碼行數:29,代碼來源:TransformersTest.java

示例2: testMarcAsMods_SubjectTopic_Issue185_Issue433

import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
/**
     * Tests mapping of field 653 indicator_9 $a to {@code subject/[email protected]}.
     * See issue 185.
     * See issue 433.
     */
    @Test
    public void testMarcAsMods_SubjectTopic_Issue185_Issue433() throws Exception {
        InputStream xmlIS = TransformersTest.class.getResourceAsStream("marc_subject_65X_X9.xml");
        assertNotNull(xmlIS);
        StreamSource streamSource = new StreamSource(xmlIS);
        Transformers mt = new Transformers();

        try {
            byte[] contents = mt.transformAsBytes(streamSource, Transformers.Format.MarcxmlAsMods3);
            assertNotNull(contents);
            String xmlResult = new String(contents, "UTF-8");
//            System.out.println(xmlResult);
            XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(new HashMap() {{
                put("m", ModsConstants.NS);
            }}));
            // 653
            XMLAssert.assertXpathExists("/m:mods/m:subject[not(@authority)]/m:topic[text()='kočky' and @lang='cze']", xmlResult);
            XMLAssert.assertXpathExists("/m:mods/m:subject[not(@authority)]/m:topic[text()='cats' and @lang='eng']", xmlResult);
            XMLAssert.assertXpathNotExists("/m:mods/m:subject/m:name/m:namePart[text()='kočky']", xmlResult);
            XMLAssert.assertXpathNotExists("/m:mods/m:subject/m:name/m:namePart[text()='cats']", xmlResult);
            validateMods(new StreamSource(new ByteArrayInputStream(contents)));
        } finally {
            close(xmlIS);
        }
    }
 
開發者ID:proarc,項目名稱:proarc,代碼行數:31,代碼來源:TransformersTest.java

示例3: testMarcAsMods_RelatedItemPartDetailNumber_Issue306

import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
/**
     * Tests mapping of field 510 $c to {@code part/detail/number}.
     * See issue 306.
     */
    @Test
    public void testMarcAsMods_RelatedItemPartDetailNumber_Issue306() throws Exception {
        InputStream xmlIS = TransformersTest.class.getResourceAsStream("marc_subject_65X_X9.xml");
        assertNotNull(xmlIS);
        StreamSource streamSource = new StreamSource(xmlIS);
        Transformers mt = new Transformers();

        try {
            byte[] contents = mt.transformAsBytes(streamSource, Transformers.Format.MarcxmlAsMods3);
            assertNotNull(contents);
            String xmlResult = new String(contents, "UTF-8");
//            System.out.println(xmlResult);
            XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(new HashMap() {{
                put("m", ModsConstants.NS);
            }}));
            // test 510 4# $a Knihopis 1 $c K01416
            XMLAssert.assertXpathExists("/m:mods/m:relatedItem[@type='isReferencedBy']"
                    + "/m:titleInfo/m:title[text()='Knihopis 1']", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("K01416", "/m:mods/m:relatedItem[@type='isReferencedBy']"
                    + "/m:titleInfo/m:title[text()='Knihopis 1']/../../m:part/m:detail[@type='part']/m:number", xmlResult);

            // test 510 0# $a Knihopis 2
            XMLAssert.assertXpathExists("/m:mods/m:relatedItem[@type='isReferencedBy']"
                    + "/m:titleInfo/m:title[text()='Knihopis 2']", xmlResult);
            XMLAssert.assertXpathNotExists("/m:mods/m:relatedItem[@type='isReferencedBy']"
                    + "/m:titleInfo/m:title[text()='Knihopis 2']/../../m:part", xmlResult);
            validateMods(new StreamSource(new ByteArrayInputStream(contents)));
        } finally {
            close(xmlIS);
        }
    }
 
開發者ID:proarc,項目名稱:proarc,代碼行數:36,代碼來源:TransformersTest.java

示例4: testAutoDetectV1

import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
@Test
public void testAutoDetectV1()
    throws Exception
{
    // Setup the autodetect-v1.xml file in the target directory (so we can save/load it)
    File userFile = getTestFile( "target/test-autodetect-v1/archiva-user.xml" );
    userFile.delete();
    assertFalse( userFile.exists() );

    userFile.getParentFile().mkdirs();
    FileUtils.copyFile( getTestFile( "src/test/conf/autodetect-v1.xml" ), userFile );

    // Load the original (unconverted) archiva.xml
    ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" );

    archivaConfiguration.reload();

    Configuration configuration = archivaConfiguration.getConfiguration();
    assertConfiguration( configuration, 2, 2, 2 );
    assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );

    ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 );

    assertEquals( "check managed repositories", "${appserver.base}/repositories/internal",
                  repository.getLocation() );
    assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() );
    assertEquals( "check managed repositories", "internal", repository.getId() );
    assertEquals( "check managed repositories", "default", repository.getLayout() );
    assertTrue( "check managed repositories", repository.isScanned() );

    // Test that only 1 set of repositories exist.
    assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() );
    assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() );
    assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );

    // Save the file.
    archivaConfiguration.save( configuration );

    // Reload.
    archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" );
    configuration = archivaConfiguration.getConfiguration();

    // Test that only 1 set of repositories exist.
    assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() );
    assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositoriesAsMap().size() );
    assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() );
    assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() );
    assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );

    String actualXML = FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) );
    XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML );
    XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML );
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:54,代碼來源:ArchivaConfigurationTest.java

示例5: testExport

import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
/**
 * integration test
 */
@Test
public void testExport() throws Exception {
    FedoraTestSupport fedora = new FedoraTestSupport();
    fedora.cleanUp();
    fedora.ingest(Kramerius4ExportTest.class.getResource("Kramerius4ExportTestPage.xml"));

    MetaModelRepository.setInstance(config.getPlugins());
    DigitalObjectManager.setDefault(new DigitalObjectManager(
            config,
            EasyMock.createNiceMock(ImportBatchManager.class),
            fedora.getRemoteStorage(),
            MetaModelRepository.getInstance(),
            EasyMock.createNiceMock(UserManager.class)));

    File output = temp.getRoot();
    boolean hierarchy = true;
    String[] pids = {"uuid:f74f3cf3-f3be-4cac-95da-8e50331414a2"};
    RemoteStorage storage = fedora.getRemoteStorage();
    Kramerius4Export instance = new Kramerius4Export(storage, config.getKramerius4Export());
    File target = instance.export(output, hierarchy, "export status", pids);
    assertNotNull(target);

    // check datastreams with xpath
    HashMap<String, String> namespaces = new HashMap<String, String>();
    namespaces.put("dc", DcConstants.NS_PURL);
    namespaces.put("f", "info:fedora/fedora-system:def/foxml#");
    namespaces.put("kramerius", Kramerius4Export.KRAMERIUS_RELATION_NS);
    namespaces.put("mods", ModsStreamEditor.DATASTREAM_FORMAT_URI);
    namespaces.put("oai", Kramerius4Export.OAI_NS);
    namespaces.put("proarc-rels", Relations.PROARC_RELS_NS);
    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));
    File foxml = ExportUtils.pidAsXmlFile(target, pids[0]);
    String foxmlSystemId = foxml.toURI().toASCIIString();
    XMLAssert.assertXpathExists(streamXPath(ModsStreamEditor.DATASTREAM_ID), new InputSource(foxmlSystemId));
    XMLAssert.assertXpathExists(streamXPath(DcStreamEditor.DATASTREAM_ID), new InputSource(foxmlSystemId));
    XMLAssert.assertXpathExists(streamXPath(StringEditor.OCR_ID), new InputSource(foxmlSystemId));
    XMLAssert.assertXpathExists(streamXPath(RelationEditor.DATASTREAM_ID), new InputSource(foxmlSystemId));
    XMLAssert.assertXpathExists(streamXPath("IMG_FULL"), new InputSource(foxmlSystemId));
    XMLAssert.assertXpathExists(streamXPath("IMG_PREVIEW"), new InputSource(foxmlSystemId));
    XMLAssert.assertXpathExists(streamXPath("IMG_THUMB"), new InputSource(foxmlSystemId));
    XMLAssert.assertXpathNotExists(streamXPath(BinaryEditor.RAW_ID), new InputSource(foxmlSystemId));

    // check OAI ID
    XMLAssert.assertXpathExists("//oai:itemID", new InputSource(foxmlSystemId));
    // check kramerius:file
    XMLAssert.assertXpathExists("//kramerius:file", new InputSource(foxmlSystemId));
    // check exclusion of proarc-rels:hasDevice
    XMLAssert.assertXpathNotExists("//proarc-rels:hasDevice", new InputSource(foxmlSystemId));
    // check MODS starts with modsCollection
    XMLAssert.assertXpathExists(streamXPath(ModsStreamEditor.DATASTREAM_ID) + "//f:xmlContent/mods:modsCollection/mods:mods", new InputSource(foxmlSystemId));
    // check policy
    XMLAssert.assertXpathEvaluatesTo("policy:private", streamXPath(DcStreamEditor.DATASTREAM_ID) + "//dc:rights", new InputSource(foxmlSystemId));
    XMLAssert.assertXpathEvaluatesTo("policy:private", streamXPath(RelationEditor.DATASTREAM_ID) + "//kramerius:policy", new InputSource(foxmlSystemId));

    // test export status
    RelationEditor relationEditor = new RelationEditor(storage.find(pids[0]));
    assertNotNull(relationEditor.getExportResult());

    // test ingest of exported object
    fedora.cleanUp();
    fedora.ingest(foxml.toURI().toURL());
}
 
開發者ID:proarc,項目名稱:proarc,代碼行數:66,代碼來源:Kramerius4ExportTest.java

示例6: testConfidential

import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
@Test
public void testConfidential() throws Exception {
    String response = invokeWorkService("http", 8080, "policy-security-wss-signencrypt", true, null);
    XMLAssert.assertXpathNotExists("//faultcode", response);
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:6,代碼來源:PolicySecurityWssSignencryptDemoQuickstartTest.java

示例7: testConfidentialSecure

import org.custommonkey.xmlunit.XMLAssert; //導入方法依賴的package包/類
@Test
public void testConfidentialSecure() throws Exception {
    String response = invokeWorkService("https", 8443, "policy-security-wss-signencrypt", true, setupSSLContext());
    XMLAssert.assertXpathNotExists("//faultcode", response);
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:6,代碼來源:PolicySecurityWssSignencryptDemoQuickstartTest.java


注:本文中的org.custommonkey.xmlunit.XMLAssert.assertXpathNotExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。