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 });
}
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);
}
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);
}
}
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);
}
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);
}
Aggregations