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


Java SimpleNamespaceContext类代码示例

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


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

示例1: setUp

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    postUrl = HTTP_BASE_URL + TEST_BASE_PATH + "/" + System.currentTimeMillis();


    Map<String,String> m = new HashMap<String,String>();
    m.put("sv", "http://www.jcp.org/jcr/sv/1.0");

    NamespaceContext ctx = new SimpleNamespaceContext(m);
    XMLUnit.setXpathNamespaceContext(ctx);


    final NameValuePairList props = new NameValuePairList();
    props.add("a", "");
    props.add("jcr:mixinTypes", "mix:referenceable");

    firstCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
    firstUuid = getProperty(firstCreatedNodeUrl, "jcr:uuid");
    firstPath = getPath(firstCreatedNodeUrl);

    secondCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
    secondUuid = getProperty(secondCreatedNodeUrl, "jcr:uuid");
    secondPath = getPath(secondCreatedNodeUrl);
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:26,代码来源:ReferenceTypeHintTest.java

示例2: before

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Before
  public void before() {
    HashMap<String, String> m = new HashMap<String, String>();
    m.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
    m.put("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
    m.put("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
    m.put("edm", "http://schemas.microsoft.com/ado/2009/11/edm");
//    m.put("edm", "http://schemas.microsoft.com/ado/2008/09/edm");
    m.put("annotation", "http://schemas.microsoft.com/ado/2009/02/edm/annotation");
    m.put("myns", "bla");
    m.put("myns2", "blabla");
    m.put("mynamespace", "http://tempuri.org/hello");
    SimpleNamespaceContext ctx = new SimpleNamespaceContext(m);
    XMLUnit.setXpathNamespaceContext(ctx);
    schema = EdmSchema.newBuilder().setNamespace(NAMESPACE);
    productSet = EdmEntitySet.newBuilder().setName("Products");
    categorySet = EdmEntitySet.newBuilder().setName("Categories");
    container = EdmEntityContainer.newBuilder().setName("Container");
  }
 
开发者ID:teiid,项目名称:oreva,代码行数:20,代码来源:EdmxFormatWriterTest.java

示例3: testWriteMods

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Test
public void testWriteMods() throws Exception {
    LocalStorage storage = new LocalStorage();
    LocalStorage.LocalObject local = storage.create();
    ModsStreamEditor modsEditor = new ModsStreamEditor(local);
    ModsDefinition mods = modsEditor.createPage(local.getPid(), "1", "[1]", "pageType");
    String model = "model:page";
    long timestamp = 0L;
    DcStreamEditor instance = new DcStreamEditor(local);
    instance.write(mods, model, timestamp, null);
    local.flush();

    DublinCoreRecord result = instance.read();
    assertNotNull(result);
    assertNotNull(result.getDc());
    assertEquals(local.getPid(), result.getPid());

    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));
    String toXml = DcUtils.toXml(result.getDc(), true);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:title[text()='[1]']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='" + local.getPid() +"']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:type[text()='" + model +"']", toXml);
}
 
开发者ID:proarc,项目名称:proarc,代码行数:27,代码来源:DcStreamEditorTest.java

示例4: testTransformation

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的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

示例5: testMarcAsMods_FrequencyAuthority_Issue181

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的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

示例6: testMarcAsMods_SubjectTopic_Issue185_Issue433

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的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

示例7: testMarcAsMods_Conspectus_Issue303

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的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

示例8: testMarcAsMods_AbstractLang_Issue434

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
/**
     * Tests mapping of field 520 and subfield $9 to {@code [email protected]}.
     * See issue 434.
     */
    @Test
    public void testMarcAsMods_AbstractLang_Issue434() 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);
            }}));
            XMLAssert.assertXpathExists("/m:mods/m:abstract[@lang='cze' and @type='Abstract' and text()='Text cze']", xmlResult);
            XMLAssert.assertXpathExists("/m:mods/m:abstract[@lang='eng' and @type='Abstract' and text()='Text eng']", xmlResult);
            XMLAssert.assertXpathExists("/m:mods/m:abstract[not(@lang) and @type='Abstract' and text()='Text no lang']", xmlResult);
            validateMods(new StreamSource(new ByteArrayInputStream(contents)));
        } finally {
            close(xmlIS);
        }
    }
 
开发者ID:proarc,项目名称:proarc,代码行数:28,代码来源:TransformersTest.java

示例9: testDeployment

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的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

示例10: testLoanRequestAccepted

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Test
public void testLoanRequestAccepted() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String port = System.getProperty("org.switchyard.component.soap.standalone.port", "8181/cxf");
        String response = httpMixIn.postString("http://localhost:" + port + "/loanService/loanService", SOAP_REQUEST_1);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        m.put("tns", "http://example.com/loan-approval/loanService/");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//tns:accept", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().equals("yes")) {
            fail("Expecting 'yes'");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:27,代码来源:BpelServiceLoanApprovalQuickstartTest.java

示例11: testLoanRequestUnableToHandle

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Test
public void testLoanRequestUnableToHandle() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String response = httpMixIn.postString("http://localhost:" + getSoapClientPort() + "/loanService/loanService", SOAP_REQUEST_2);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        //m.put("tns", "http://example.com/loan-approval/loanService/");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//faultcode", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().endsWith(":unableToHandleRequest")) {
            fail("Expecting 'unableToHandleRequest' fault code");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:26,代码来源:BpelServiceLoanApprovalQuickstartTest.java

示例12: testOrders

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Test
public void testOrders() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();

    httpMixIn.initialize();
    try {
        XMLUnit.setIgnoreWhitespace(true);
        String response = httpMixIn.postString("http://localhost:" + getSoapClientPort() + "/quickstart-cdi-bus/OrderService", SOAP_REQUEST);

        Map<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("ns", "urn:switchyard-quickstart:cdi-bus:1.0");
        XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));

        XMLAssert.assertXpathEvaluatesTo("PO-19838-XYZ", "//ns:orderAck/orderId", response);
        XMLAssert.assertXpathEvaluatesTo("true", "//ns:orderAck/accepted", response);
        XMLAssert.assertXpathEvaluatesTo("Order Accepted", "//ns:orderAck/status", response);
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:21,代码来源:CamelCDIBusQuickstartTest.java

示例13: testDeployment

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Override
@Test
public void testDeployment() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String response = httpMixIn.postString("http://localhost:" + getSoapClientPort() + "/SayHelloService/SayHelloService", SOAP_REQUEST);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        m.put("tns", "http://www.jboss.org/bpel/examples");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//tns:result", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().equals("Hello Fred")) {
            fail("Expecting 'Hello Fred'");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:27,代码来源:BpelServiceSayHelloQuickstartTest.java

示例14: testLoanRequestAccepted

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Test
public void testLoanRequestAccepted() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String response = httpMixIn.postString("http://localhost:8080/loanService/loanService", SOAP_REQUEST_1);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        m.put("tns", "http://example.com/loan-approval/loanService/");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//tns:accept", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().equals("yes")) {
            fail("Expecting 'yes'");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:26,代码来源:BpelServiceLoanApprovalQuickstartTest.java

示例15: testLoanRequestUnableToHandle

import org.custommonkey.xmlunit.SimpleNamespaceContext; //导入依赖的package包/类
@Test
public void testLoanRequestUnableToHandle() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String response = httpMixIn.postString("http://localhost:8080/loanService/loanService", SOAP_REQUEST_2);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        //m.put("tns", "http://example.com/loan-approval/loanService/");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//faultcode", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().endsWith(":unableToHandleRequest")) {
            fail("Expecting 'unableToHandleRequest' fault code");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:26,代码来源:BpelServiceLoanApprovalQuickstartTest.java


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