javax.wsdl.extensions.UnknownExtensibilityElement Java Examples

The following examples show how to use javax.wsdl.extensions.UnknownExtensibilityElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XTeeSoapProvider.java    From j-road with Apache License 2.0 6 votes vote down vote up
@Override
protected void populatePort(Definition definition, Port port) throws WSDLException {
  super.populatePort(definition, port);
  ExtensionRegistry extensionRegistry = definition.getExtensionRegistry();
  extensionRegistry.mapExtensionTypes(Port.class,
                                      new QName(XTeeWsdlDefinition.XROAD_NAMESPACE,
                                                "address",
                                                XTeeWsdlDefinition.XROAD_PREFIX),
                                      UnknownExtensibilityElement.class);
  UnknownExtensibilityElement element =
      (UnknownExtensibilityElement) extensionRegistry.createExtension(Port.class,
                                                                      new QName(XTeeWsdlDefinition.XROAD_NAMESPACE,
                                                                                "address",
                                                                                XTeeWsdlDefinition.XROAD_NAMESPACE));
  Document doc;
  try {
    doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  } catch (ParserConfigurationException e) {
    throw new RuntimeException(e);
  }
  Element xRoadAddr = doc.createElementNS(XTeeWsdlDefinition.XROAD_NAMESPACE, "address");
  xRoadAddr.setPrefix(XTeeWsdlDefinition.XROAD_PREFIX);
  xRoadAddr.setAttribute("producer", xRoadDatabase);
  element.setElement(xRoadAddr);
  port.addExtensibilityElement(element);
}
 
Example #2
Source File: JAXBExtensionHelperTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void checkTestExt() throws Exception {
    Service s = wsdlDefinition.getService(new QName("http://cxf.apache.org/test/hello_world",
        "HelloWorldService"));
    Port p = s.getPort("HelloWorldPort");
    List<?> extPortList = p.getExtensibilityElements();

    TestPolicyType tp = null;
    AnotherPolicyType ap = null;
    for (Object ext : extPortList) {
        if (ext instanceof TestPolicyType) {
            tp = (TestPolicyType) ext;
        } else if (ext instanceof AnotherPolicyType) {
            ap = (AnotherPolicyType) ext;
        } else if (ext instanceof UnknownExtensibilityElement) {
            UnknownExtensibilityElement e = (UnknownExtensibilityElement)ext;
            System.out.println(e.getElementType());
        }
    }
    assertNotNull("Could not find extension element TestPolicyType", tp);
    assertNotNull("Could not find extension element AnotherPolicyType", ap);

    assertEquals("Unexpected value for TestPolicyType intAttr", 30, tp.getIntAttr());
    assertEquals("Unexpected value for TestPolicyType stringAttr", "hello", tp.getStringAttr());
    assertTrue("Unexpected value for AnotherPolicyType floatAttr",
               Math.abs(0.1F - ap.getFloatAttr()) < 0.5E-5);
}
 
Example #3
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void addExtensibilityElements(Definition def,
                                        ElementExtensible elementExtensible,
                                        List<ExtensibilityElement> extensibilityElements) {
    if (extensibilityElements != null) {
        for (ExtensibilityElement element : extensibilityElements) {
            if (element instanceof UnknownExtensibilityElement) {
                UnknownExtensibilityElement uee = (UnknownExtensibilityElement)element;
                String pfx = uee.getElement().getPrefix();
                addNamespace(pfx, element.getElementType().getNamespaceURI(), def);
            } else {
                QName qn = element.getElementType();
                addNamespace(qn.getNamespaceURI(), def);
            }
            elementExtensible.addExtensibilityElement(element);
        }
    }
}
 
Example #4
Source File: ServiceModelPolicyUpdater.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addPolicy(PolicyAttachment pa) {
    // TODO - do I need to defensively copy this?
    Element policyEl = pa.getElement();

    UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
    uee.setRequired(true);
    uee.setElementType(DOMUtils.getElementQName(policyEl));
    uee.setElement(policyEl);

    if (ei.getService().getDescription() == null) {
        DescriptionInfo description = new DescriptionInfo();
        description.setName(ei.getService().getName());
        if (!StringUtils.isEmpty(ei.getAddress())) {
            description.setBaseURI(ei.getAddress() + "?wsdl");
        }

        ei.getService().setDescription(description);
    }
    ei.getService().getDescription().addExtensor(uee);
}
 
Example #5
Source File: JaxWsEndpointImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void extractWsdlEprs(EndpointInfo endpoint) {
    //parse the EPR in wsdl
    List<ExtensibilityElement> portExtensors = endpoint.getExtensors(ExtensibilityElement.class);
    if (portExtensors != null) {
        Iterator<ExtensibilityElement> extensionElements = portExtensors.iterator();
        QName wsaEpr = new QName(Names.WSA_NAMESPACE_NAME, "EndpointReference");
        while (extensionElements.hasNext()) {
            ExtensibilityElement ext = extensionElements.next();
            if (ext instanceof UnknownExtensibilityElement && wsaEpr.equals(ext.getElementType())) {
                DOMSource domSource = new DOMSource(((UnknownExtensibilityElement)ext).getElement());
                W3CEndpointReference w3cEPR = new W3CEndpointReference(domSource);
                EndpointReferenceType ref = ProviderImpl.convertToInternal(w3cEPR);
                endpoint.getTarget().setMetadata(ref.getMetadata());
                endpoint.getTarget().setReferenceParameters(ref.getReferenceParameters());
                endpoint.getTarget().getOtherAttributes().putAll(ref.getOtherAttributes());
            }

        }
    }
}
 
Example #6
Source File: JaxWsEndpointImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void checkRespectBindingFeature(List<ExtensibilityElement> bindingExtensors) {
    if (bindingExtensors != null) {
        Iterator<ExtensibilityElement> extensionElements = bindingExtensors.iterator();
        while (extensionElements.hasNext()) {
            ExtensibilityElement ext = extensionElements.next();
            if (ext instanceof UnknownExtensibilityElement && Boolean.TRUE.equals(ext.getRequired())
                && this.wsFeatures != null) {
                for (WebServiceFeature feature : this.wsFeatures) {
                    if (feature instanceof RespectBindingFeature && feature.isEnabled()) {

                        org.apache.cxf.common.i18n.Message message =
                            new org.apache.cxf.common.i18n.Message("UNKONWN_REQUIRED_WSDL_BINDING", LOG);
                        LOG.severe(message.toString());
                        throw new WebServiceException(message.toString());
                    }
                }
            }
        }
    }

}
 
Example #7
Source File: APIMWSDLReader.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Get the addressURl from the Extensibility element
 * @param exElement - {@link ExtensibilityElement}
 * @throws APIManagementException
 */
private void setAddressUrl(ExtensibilityElement exElement, String transports, API api) throws APIManagementException {

       if (exElement instanceof SOAP12AddressImpl) {
           ((SOAP12AddressImpl) exElement).setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
       } else if (exElement instanceof SOAPAddressImpl) {
           ((SOAPAddressImpl) exElement).setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
       } else if (exElement instanceof HTTPAddressImpl) {
           ((HTTPAddressImpl) exElement).setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
       } else if (exElement instanceof UnknownExtensibilityElement) {
           Element unknownExtensibilityElement = ((UnknownExtensibilityElement) exElement).getElement();
           if (unknownExtensibilityElement != null) {
               NodeList nodeList = unknownExtensibilityElement.getElementsByTagNameNS(APIConstants.WSDL_NAMESPACE_URI,
                       APIConstants.WSDL_ELEMENT_LOCAL_NAME);
               if (nodeList != null && nodeList.getLength() > 0) {
                   nodeList.item(0).setTextContent(APIUtil.getGatewayendpoint(transports) + api.getContext());
               }
           }
       } else {
		String msg = "Unsupported WSDL errors!";
		log.error(msg);
		throw new APIManagementException(msg);
	}
}
 
Example #8
Source File: ServiceModelPolicyUpdater.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addPolicyRef(Extensible ext, Policy p) {
    Document doc = DOMUtils.getEmptyDocument();
    Element el = doc.createElementNS(p.getNamespace(), Constants.ELEM_POLICY_REF);
    el.setPrefix(Constants.ATTR_WSP);
    el.setAttribute(Constants.ATTR_URI, "#" + p.getId());

    UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
    uee.setElementType(new QName(p.getNamespace(), Constants.ELEM_POLICY_REF));
    uee.setElement(el);
    uee.setRequired(true);

    ext.addExtensor(uee);
}
 
Example #9
Source File: LocalServiceModelReferenceResolver.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Policy resolveReference(String uri) {
    List<UnknownExtensibilityElement> extensions =
        descriptionInfo.getExtensors(UnknownExtensibilityElement.class);
    if (extensions != null) {
        for (UnknownExtensibilityElement e : extensions) {
            if (Constants.isPolicyElement(e.getElementType())
                && uri.equals(e.getElement().getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
                                                            PolicyConstants.WSU_ID_ATTR_NAME))) {
                return builder.getPolicy(e.getElement());
            }
        }
    }
    return null;
}
 
Example #10
Source File: PolicyAnnotationListener.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addPolicy(AbstractPropertiesHolder place,
                       ServiceInfo service,
                       Policy p,
                       Class<?> cls,
                       String defName) {
    Element el = addPolicy(service, p, cls, defName);
    if (el != null && !isExistsPolicyReference(place.getExtensors().get(), getPolicyRefURI(el))) {
        UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
        uee.setElement(el);
        uee.setRequired(true);
        uee.setElementType(DOMUtils.getElementQName(el));
        place.addExtensor(uee);
    }
}
 
Example #11
Source File: PolicyAnnotationListener.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean isExistsPolicy(Object[] exts, String uri) {
    exts = exts == null ? new Object[0] : exts;
    for (Object o : exts) {
        if (o instanceof UnknownExtensibilityElement) {
            UnknownExtensibilityElement uee = (UnknownExtensibilityElement)o;
            String uri2 = getPolicyId(uee.getElement());
            if (uri.equals(uri2)) {
                return true;
            }
        }
    }
    return false;
}
 
Example #12
Source File: PolicyAnnotationListener.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean isExistsPolicyReference(Object[] exts, String uri) {
    exts = exts == null ? new Object[0] : exts;
    for (Object o : exts) {
        if (o instanceof UnknownExtensibilityElement) {
            UnknownExtensibilityElement uee = (UnknownExtensibilityElement)o;
            String uri2 = getPolicyRefURI(uee.getElement());
            if (uri.equals(uri2)) {
                return true;
            }
        }
    }
    return false;
}
 
Example #13
Source File: ReferenceResolverTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testLocalServiceModelReferenceResolver() {
    DescriptionInfo di = control.createMock(DescriptionInfo.class);
    PolicyBuilder builder = control.createMock(PolicyBuilder.class);
    LocalServiceModelReferenceResolver resolver =
        new LocalServiceModelReferenceResolver(di, builder);

    List<UnknownExtensibilityElement> extensions = new ArrayList<>();
    EasyMock.expect(di.getExtensors(UnknownExtensibilityElement.class)).andReturn(extensions);

    control.replay();
    assertNull(resolver.resolveReference("A"));
    control.verify();

    control.reset();
    UnknownExtensibilityElement extension = control.createMock(UnknownExtensibilityElement.class);
    extensions.add(extension);
    EasyMock.expect(di.getExtensors(UnknownExtensibilityElement.class)).andReturn(extensions);
    Element e = control.createMock(Element.class);
    EasyMock.expect(extension.getElement()).andReturn(e).times(2);
    QName qn = new QName(Constants.URI_POLICY_NS,
                         Constants.ELEM_POLICY);
    EasyMock.expect(extension.getElementType()).andReturn(qn).anyTimes();
    EasyMock.expect(e.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
                                     PolicyConstants.WSU_ID_ATTR_NAME))
                    .andReturn("A");
    Policy p = control.createMock(Policy.class);
    EasyMock.expect(builder.getPolicy(e)).andReturn(p);

    control.replay();
    assertSame(p, resolver.resolveReference("A"));
    control.verify();

}
 
Example #14
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void assertPortTypeOperationExtensions(OperationInfo oi, boolean expectExtensions) {
    if (expectExtensions) {
        assertEquals(1, oi.getExtensionAttributes().size());
        assertNotNull(oi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertEquals(1, oi.getExtensors(UnknownExtensibilityElement.class).size());
        assertEquals(EXTENSION_ELEM, oi.getExtensor(UnknownExtensibilityElement.class).getElementType());
    } else {
        assertNull(oi.getExtensionAttributes());
        assertNull(oi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertNull(oi.getExtensors(UnknownExtensibilityElement.class));
        assertNull(oi.getExtensor(UnknownExtensibilityElement.class));
    }
}
 
Example #15
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void assertBindingOperationExtensions(BindingOperationInfo boi, boolean expectExtensions) {
    if (expectExtensions) {
        assertEquals(1, boi.getExtensionAttributes().size());
        assertNotNull(boi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertEquals(1, boi.getExtensors(UnknownExtensibilityElement.class).size());
        assertEquals(EXTENSION_ELEM, boi.getExtensor(UnknownExtensibilityElement.class).getElementType());
    } else {
        assertNull(boi.getExtensionAttributes());
        assertNull(boi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertEquals(0, boi.getExtensors(UnknownExtensibilityElement.class).size());
        assertNull(boi.getExtensor(UnknownExtensibilityElement.class));
    }
}
 
Example #16
Source File: PolicyAnnotationListener.java    From cxf with Apache License 2.0 4 votes vote down vote up
private Element addPolicy(ServiceInfo service, Policy p, Class<?> cls, String defName) {
    String uri = p.uri();
    String ns = Constants.URI_POLICY_NS;

    if (p.includeInWSDL()) {
        Element element = loadPolicy(uri, defName);
        if (element == null) {
            return null;
        }

        // might have been updated on load policy
        uri = getPolicyId(element);
        ns = element.getNamespaceURI();

        if (service.getDescription() == null && cls != null) {
            service.setDescription(new DescriptionInfo());
            URL u = cls.getResource("/");
            if (u != null) {
                service.getDescription().setBaseURI(u.toString());
            }
        }

        // if not already added to service add it, otherwise ignore
        // and just create the policy reference.
        if (!isExistsPolicy(service.getDescription().getExtensors().get(), uri)) {
            UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
            uee.setElement(element);
            uee.setRequired(true);
            uee.setElementType(DOMUtils.getElementQName(element));
            service.getDescription().addExtensor(uee);
        }

        uri = "#" + uri;
    }

    Document doc = DOMUtils.getEmptyDocument();
    Element el = doc.createElementNS(ns, "wsp:" + Constants.ELEM_POLICY_REF);
    Attr att = doc.createAttributeNS(null, "URI");
    att.setValue(uri);
    el.setAttributeNodeNS(att);
    return el;
}
 
Example #17
Source File: EndpointReferenceBuilder.java    From cxf with Apache License 2.0 4 votes vote down vote up
public EndpointReference getEndpointReference() {

        //if there is epr in wsdl, direct return this EPR
        List<ExtensibilityElement> portExtensors = endpoint.getEndpointInfo()
            .getExtensors(ExtensibilityElement.class);
        if (portExtensors != null) {
            Iterator<ExtensibilityElement> extensionElements = portExtensors.iterator();
            QName wsaEpr = new QName(Names.WSA_NAMESPACE_NAME, "EndpointReference");
            while (extensionElements.hasNext()) {
                ExtensibilityElement ext = extensionElements.next();
                if (ext instanceof UnknownExtensibilityElement && wsaEpr.equals(ext.getElementType())) {
                    Element eprEle = ((UnknownExtensibilityElement)ext).getElement();
                    List<Element> addressElements = DOMUtils.getChildrenWithName(eprEle,
                                                                                 Names.WSA_NAMESPACE_NAME,
                                                                                 Names.WSA_ADDRESS_NAME);
                    if (!addressElements.isEmpty()) {
                        /*
                         * [WSA-WSDL Binding] : in a SOAP 1.1 port described using WSDL 1.1, the location
                         * attribute of a soap11:address element (if present) would have the same value as the
                         * wsa:Address child element of the wsa:EndpointReference element.
                         */
                        addressElements.get(0).setTextContent(this.endpoint.getEndpointInfo().getAddress());
                    }
                    return EndpointReference.readFrom(new DOMSource(eprEle));
                }

            }
        }


        String bindingId = endpoint.getJaxwsBinding().getBindingID();

        if (!SOAPBindingImpl.isSoapBinding(bindingId)) {
            throw new UnsupportedOperationException(new Message("GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING",
                                                                LOG, bindingId).toString());
        }

        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
        builder.address(this.endpoint.getEndpointInfo().getAddress());

        builder.serviceName(this.endpoint.getService().getName());
        builder.endpointName(this.endpoint.getEndpointInfo().getName());

        if (this.endpoint.getEndpointInfo().getService().getDescription() != null) {
            builder.wsdlDocumentLocation(this.endpoint.getEndpointInfo().getService().getDescription()
                .getBaseURI());
        }
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(EndpointReferenceBuilder.class.getClassLoader());

            return builder.build();
        } finally {
            Thread.currentThread().setContextClassLoader(cl);
        }
    }
 
Example #18
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testExtensions() throws Exception {
    setUpWSDL("hello_world_ext.wsdl", 0);

    String ns = "http://apache.org/hello_world_soap_http";
    QName pingMeOpName = new QName(ns, "pingMe");
    QName greetMeOpName = new QName(ns, "greetMe");
    QName faultName = new QName(ns, "pingMeFault");

    // portType extensions

    InterfaceInfo ii = serviceInfo.getInterface();
    assertEquals(2, ii.getExtensionAttributes().size());
    assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_BOOLEAN));
    assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, ii.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, ii.getExtensor(UnknownExtensibilityElement.class).getElementType());

    // portType/operation extensions

    OperationInfo oi = ii.getOperation(pingMeOpName);
    assertPortTypeOperationExtensions(oi, true);
    assertPortTypeOperationExtensions(ii.getOperation(greetMeOpName), false);

    // portType/operation/[input|output|fault] extensions

    assertPortTypeOperationMessageExtensions(oi, true, true, faultName);
    assertPortTypeOperationMessageExtensions(ii.getOperation(greetMeOpName), false, true, null);

    // service extensions

    assertEquals(1, serviceInfo.getExtensionAttributes().size());
    assertNotNull(serviceInfo.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, serviceInfo.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM,
        serviceInfo.getExtensor(UnknownExtensibilityElement.class).getElementType());

    // service/port extensions

    EndpointInfo ei = serviceInfo.getEndpoints().iterator().next();
    assertEquals(1, ei.getExtensionAttributes().size());
    assertNotNull(ei.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, ei.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, ei.getExtensor(UnknownExtensibilityElement.class).getElementType());

    // binding extensions

    BindingInfo bi = ei.getBinding();
    // REVISIT: bug in wsdl4j?
    // getExtensionAttributes on binding element returns an empty map
    // assertEquals(1, bi.getExtensionAttributes().size());
    // assertNotNull(bi.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, bi.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, bi.getExtensor(UnknownExtensibilityElement.class).getElementType());

    // binding/operation extensions

    BindingOperationInfo boi = bi.getOperation(pingMeOpName);
    assertBindingOperationExtensions(boi, true);
    assertBindingOperationExtensions(bi.getOperation(greetMeOpName), false);

    // binding/operation/[input|output|fault] extensions

    assertBindingOperationMessageExtensions(boi, true, true, faultName);
    assertBindingOperationMessageExtensions(bi.getOperation(greetMeOpName), false, true, null);
    control.verify();

}
 
Example #19
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void assertPortTypeOperationMessageExtensions(OperationInfo oi, boolean expectExtensions,
    boolean hasOutput, QName fault) {

    MessageInfo mi = oi.getInput();
    if (expectExtensions) {
        assertEquals(1, mi.getExtensionAttributes().size());
        assertNotNull(mi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertEquals(1, mi.getExtensors(UnknownExtensibilityElement.class).size());
        assertEquals(EXTENSION_ELEM, mi.getExtensor(UnknownExtensibilityElement.class).getElementType());
    } else {
        assertNull(mi.getExtensionAttributes());
        assertNull(mi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertNull(mi.getExtensors(UnknownExtensibilityElement.class));
        assertNull(mi.getExtensor(UnknownExtensibilityElement.class));
    }

    if (hasOutput) {
        mi = oi.getOutput();
        if (expectExtensions) {
            assertEquals(1, mi.getExtensionAttributes().size());
            assertNotNull(mi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertEquals(1, mi.getExtensors(UnknownExtensibilityElement.class).size());
            assertEquals(EXTENSION_ELEM,
                mi.getExtensor(UnknownExtensibilityElement.class).getElementType());
        } else {
            assertNull(mi.getExtensionAttributes());
            assertNull(mi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertNull(mi.getExtensors(UnknownExtensibilityElement.class));
            assertNull(mi.getExtensor(UnknownExtensibilityElement.class));
        }
    }

    if (null != fault) {
        FaultInfo fi = oi.getFault(fault);
        if (expectExtensions) {
            assertEquals(1, fi.getExtensionAttributes().size());
            assertNotNull(fi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertEquals(1, fi.getExtensors(UnknownExtensibilityElement.class).size());
            assertEquals(EXTENSION_ELEM,
                fi.getExtensor(UnknownExtensibilityElement.class).getElementType());
        } else {
            assertNull(fi.getExtensionAttributes());
            assertNull(fi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertNull(fi.getExtensors(UnknownExtensibilityElement.class));
            assertNull(fi.getExtensor(UnknownExtensibilityElement.class));
        }
    }
}
 
Example #20
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void assertBindingOperationMessageExtensions(BindingOperationInfo boi, boolean expectExtensions,
    boolean hasOutput, QName fault) {

    BindingMessageInfo bmi = boi.getInput();
    if (expectExtensions) {
        // REVISIT: bug in wsdl4j?
        // getExtensionAttributes on binding/operation/input element returns an empty map
        // assertEquals(1, bmi.getExtensionAttributes().size());
        // assertNotNull(bmi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertEquals(1, bmi.getExtensors(UnknownExtensibilityElement.class).size());
        assertEquals(EXTENSION_ELEM, bmi.getExtensor(UnknownExtensibilityElement.class).getElementType());
    } else {
        assertNull(bmi.getExtensionAttributes());
        assertNull(bmi.getExtensionAttribute(EXTENSION_ATTR_STRING));
        assertEquals(0, bmi.getExtensors(UnknownExtensibilityElement.class).size());
        assertNull(bmi.getExtensor(UnknownExtensibilityElement.class));
    }

    if (hasOutput) {
        bmi = boi.getOutput();
        if (expectExtensions) {
            // REVISIT: bug in wsdl4j?
            // getExtensionAttributes on binding/operation/output element returns an empty map
            // assertEquals(1, bmi.getExtensionAttributes().size());
            // assertNotNull(bmi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertEquals(1, bmi.getExtensors(UnknownExtensibilityElement.class).size());
            assertEquals(EXTENSION_ELEM,
                bmi.getExtensor(UnknownExtensibilityElement.class).getElementType());
        } else {
            assertNull(bmi.getExtensionAttributes());
            assertNull(bmi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertEquals(0, bmi.getExtensors(UnknownExtensibilityElement.class).size());
            assertNull(bmi.getExtensor(UnknownExtensibilityElement.class));
        }
    }

    if (null != fault) {
        BindingFaultInfo bfi = boi.getFault(fault);
        if (expectExtensions) {
            assertEquals(1, bfi.getExtensionAttributes().size());
            assertNotNull(bfi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertEquals(1, bfi.getExtensors(UnknownExtensibilityElement.class).size());
            assertEquals(EXTENSION_ELEM,
                bfi.getExtensor(UnknownExtensibilityElement.class).getElementType());
        } else {
            assertNull(bfi.getExtensionAttributes());
            assertNull(bfi.getExtensionAttribute(EXTENSION_ATTR_STRING));
            assertNull(bfi.getExtensors(UnknownExtensibilityElement.class));
            assertNull(bfi.getExtensor(UnknownExtensibilityElement.class));
        }
    }
}