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