Search in sources :

Example 1 with WSDL11ProcessorImpl

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

the class WSDL11ProcessorImplTestCase method testWSDLArchive.

@Test
public void testWSDLArchive() throws Exception {
    String extractedLocation = SampleTestObjectCreator.createDefaultWSDL11Archive();
    WSDL11ProcessorImpl wsdl11Processor = new WSDL11ProcessorImpl();
    wsdl11Processor.initPath(extractedLocation);
    Assert.assertTrue(wsdl11Processor.canProcess());
    assertDefaultArchivedWSDLContent(wsdl11Processor.getWsdlInfo(), new String[] { SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER, SampleTestObjectCreator.ORIGINAL_ENDPOINT_STOCK_QUOTE }, null);
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Label label = SampleTestObjectCreator.createLabel(SAMPLE_LABEL_NAME, SampleTestObjectCreator.LABEL_TYPE_STORE).build();
    String updatedPath = wsdl11Processor.getUpdatedWSDLPath(api, label);
    WSDL11ProcessorImpl wsdl11Processor2 = new WSDL11ProcessorImpl();
    wsdl11Processor2.initPath(updatedPath);
    Assert.assertTrue(wsdl11Processor2.canProcess());
    assertDefaultArchivedWSDLContent(wsdl11Processor2.getWsdlInfo(), new String[] { UPDATED_ENDPOINT_API_LABEL }, new String[] { SampleTestObjectCreator.ORIGINAL_ENDPOINT_STOCK_QUOTE, SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER });
}
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 WSDL11ProcessorImpl

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

the class WSDL11ProcessorImplTestCase method testSingleWSDL.

@Test
public void testSingleWSDL() throws Exception {
    WSDL11ProcessorImpl wsdl11Processor = new WSDL11ProcessorImpl();
    byte[] wsdlContentBytes = SampleTestObjectCreator.createDefaultWSDL11Content();
    wsdl11Processor.init(wsdlContentBytes);
    Assert.assertTrue(wsdl11Processor.canProcess());
    assertDefaultSingleWSDLContent(wsdl11Processor.getWsdlInfo(), SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER, null);
    // validate the content from getWSDL() after initializing the WSDL processor
    byte[] originalWsdlContentFromProcessor = wsdl11Processor.getWSDL();
    WSDL11ProcessorImpl wsdl11Processor2 = new WSDL11ProcessorImpl();
    wsdl11Processor2.init(originalWsdlContentFromProcessor);
    Assert.assertTrue(wsdl11Processor2.canProcess());
    assertDefaultSingleWSDLContent(wsdl11Processor2.getWsdlInfo(), SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER, 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 = wsdl11Processor.getUpdatedWSDL(api, label);
    // validate the content of wsdl11Processor's WSDL Info content after updating its endpoints
    assertDefaultSingleWSDLContent(wsdl11Processor.getWsdlInfo(), UPDATED_ENDPOINT_API_LABEL, SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER);
    // validate the content of wsdl11Processor's returned WSDL content after updating its endpoints
    WSDL11ProcessorImpl wsdl11Processor3 = new WSDL11ProcessorImpl();
    wsdl11Processor3.init(updatedWSDLWithEndpoint);
    Assert.assertTrue(wsdl11Processor3.canProcess());
    assertDefaultSingleWSDLContent(wsdl11Processor3.getWsdlInfo(), UPDATED_ENDPOINT_API_LABEL, SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER);
}
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 WSDL11ProcessorImpl

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl 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 WSDL11ProcessorImpl

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl 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 WSDL11ProcessorImpl

use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl 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