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


Java XMLAssert.assertXpathEvaluatesTo方法代码示例

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


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

示例1: verifyReferences

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
private void verifyReferences(final String referencingNodeUrl) throws Exception {
    final String refCreatedValue = getProperty(referencingNodeUrl, "r");
    final String weakrefCreatedValue = getProperty(referencingNodeUrl, "w");

    final String[] refCreatedValues = getPropertyArray(referencingNodeUrl, "rs");
    final String[] weakrefCreatedValues = getPropertyArray(referencingNodeUrl, "ws");

    assertEquals(firstUuid, refCreatedValue);
    assertEquals(firstUuid, weakrefCreatedValue);
    assertEquals(firstUuid, refCreatedValues[0]);
    assertEquals(firstUuid, weakrefCreatedValues[0]);
    assertEquals(secondUuid, refCreatedValues[1]);
    assertEquals(secondUuid, weakrefCreatedValues[1]);

    final String sysView = getSystemView(referencingNodeUrl);

    XMLAssert.assertXpathEvaluatesTo("Reference", "//sv:property[@sv:name='r']/@sv:type", sysView);
    XMLAssert.assertXpathEvaluatesTo("WeakReference", "//sv:property[@sv:name='w']/@sv:type", sysView);
    XMLAssert.assertXpathEvaluatesTo("Reference", "//sv:property[@sv:name='rs']/@sv:type", sysView);
    XMLAssert.assertXpathEvaluatesTo("WeakReference", "//sv:property[@sv:name='ws']/@sv:type", sysView);
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:22,代码来源:ReferenceTypeHintTest.java

示例2: testTransformation

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testTransformation() throws Exception {
    ModsDefinition mods = ModsUtils.unmarshalModsType(new StreamSource(DcStreamEditorTest.class.getResource("periodical.xml").toExternalForm()));
    Transformer t = DcUtils.modsTransformer("model:periodical");
    JAXBSource jaxbSource = new JAXBSource(ModsUtils.defaultMarshaller(false),
            new ObjectFactory().createMods(mods));
    StringWriter dump = new StringWriter();
    t.transform(jaxbSource, new StreamResult(dump));
    String toXml = dump.toString();
    System.out.println(toXml);

    HashMap<String, String> namespaces = new HashMap<String, String>();
    namespaces.put("oai_dc", DcStreamEditor.DATASTREAM_FORMAT_URI);
    namespaces.put("dc", "http://purl.org/dc/elements/1.1/");
    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:title[text()='main']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:title[text()='key']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:title[text()='alternative']", toXml);
    XMLAssert.assertXpathEvaluatesTo("3", "count(/oai_dc:dc/dc:title)", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:creator[text()='Boleslav']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:description[text()='poznámka']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='uuid:40d13cb2-811f-468c-a6d3-1ad6b01f06f7']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='isbn:0eaa6730']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='issn-l:idIssn-l']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='idWitEmptyType']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='idWithoutType']", toXml);
    // XXX needs more test
}
 
开发者ID:proarc,项目名称:proarc,代码行数:29,代码来源:DcStreamEditorTest.java

示例3: 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

示例4: testMarcAsMods_Conspectus_Issue303

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
/**
     * Test mapping of 072#7 $x to {@code subject/topic} and $a/$9 to {@code classification}.
     * See issue 303.
     */
    @Test
    public void testMarcAsMods_Conspectus_Issue303() throws Exception {
        InputStream xmlIS = TransformersTest.class.getResourceAsStream("marc.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.assertXpathEvaluatesTo("Umění", "/m:mods/m:subject[@authority='Konspekt']/m:topic", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("7.01/.09", "/m:mods/m:classification[@authority='udc' and @edition='Konspekt']", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("21", "/m:mods/m:classification[@authority='Konspekt']", xmlResult);
            validateMods(new StreamSource(new ByteArrayInputStream(contents)));
        } finally {
            close(xmlIS);
        }
    }
 
开发者ID:proarc,项目名称:proarc,代码行数:28,代码来源:TransformersTest.java

示例5: testDeployment

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Override
@Test
public void testDeployment() throws Exception {
    HTTPMixIn soapMixIn = new HTTPMixIn();
    soapMixIn.initialize();

    try {
        String url = "http://localhost:" + getSoapClientPort() + "/HelloGoodbyeService/HelloGoodbyeService";
        String response = soapMixIn.postString(url, HELLO_REQUEST);
        XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(Collections.singletonMap("ns", "http://www.jboss.org/bpel/examples/simple_correlation/")));
        XMLAssert.assertXpathEvaluatesTo("1", "//ns:sessionId/ns:id", response);
        XMLAssert.assertXpathEvaluatesTo("BPEL, Hello World!", "//ns:parameter", response);

        response = soapMixIn.postString(url, GOODBYE_REQUEST);
        XMLAssert.assertXpathEvaluatesTo("1", "//ns:sessionId/ns:id", response);
        XMLAssert.assertXpathEvaluatesTo("BPEL, Goodbye World!", "//ns:parameter", response);
    } finally {
        soapMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:21,代码来源:BpelSimpleCorrelationQuickstartTest.java

示例6: testDeployment

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testDeployment() throws Exception {
    HTTPMixIn soapMixIn = new HTTPMixIn();
    soapMixIn.initialize();

    try {
        String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
        // For karaf, the directory will generally be cxf/proxy/ReverseService
        String dir = System.getProperty("org.switchyard.component.soap.client.dir", "proxy/ReverseService");
        String url = "http://localhost:" + port + "/" + dir;
        String response = soapMixIn.postString(url, XML);
        XMLAssert.assertXpathEvaluatesTo("raboof", "//text", response);
    } finally {
        soapMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:17,代码来源:CamelSOAPProxyQuickstartTest.java

示例7: testDeployment

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testDeployment() throws Exception {
    HTTPMixIn soapMixIn = new HTTPMixIn();
    soapMixIn.initialize();

    try {
        String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
        String url = "http://localhost:" + port + "/quickstart-transform-smooks/OrderService";
        String response = soapMixIn.postString(url, XML);
        XMLAssert.assertXpathEvaluatesTo("PO-19838-XYZ", "//orderId", response);
        XMLAssert.assertXpathEvaluatesTo("true", "//accepted", response);
        XMLAssert.assertXpathEvaluatesTo("Order Accepted", "//status", response);
    } finally {
        soapMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:17,代码来源:TransformSmooksQuickstartTest.java

示例8: testConfidentialSecure

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testConfidentialSecure() throws Exception {
    KeyStore keystore = KeyStore.getInstance("JKS");
    keystore.load(new FileInputStream(new File(SRC_DIR, "connector.jks")), "changeit".toCharArray());

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
    tmf.init(keystore);

    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    keyManagerFactory.init(keystore, "changeit".toCharArray());

    SSLContext sslcontext = SSLContext.getInstance("TLS");
    sslcontext.init(keyManagerFactory.getKeyManagers(), tmf.getTrustManagers(), null);

    String response = invokeWorkService("https", 8443, "policy-security-saml", getAssertion(), sslcontext);
    XMLAssert.assertXpathEvaluatesTo("true", "//received", response);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:18,代码来源:PolicySecuritySamlDemoQuickstartTest.java

示例9: testConfidentialSecure

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testConfidentialSecure() throws Exception {
    KeyStore keystore = KeyStore.getInstance("JKS");
    keystore.load(new FileInputStream(new File(SRC_DIR, "connector.jks")), "changeit".toCharArray());

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
    tmf.init(keystore);

    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    keyManagerFactory.init(keystore, "changeit".toCharArray());

    SSLContext sslcontext = SSLContext.getInstance("TLS");
    sslcontext.init(keyManagerFactory.getKeyManagers(), tmf.getTrustManagers(), null);

    String response = invokeWorkService("https", 8443, "security-propagation-jms", new String[] {"kermit",
            "the-frog-1" }, sslcontext);
    XMLAssert.assertXpathEvaluatesTo("true", "//received", response);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:19,代码来源:SecurityPropagationJMSDemoQuickstartTest.java

示例10: testConfidentialSecure

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testConfidentialSecure() throws Exception {
    KeyStore keystore = KeyStore.getInstance("JKS");
    keystore.load(new FileInputStream(new File(SRC_DIR, "connector.jks")), "changeit".toCharArray());

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
    tmf.init(keystore);

    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    keyManagerFactory.init(keystore, "changeit".toCharArray());

    SSLContext sslcontext = SSLContext.getInstance("TLS");
    sslcontext.init(keyManagerFactory.getKeyManagers(), tmf.getTrustManagers(), null);

    String response = invokeWorkService("https", 8443, "policy-security-cert",
            new StringPuller().pull(new File(SRC_DIR, "src/test/resources/xml/BinarySecurityToken.xml")), sslcontext);
    XMLAssert.assertXpathEvaluatesTo("true", "//received", response);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:19,代码来源:PolicySecurityCertDemoQuickstartTest.java

示例11: testMarcAsMods_Issue32

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
/**
     * Tests mapping of 910a(sigla) as {@code <physicalLocation>} and 910b(signatura) as {@code <shelfLocator>}.
     */
    @Test
    public void testMarcAsMods_Issue32() throws Exception {
        InputStream xmlIS = TransformersTest.class.getResourceAsStream("marc.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.assertXpathEvaluatesTo("HKA001", "/m:mods/m:location/m:physicalLocation[1]", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("test sigla", "/m:mods/m:location/m:physicalLocation[2]", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("2", "count(/m:mods/m:location/m:physicalLocation)", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("54 487", "/m:mods/m:location/m:shelfLocator[1]", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("test signatura", "/m:mods/m:location/m:shelfLocator[2]", xmlResult);
            XMLAssert.assertXpathEvaluatesTo("2", "count(/m:mods/m:location/m:shelfLocator)", xmlResult);
            validateMods(new StreamSource(new ByteArrayInputStream(contents)));
        } finally {
            close(xmlIS);
        }
    }
 
开发者ID:proarc,项目名称:proarc,代码行数:30,代码来源:TransformersTest.java

示例12: 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

示例13: testMarcAsMods_RelatedItem_Issue313

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
/**
     * Tests mapping of field 787 to {@code relatedItem}.
     * See issue 313.
     */
    @Test
    public void testMarcAsMods_RelatedItem_Issue313() throws Exception {
        InputStream xmlIS = TransformersTest.class.getResourceAsStream("marc_relatedItem_787.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 78708 |i Recenze na: |a Čeřovský, Jan |t Jak jsme zachraňovali svět aneb Půl století ve službách ochrany přírody |d Praha : Nakladatelství Academia, 2014 |4 kniha
            XMLAssert.assertXpathEvaluatesTo(
                    "Jak jsme zachraňovali svět aneb Půl století ve službách ochrany přírody",
                    "/m:mods/m:relatedItem[not(@type) and @displayLabel='Recenze na:']"
                    + "/m:titleInfo/m:title/text()", xmlResult);
            XMLAssert.assertXpathEvaluatesTo(
                    "Čeřovský, Jan",
                    "/m:mods/m:relatedItem[not(@type) and @displayLabel='Recenze na:']"
                    + "/m:name/m:namePart/text()", xmlResult);
            XMLAssert.assertXpathEvaluatesTo(
                    "Praha : Nakladatelství Academia, 2014",
                    "/m:mods/m:relatedItem[not(@type) and @displayLabel='Recenze na:']"
                    + "/m:originInfo/m:publisher/text()", xmlResult);
            validateMods(new StreamSource(new ByteArrayInputStream(contents)));
        } finally {
            close(xmlIS);
        }
    }
 
开发者ID:proarc,项目名称:proarc,代码行数:38,代码来源:TransformersTest.java

示例14: testDeployment

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Override
public void testDeployment() throws Exception {
    final String ticketId = "TCKT-" + System.currentTimeMillis();
    final String soapRequest = REQUEST.replaceAll("TICKET_ID", ticketId);
    final HTTPMixIn http = new HTTPMixIn();
    http.initialize();
    try {
        String port = getSoapClientPort();
        String response = http.postString("http://localhost:" + port + "/HelpDeskService/HelpDeskService", soapRequest);
        XMLAssert.assertXpathEvaluatesTo(ticketId, "//ticketAck/id", response);
    } finally {
        http.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:15,代码来源:HelpdeskDemoQuickstartTest.java

示例15: doTestVerify

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
static final void doTestVerify(String context, String port, boolean pass) throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String request = getSoapRequest(context, pass);
        String response = httpMixIn.postString("http://localhost:" + port + "/" + context + "/Interview", request);
        XMLAssert.assertXpathEvaluatesTo(String.valueOf(pass), "//return", response);
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:12,代码来源:RulesInterviewQuickstartTest.java


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