Package org.apache.cxf.helpers

Examples of org.apache.cxf.helpers.XPathUtils


        File wsdlFile = new File(output, "exception-type-adapter.wsdl");
        assertTrue(wsdlFile.exists());
        Document doc = StaxUtils.read(wsdlFile);
        Map<String, String> map = new HashMap<String, String>();
        map.put("xsd", "http://www.w3.org/2001/XMLSchema");
        XPathUtils util = new XPathUtils(map);
        Node nd = util.getValueNode("//xsd:complexType[@name='myClass2']", doc);
        assertNotNull(nd);
       
        nd = util.getValueNode("//xsd:element[@name='adapted']", doc);
        assertNotNull(nd);
       
        String at = ((Element)nd).getAttribute("type");
        assertTrue(at.contains("myClass2"));
        assertEquals("0", ((Element)nd).getAttribute("minOccurs"));
View Full Code Here


        WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
        reader.setFeature("javax.wsdl.verbose", false);
        Definition def = reader.readWSDL(wsdlFile.toURI().toURL().toString());
        Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
        assertValid("//xsd:element[@type='ns0:Something']", wsdl);
        XPathUtils xpu = new XPathUtils(getNSMap());
       
        String s = (String)xpu.getValue("//xsd:complexType[@name='takeSomething']/"
                                + "xsd:sequence/xsd:element[@name='arg0']/@minOccurs",
                                wsdl, XPathConstants.STRING);
        assertEquals("50", s);
        assertFalse(xpu.isExist("//xsd:complexType[@name='Something']/xsd:sequence/"
                                + "xsd:element[@name='singular']/@minOccurs",
                         wsdl, XPathConstants.NODE));
    }
View Full Code Here

        namespaces.put("ns0", "http://aegis2ws.fortest.tools.cxf.apache.org/");
        return namespaces;
    }
   
    private void assertValid(String xpathExpression, Document doc) throws XMLStreamException {
        XPathUtils xpu = new XPathUtils(getNSMap());
        if (!xpu.isExist(xpathExpression, doc, XPathConstants.NODE)) {
            throw new AssertionFailedError("Failed to select any nodes for expression:\n" + xpathExpression
                                           + " from document:\n" + StaxUtils.toString(doc));
        }
    }   
View Full Code Here

        Document doc = StaxUtils.read(wsdlFile);
        Map<String, String> map = new HashMap<String, String>();
        map.put("xsd", "http://www.w3.org/2001/XMLSchema");
        map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
        map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
        XPathUtils util = new XPathUtils(map);
       
        assertNotNull(util.getValueNode("//xsd:complexType[@name='Exception']", doc));

        Element nd = (Element)util.getValueNode("//xsd:element[@name='Exception']", doc);
        assertNotNull(nd);
        assertTrue(nd.getAttribute("type").contains("Exception"));
       
        nd = (Element)util.getValueNode("//xsd:element[@name='message']", doc);
        assertNotNull(nd);
        assertTrue(nd.getAttribute("type").contains("string"));
        assertTrue(nd.getAttribute("minOccurs").contains("0"));
       
        nd = (Element)util.getValueNode("//wsdl:part[@name='Exception']", doc);
        assertNotNull(nd);
        assertTrue(nd.getAttribute("element").contains(":Exception"));

        nd = (Element)util.getValueNode("//wsdl:fault[@name='Exception']", doc);
        assertNotNull(nd);
        assertTrue(nd.getAttribute("message").contains(":Exception"));

        nd = (Element)util.getValueNode("//soap:fault[@name='Exception']", doc);
        assertNotNull(nd);
        assertTrue(nd.getAttribute("use").contains("literal"));
    }
View Full Code Here

        Document doc = StaxUtils.read(wsdlFile);
        Map<String, String> map = new HashMap<String, String>();
        map.put("xsd", "http://www.w3.org/2001/XMLSchema");
        map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
        map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
        XPathUtils util = new XPathUtils(map);

        Element summary = (Element)util.getValueNode("//xsd:element[@name='summary']", doc);
        Element from = (Element)util.getValueNode("//xsd:element[@name='from']", doc);
        Element id = (Element)util.getValueNode("//xsd:element[@name='id']", doc);
        assertNotNull(summary);
        assertNotNull(from);
        assertNotNull(id);
       
        Node nd = summary.getNextSibling();
View Full Code Here

        Document doc = StaxUtils.read(wsdlFile);
        Map<String, String> map = new HashMap<String, String>();
        map.put("xsd", "http://www.w3.org/2001/XMLSchema");
        map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
        map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
        XPathUtils util = new XPathUtils(map);

        Element summary = (Element)util.getValueNode("//xsd:element[@name='summary']", doc);
        Element from = (Element)util.getValueNode("//xsd:element[@name='from']", doc);
        Element id = (Element)util.getValueNode("//xsd:element[@name='id']", doc);
        assertNotNull(summary);
        assertNotNull(from);
        assertNotNull(id);
       
        Node nd = from.getNextSibling();
View Full Code Here

        Document doc = StaxUtils.read(wsdlFile);
        Map<String, String> map = new HashMap<String, String>();
        map.put("xsd", "http://www.w3.org/2001/XMLSchema");
        map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
        map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
        XPathUtils util = new XPathUtils(map);

        Element nd = (Element)util.getValueNode("//xsd:element[@name='names']", doc);
        assertNotNull(nd);
        assertEquals("0", nd.getAttribute("minOccurs"));
        assertEquals("unbounded", nd.getAttribute("maxOccurs"));
        assertTrue(nd.getAttribute("type").endsWith(":myData"));
       
       
        nd = (Element)util.getValueNode("//xsd:complexType[@name='ListException2']"
                                        + "/xsd:sequence/xsd:element[@name='address']", doc);
        assertNotNull(nd);
        assertEquals("0", nd.getAttribute("minOccurs"));
        assertEquals("unbounded", nd.getAttribute("maxOccurs"));
        assertTrue(nd.getAttribute("type").endsWith(":myData"));
View Full Code Here

        if (nd instanceof Document) {
            nd = ((Document)nd).getDocumentElement();
        }
        Map<String, String> ns = new HashMap<String, String>();
        ns.put("ns2", "http://cxf.apache.org/policytest/DoubleIt");
        XPathUtils xp = new XPathUtils(ns);
        Object o = xp.getValue("//ns2:DoubleItResponse/doubledNumber", nd, XPathConstants.STRING);
        assertEquals(XMLUtils.toString(nd), "50", o);
    }
View Full Code Here

    private static String parseResponse(DOMSource domResponse) {
        Element el = ((Document)domResponse.getNode()).getDocumentElement();
        Map<String, String> ns = new HashMap<String, String>();
        ns.put("soap", "http://schemas.xmlsoap.org/soap/envelope/");
        ns.put("ns", "http://cxf.apache.org/greeter_control/types");
        XPathUtils xp = new XPathUtils(ns);
        return (String)xp.getValue("/soap:Envelope/soap:Body"
                                   + "/ns:greetMeResponse/ns:responseType",
                                   el,
                                   XPathConstants.STRING);
    }
View Full Code Here

            if (el instanceof Document) {
                el = ((Document)el).getDocumentElement();
            }
            Map<String, String> ns = new HashMap<String, String>();
            ns.put("ns2", "http://cxf.apache.org/policytest/DoubleIt");
            XPathUtils xp = new XPathUtils(ns);
            String o = (String)xp.getValue("//ns2:DoubleIt/numberToDouble", el, XPathConstants.STRING);
            int i = Integer.parseInt(o);
           
            String req = "<ns2:DoubleItResponse xmlns:ns2=\"http://cxf.apache.org/policytest/DoubleIt\">"
                + "<doubledNumber>" + Integer.toString(i * 2) + "</doubledNumber></ns2:DoubleItResponse>";
            return new StreamSource(new StringReader(req));
View Full Code Here

TOP

Related Classes of org.apache.cxf.helpers.XPathUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.