Search in sources :

Example 1 with JAXWSDefinitionBuilder

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder in project cxf by apache.

the class JAXWSDefinitionBuilderTest method testBuildDefinitionWithXMLBinding.

@Test
public void testBuildDefinitionWithXMLBinding() {
    String qname = "http://apache.org/hello_world_xml_http/bare";
    String wsdlUrl = getClass().getResource("resources/hello_world_xml_bare.wsdl").toString();
    JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
    builder.setBus(BusFactory.getDefaultBus());
    builder.setContext(env);
    Definition def = builder.build(wsdlUrl);
    assertNotNull(def);
    Map<?, ?> services = def.getServices();
    assertNotNull(services);
    assertEquals(1, services.size());
    Service service = (Service) services.get(new QName(qname, "XMLService"));
    assertNotNull(service);
    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("XMLPort");
    assertNotNull(port);
    assertEquals(1, port.getExtensibilityElements().size());
    Object obj = port.getExtensibilityElements().get(0);
    if (obj instanceof JAXBExtensibilityElement) {
        obj = ((JAXBExtensibilityElement) obj).getValue();
    }
    assertTrue(obj.getClass().getName() + " is not an AddressType", obj instanceof AddressType);
    Binding binding = port.getBinding();
    assertNotNull(binding);
    assertEquals(new QName(qname, "Greeter_XMLBinding"), binding.getQName());
    BindingOperation operation = binding.getBindingOperation("sayHi", null, null);
    assertNotNull(operation);
    BindingInput input = operation.getBindingInput();
    assertNotNull(input);
    assertEquals(1, input.getExtensibilityElements().size());
    obj = input.getExtensibilityElements().get(0);
    if (obj instanceof JAXBExtensibilityElement) {
        obj = ((JAXBExtensibilityElement) obj).getValue();
    }
    assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat", obj instanceof XMLBindingMessageFormat);
}
Also used : Binding(javax.wsdl.Binding) JAXBExtensibilityElement(org.apache.cxf.wsdl.JAXBExtensibilityElement) QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) BindingInput(javax.wsdl.BindingInput) BindingOperation(javax.wsdl.BindingOperation) XMLBindingMessageFormat(org.apache.cxf.bindings.xformat.XMLBindingMessageFormat) AddressType(org.apache.cxf.wsdl.http.AddressType) JAXWSDefinitionBuilder(org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder) Test(org.junit.Test)

Example 2 with JAXWSDefinitionBuilder

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder in project cxf by apache.

the class JAXWSProfileTest method testLoadPlugins.

@Test
public void testLoadPlugins() {
    PluginLoader loader = PluginLoader.getInstance();
    assertNotNull(loader);
    loader.loadPlugin("/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-plugin.xml");
    assertEquals(3, loader.getPlugins().size());
    Plugin plugin = null;
    for (Plugin p : loader.getPlugins().values()) {
        if (p.getName().contains("jaxws")) {
            plugin = p;
        }
    }
    assertNotNull(plugin);
    assertEquals("tools-jaxws-frontend", plugin.getName());
    assertEquals("2.0", plugin.getVersion());
    assertEquals("apache cxf", plugin.getProvider());
    Map<String, FrontEnd> frontends = loader.getFrontEnds();
    assertNotNull(frontends);
    assertEquals(3, frontends.size());
    FrontEnd frontend = getFrontEnd(frontends, 0);
    assertEquals("jaxws", frontend.getName());
    assertEquals("org.apache.cxf.tools.wsdlto.frontend.jaxws", frontend.getPackage());
    assertEquals("JAXWSProfile", frontend.getProfile());
    assertNotNull(frontend.getGenerators());
    assertNotNull(frontend.getGenerators().getGenerator());
    assertEquals(2, frontend.getGenerators().getGenerator().size());
    assertEquals("AntGenerator", getGenerator(frontend, 0).getName());
    assertEquals("ImplGenerator", getGenerator(frontend, 1).getName());
    FrontEndProfile profile = loader.getFrontEndProfile("jaxws");
    assertNotNull(profile);
    List<FrontEndGenerator> generators = profile.getGenerators();
    assertNotNull(generators);
    assertEquals(2, generators.size());
    assertTrue(generators.get(0) instanceof AntGenerator);
    assertTrue(generators.get(1) instanceof ImplGenerator);
    Processor processor = profile.getProcessor();
    assertNotNull(processor);
    assertTrue(processor instanceof WSDLToJavaProcessor);
    AbstractWSDLBuilder builder = profile.getWSDLBuilder();
    assertNotNull(builder);
    assertTrue(builder instanceof JAXWSDefinitionBuilder);
    Class<?> container = profile.getContainerClass();
    assertEquals(container, JAXWSContainer.class);
    assertEquals("/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml", profile.getToolspec());
}
Also used : AbstractWSDLBuilder(org.apache.cxf.tools.wsdlto.core.AbstractWSDLBuilder) Processor(org.apache.cxf.tools.common.Processor) WSDLToJavaProcessor(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor) ImplGenerator(org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.ImplGenerator) FrontEndProfile(org.apache.cxf.tools.wsdlto.core.FrontEndProfile) FrontEnd(org.apache.cxf.tools.plugin.FrontEnd) FrontEndGenerator(org.apache.cxf.tools.common.FrontEndGenerator) WSDLToJavaProcessor(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor) PluginLoader(org.apache.cxf.tools.wsdlto.core.PluginLoader) JAXWSDefinitionBuilder(org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder) Plugin(org.apache.cxf.tools.plugin.Plugin) AntGenerator(org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.AntGenerator) Test(org.junit.Test)

Aggregations

JAXWSDefinitionBuilder (org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder)2 Test (org.junit.Test)2 Binding (javax.wsdl.Binding)1 BindingInput (javax.wsdl.BindingInput)1 BindingOperation (javax.wsdl.BindingOperation)1 Definition (javax.wsdl.Definition)1 Port (javax.wsdl.Port)1 Service (javax.wsdl.Service)1 QName (javax.xml.namespace.QName)1 XMLBindingMessageFormat (org.apache.cxf.bindings.xformat.XMLBindingMessageFormat)1 FrontEndGenerator (org.apache.cxf.tools.common.FrontEndGenerator)1 Processor (org.apache.cxf.tools.common.Processor)1 FrontEnd (org.apache.cxf.tools.plugin.FrontEnd)1 Plugin (org.apache.cxf.tools.plugin.Plugin)1 AbstractWSDLBuilder (org.apache.cxf.tools.wsdlto.core.AbstractWSDLBuilder)1 FrontEndProfile (org.apache.cxf.tools.wsdlto.core.FrontEndProfile)1 PluginLoader (org.apache.cxf.tools.wsdlto.core.PluginLoader)1 AntGenerator (org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.AntGenerator)1 ImplGenerator (org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.ImplGenerator)1 WSDLToJavaProcessor (org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor)1