Search in sources :

Example 1 with APIMWSDLReader

use of org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader in project carbon-apimgt by wso2.

the class WSDL11SOAPOperationExtractor method getBasedXSDofWSDL.

private Document getBasedXSDofWSDL(String ns) {
    if (basedSchemas.containsKey(ns)) {
        return basedSchemas.get(ns);
    }
    Document doc = null;
    APIMWSDLReader reader = new APIMWSDLReader(ns + ".xsd");
    try {
        doc = reader.getSecuredParsedDocumentFromURL(ns + ".xsd");
    } catch (APIManagementException e) {
        String error = "Error occurred reading wsdl document.";
        log.error(error, e);
    }
    basedSchemas.put(ns, doc);
    return doc;
}
Also used : APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader) Document(org.w3c.dom.Document)

Example 2 with APIMWSDLReader

use of org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader in project carbon-apimgt by wso2.

the class SOAPOperationBindingTestCase method testGetWSDLProcessor.

@Test
public void testGetWSDLProcessor() throws Exception {
    APIMWSDLReader wsdlReader = new APIMWSDLReader(Thread.currentThread().getContextClassLoader().getResource("wsdls/phoneverify.wsdl").toExternalForm());
    byte[] wsdlContent = wsdlReader.getWSDL();
    WSDL11SOAPOperationExtractor processor = SOAPOperationBindingUtils.getWSDL11SOAPOperationExtractor(wsdlContent, wsdlReader);
    Assert.assertNotNull(processor);
    Assert.assertTrue("Failed to get soap binding operations from the WSDL", processor.getWsdlInfo().getSoapBindingOperations().size() > 0);
}
Also used : APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with APIMWSDLReader

use of org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader in project carbon-apimgt by wso2.

the class WSDLSOAPOperationExtractorImplTestCase method testGetSwaggerModelForWSDLsWithCompositeBindings.

@Test
public void testGetSwaggerModelForWSDLsWithCompositeBindings() throws Exception {
    APIMWSDLReader wsdlReader = new APIMWSDLReader(Thread.currentThread().getContextClassLoader().getResource("wsdls/wsdl-with-composite-bindings/sampleservice.wsdl").toExternalForm());
    byte[] wsdlContent = wsdlReader.getWSDL();
    WSDL11SOAPOperationExtractor processor = SOAPOperationBindingUtils.getWSDL11SOAPOperationExtractor(wsdlContent, wsdlReader);
    Set<WSDLSOAPOperation> operations = processor.getWsdlInfo().getSoapBindingOperations();
    Assert.assertNotNull(operations);
    Map<String, ModelImpl> parameterModelMap = processor.getWsdlInfo().getParameterModelMap();
    Assert.assertNotNull(parameterModelMap);
}
Also used : APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) ModelImpl(io.swagger.models.ModelImpl) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with APIMWSDLReader

use of org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader in project carbon-apimgt by wso2.

the class WSDLSOAPOperationExtractorImplTestCase method testGetWsdlDefinition.

@Test
public void testGetWsdlDefinition() throws Exception {
    APIMWSDLReader wsdlReader = new APIMWSDLReader(Thread.currentThread().getContextClassLoader().getResource("wsdls/phoneverify.wsdl").toExternalForm());
    byte[] wsdlContent = wsdlReader.getWSDL();
    WSDL11SOAPOperationExtractor processor = new WSDL11SOAPOperationExtractor(wsdlReader);
    Assert.assertTrue("WSDL definition parsing failed", processor.init(wsdlContent));
}
Also used : APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with APIMWSDLReader

use of org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader in project carbon-apimgt by wso2.

the class WSDLSOAPOperationExtractorImplTestCase method testGetSwaggerModelForSimpleType.

@Test
public void testGetSwaggerModelForSimpleType() throws Exception {
    APIMWSDLReader wsdlReader = new APIMWSDLReader(Thread.currentThread().getContextClassLoader().getResource("wsdls/sample-service.wsdl").toExternalForm());
    byte[] wsdlContent = wsdlReader.getWSDL();
    WSDL11SOAPOperationExtractor processor = SOAPOperationBindingUtils.getWSDL11SOAPOperationExtractor(wsdlContent, wsdlReader);
    Map<String, ModelImpl> parameterModelMap = processor.getWsdlInfo().getParameterModelMap();
    Assert.assertNotNull(parameterModelMap);
    // get simple type
    Assert.assertNotNull(parameterModelMap.get("Condition"));
    Assert.assertEquals("string", parameterModelMap.get("Condition").getType());
    // get simple type inside complex type
    Assert.assertNotNull(parameterModelMap.get("ItemSearchRequest").getProperties().get("Availability"));
    Assert.assertEquals("string", parameterModelMap.get("ItemSearchRequest").getProperties().get("Availability").getType());
}
Also used : APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader) ModelImpl(io.swagger.models.ModelImpl) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

APIMWSDLReader (org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader)11 Test (org.junit.Test)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)6 ModelImpl (io.swagger.models.ModelImpl)4 Definition (javax.wsdl.Definition)3 API (org.wso2.carbon.apimgt.api.model.API)3 WSDL11SOAPOperationExtractor (org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor)3 Document (org.w3c.dom.Document)2 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)2 WSDLProcessor (org.wso2.carbon.apimgt.impl.wsdl.WSDLProcessor)2 WSDLSOAPOperation (org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation)2 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 OMElement (org.apache.axiom.om.OMElement)1