Search in sources :

Example 1 with WSDL20ProcessorImpl

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl in project carbon-apimgt by wso2.

the class WSDL20ProcessorImplTestCase method testWSDLArchive.

@Test
public void testWSDLArchive() throws Exception {
    String extractedLocation = SampleTestObjectCreator.createDefaultWSDL20Archive();
    WSDL20ProcessorImpl wsdl20Processor = new WSDL20ProcessorImpl();
    wsdl20Processor.initPath(extractedLocation);
    Assert.assertTrue(wsdl20Processor.canProcess());
    assertDefaultArchivedWSDLContent(wsdl20Processor.getWsdlInfo(), new String[] { ORIGINAL_ENDPOINT_MY_SERVICE, ORIGINAL_ENDPOINT_PURCHASE_ORDER }, null);
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Label label = SampleTestObjectCreator.createLabel(SAMPLE_LABEL_NAME, SampleTestObjectCreator.LABEL_TYPE_STORE).build();
    String updatedPath = wsdl20Processor.getUpdatedWSDLPath(api, label);
    WSDL20ProcessorImpl wsdl20Processor2 = new WSDL20ProcessorImpl();
    wsdl20Processor2.initPath(updatedPath);
    Assert.assertTrue(wsdl20Processor2.canProcess());
    assertDefaultArchivedWSDLContent(wsdl20Processor2.getWsdlInfo(), new String[] { UPDATED_ENDPOINT_API_LABEL }, new String[] { ORIGINAL_ENDPOINT_MY_SERVICE, ORIGINAL_ENDPOINT_PURCHASE_ORDER });
}
Also used : Label(org.wso2.carbon.apimgt.core.models.Label) API(org.wso2.carbon.apimgt.core.models.API) Test(org.testng.annotations.Test)

Example 2 with WSDL20ProcessorImpl

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl in project carbon-apimgt by wso2.

the class WSDL20ProcessorImplTestCase method testSingleWSDL.

@Test
public void testSingleWSDL() throws Exception {
    WSDL20ProcessorImpl wsdl20Processor = new WSDL20ProcessorImpl();
    byte[] wsdlContentBytes = SampleTestObjectCreator.createDefaultWSDL20Content();
    wsdl20Processor.init(wsdlContentBytes);
    Assert.assertTrue(wsdl20Processor.canProcess());
    assertDefaultSingleWSDLContent(wsdl20Processor.getWsdlInfo(), ORIGINAL_ENDPOINT_MY_SERVICE, null);
    // validate the content from getWSDL() after initializing the WSDL processor
    byte[] originalWsdlContentFromProcessor = wsdl20Processor.getWSDL();
    WSDL20ProcessorImpl wsdl20Processor2 = new WSDL20ProcessorImpl();
    wsdl20Processor2.init(originalWsdlContentFromProcessor);
    Assert.assertTrue(wsdl20Processor2.canProcess());
    assertDefaultSingleWSDLContent(wsdl20Processor2.getWsdlInfo(), ORIGINAL_ENDPOINT_MY_SERVICE, null);
    // validate the content after updating endpoints using an API and Label
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Label label = SampleTestObjectCreator.createLabel(SAMPLE_LABEL_NAME, SampleTestObjectCreator.LABEL_TYPE_STORE).build();
    byte[] updatedWSDLWithEndpoint = wsdl20Processor.getUpdatedWSDL(api, label);
    // validate the content of wsdl20Processor's WSDL Info content after updating its endpoints
    assertDefaultSingleWSDLContent(wsdl20Processor.getWsdlInfo(), UPDATED_ENDPOINT_API_LABEL, ORIGINAL_ENDPOINT_MY_SERVICE);
    // validate the content of wsdl20Processor's returned WSDL content after updating its endpoints
    WSDL20ProcessorImpl wsdl20Processor3 = new WSDL20ProcessorImpl();
    wsdl20Processor3.init(updatedWSDLWithEndpoint);
    Assert.assertTrue(wsdl20Processor3.canProcess());
    assertDefaultSingleWSDLContent(wsdl20Processor3.getWsdlInfo(), UPDATED_ENDPOINT_API_LABEL, ORIGINAL_ENDPOINT_MY_SERVICE);
}
Also used : Label(org.wso2.carbon.apimgt.core.models.Label) API(org.wso2.carbon.apimgt.core.models.API) Test(org.testng.annotations.Test)

Example 3 with WSDL20ProcessorImpl

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl in project carbon-apimgt by wso2.

the class APIMWSDLReader method getWSDLProcessor.

/**
 * Gets WSDL processor WSDL 1.1/WSDL 2.0 based on the content {@code content}.
 *
 * @param content WSDL content
 * @return {@link WSDLProcessor}
 * @throws APIManagementException
 */
public static WSDLProcessor getWSDLProcessor(byte[] content) throws APIManagementException {
    WSDLProcessor wsdl11Processor = new WSDL11ProcessorImpl();
    WSDLProcessor wsdl20Processor = new WSDL20ProcessorImpl();
    try {
        if (wsdl11Processor.canProcess(content)) {
            wsdl11Processor.init(content);
            return wsdl11Processor;
        } else if (wsdl20Processor.canProcess(content)) {
            wsdl20Processor.init(content);
            return wsdl20Processor;
        } else {
            // no processors found if this line reaches
            throw new APIManagementException("No WSDL processor found to process WSDL content.", ExceptionCodes.CONTENT_NOT_RECOGNIZED_AS_WSDL);
        }
    } catch (APIMgtWSDLException e) {
        throw new APIManagementException("Error while instantiating wsdl processor class", e);
    }
}
Also used : WSDLProcessor(org.wso2.carbon.apimgt.impl.wsdl.WSDLProcessor) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) WSDL20ProcessorImpl(org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl) WSDL11ProcessorImpl(org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl)

Example 4 with WSDL20ProcessorImpl

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl in project carbon-apimgt by wso2.

the class WSDLProcessFactoryTestcase method testGetWSDLProcessorForContent.

@Test
public void testGetWSDLProcessorForContent() throws Exception {
    byte[] wsdl11Content = SampleTestObjectCreator.createDefaultWSDL11Content();
    WSDLProcessor processor = WSDLProcessFactory.getInstance().getWSDLProcessor(wsdl11Content);
    Assert.assertTrue(processor instanceof WSDL11ProcessorImpl);
    byte[] wsdl20Content = SampleTestObjectCreator.createDefaultWSDL20Content();
    processor = WSDLProcessFactory.getInstance().getWSDLProcessor(wsdl20Content);
    Assert.assertTrue(processor instanceof WSDL20ProcessorImpl);
}
Also used : WSDLProcessor(org.wso2.carbon.apimgt.core.api.WSDLProcessor) Test(org.testng.annotations.Test)

Example 5 with WSDL20ProcessorImpl

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl in project carbon-apimgt by wso2.

the class WSDLProcessFactoryTestcase method testGetWSDLProcessorForPath.

@Test
public void testGetWSDLProcessorForPath() throws Exception {
    String extractedLocation = SampleTestObjectCreator.createDefaultWSDL11Archive();
    WSDLProcessor processor = WSDLProcessFactory.getInstance().getWSDLProcessorForPath(extractedLocation);
    Assert.assertTrue(processor instanceof WSDL11ProcessorImpl);
    extractedLocation = SampleTestObjectCreator.createDefaultWSDL20Archive();
    processor = WSDLProcessFactory.getInstance().getWSDLProcessorForPath(extractedLocation);
    Assert.assertTrue(processor instanceof WSDL20ProcessorImpl);
}
Also used : WSDLProcessor(org.wso2.carbon.apimgt.core.api.WSDLProcessor) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)4 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 WSDL11ProcessorImpl (org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl)3 WSDL20ProcessorImpl (org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl)3 WSDLProcessor (org.wso2.carbon.apimgt.impl.wsdl.WSDLProcessor)3 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)3 WSDLProcessor (org.wso2.carbon.apimgt.core.api.WSDLProcessor)2 API (org.wso2.carbon.apimgt.core.models.API)2 Label (org.wso2.carbon.apimgt.core.models.Label)2