use of org.apache.cxf.helpers.XPathUtils in project cxf by apache.
the class JavaToWSTest method testXmlJavaTypeAdapter.
@Test
public void testXmlJavaTypeAdapter() throws Exception {
String[] args = new String[] { "-o", output.getPath() + "/xmladapter.wsdl", "-verbose", "-wsdl", "org.apache.xmladapter.GreeterImpl" };
CommandInterfaceUtils.commandCommonMain();
JavaToWS j2w = new JavaToWS(args);
j2w.run();
File file = new File(output.getPath() + "/xmladapter.wsdl");
Document doc = StaxUtils.read(file);
Map<String, String> map = new HashMap<>();
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 node = (Element) util.getValueNode("//xsd:element[@name='arg0']", doc);
assertNotNull(node);
assertEquals("0", node.getAttribute("minOccurs"));
assertTrue(node.getAttribute("type").contains("string"));
}
use of org.apache.cxf.helpers.XPathUtils in project cxf by apache.
the class JavaToProcessorTest method testPropOrderInException2.
@Test
public void testPropOrderInException2() throws Exception {
env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/exception_prop_order2.wsdl");
// env.put(ToolConstants.CFG_OUTPUTFILE, "/x1/tmp/exception_prop_order.wsdl");
env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.exception.Echo5Impl");
env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
processor.setEnvironment(env);
processor.process();
File wsdlFile = new File(output, "exception_prop_order2.wsdl");
assertTrue(wsdlFile.exists());
Document doc = StaxUtils.read(wsdlFile);
Map<String, String> map = new HashMap<>();
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();
while (nd != null) {
if (nd == from) {
from = null;
} else if (nd == id) {
if (from != null) {
fail("id before from");
}
id = null;
}
nd = nd.getNextSibling();
}
assertNull(id);
assertNull(from);
}
use of org.apache.cxf.helpers.XPathUtils in project cxf by apache.
the class JavaToProcessorTest method testException.
@Test
public void testException() throws Exception {
env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/exception.wsdl");
env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.simple.Caculator");
env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
processor.setEnvironment(env);
processor.process();
File wsdlFile = new File(output, "exception.wsdl");
assertTrue(wsdlFile.exists());
// schema element
Document doc = StaxUtils.read(wsdlFile);
Map<String, String> map = new HashMap<>();
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"));
}
use of org.apache.cxf.helpers.XPathUtils in project cxf by apache.
the class ClientServerRPCLitTest method testNoElementParts.
@Test
public void testNoElementParts() throws Exception {
HttpURLConnection httpConnection = getHttpConnection("http://localhost:" + PORT + "/TestRPCWsdl?wsdl");
httpConnection.connect();
assertEquals(200, httpConnection.getResponseCode());
assertEquals("OK", httpConnection.getResponseMessage());
InputStream in = httpConnection.getInputStream();
assertNotNull(in);
Document doc = StaxUtils.read(in);
assertNotNull(doc);
Map<String, String> ns = new HashMap<>();
ns.put("soap", Soap11.SOAP_NAMESPACE);
ns.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
ns.put("xs", "http://www.w3.org/2001/XMLSchema");
XPathUtils xu = new XPathUtils(ns);
// make sure the wrapper types are anonymous types
NodeList ct = (NodeList) xu.getValue("//wsdl:definitions/wsdl:message/wsdl:part[@element != '']", doc, XPathConstants.NODESET);
assertNotNull(ct);
assertEquals(0, ct.getLength());
ct = (NodeList) xu.getValue("//wsdl:definitions/wsdl:message/wsdl:part[@type != '']", doc, XPathConstants.NODESET);
assertEquals(4, ct.getLength());
}
use of org.apache.cxf.helpers.XPathUtils in project cxf by apache.
the class ClientServerGreeterNoWsdlTest method testWSDLImports.
@Test
public void testWSDLImports() throws Exception {
URL url = new URL("http://localhost:" + PORT + "/SoapContext/GreeterPort?wsdl");
Document doc = StaxUtils.read(url.openStream());
Map<String, String> ns = new HashMap<>();
ns.put("xsd", "http://www.w3.org/2001/XMLSchema");
Node nd = new XPathUtils(ns).getValueNode("//xsd:import[@namespace='http://cxf.apache.org/greeter_control/types']", doc.getDocumentElement());
assertNotNull(nd);
}
Aggregations