use of org.apache.cxf.bindings.xformat.XMLFormatBinding in project cxf by apache.
the class WSDLToXMLProcessorTest method testAllDefault.
@Test
public void testAllDefault() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world.wsdl") };
WSDLToXML.main(args);
File outputFile = new File(output, "hello_world-xmlbinding.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
WSDLToXMLProcessor processor = new WSDLToXMLProcessor();
processor.setEnvironment(env);
processor.parseWSDL(outputFile.getAbsolutePath());
Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_XMLBinding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_XMLBinding Missed!");
}
boolean found = false;
for (Object obj : binding.getExtensibilityElements()) {
if (obj instanceof XMLFormatBinding) {
found = true;
break;
}
}
if (!found) {
fail("Element <xformat:binding/> Missed!");
}
BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
}
found = false;
for (Object obj : bo.getBindingInput().getExtensibilityElements()) {
if (obj instanceof XMLBindingMessageFormat && ((XMLBindingMessageFormat) obj).getRootNode().getLocalPart().equals("sayHi")) {
found = true;
break;
}
}
if (!found) {
fail("Element <xformat:body rootNode=\"tns:sayHi\" /> Missed!");
}
Service service = processor.getWSDLDefinition().getService(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_XMLService"));
if (service == null) {
fail("Element wsdl:service Greeter_XMLService Missed!");
}
found = false;
for (Object obj : service.getPort("Greeter_XMLPort").getExtensibilityElements()) {
if (obj instanceof HTTPAddress) {
HTTPAddress xmlHttpAddress = (HTTPAddress) obj;
if (xmlHttpAddress.getLocationURI() != null) {
found = true;
break;
}
}
}
if (!found) {
fail("Element http:address of service port Missed!");
}
}
Aggregations