Search in sources :

Example 26 with APIMgtWSDLException

use of org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException in project carbon-apimgt by wso2.

the class ApisApiServiceImplTestCase method testApisApiIdWsdlPutException.

@Test
public void testApisApiIdWsdlPutException() throws Exception {
    printTestMethodName();
    File file = new File(getClass().getClassLoader().getResource(WSDL_FILE_LOCATION).getFile());
    FileInfo fileInfo = new FileInfo();
    fileInfo.setFileName(WSDL_FILE);
    InputStream inputStream = new FileInputStream(file);
    ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
    APIPublisher apiPublisher = powerMockDefaultAPIPublisher();
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Mockito.doThrow(new APIMgtWSDLException("Error while updating WSDL", ExceptionCodes.INTERNAL_WSDL_EXCEPTION)).when(apiPublisher).updateAPIWSDL(api.getId(), inputStream);
    Response response = apisApiService.apisApiIdWsdlPut(api.getId(), inputStream, fileInfo, null, null, getRequest());
    assertEquals(response.getStatus(), 500);
}
Also used : WorkflowResponse(org.wso2.carbon.apimgt.core.api.WorkflowResponse) GeneralWorkflowResponse(org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse) Response(javax.ws.rs.core.Response) FileInfo(org.wso2.msf4j.formparam.FileInfo) APIMgtWSDLException(org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) APIPublisher(org.wso2.carbon.apimgt.core.api.APIPublisher) API(org.wso2.carbon.apimgt.core.models.API) File(java.io.File) FileInputStream(java.io.FileInputStream) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

APIMgtWSDLException (org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException)24 IOException (java.io.IOException)9 WSDLProcessor (org.wso2.carbon.apimgt.core.api.WSDLProcessor)8 File (java.io.File)6 InputStream (java.io.InputStream)5 FileInputStream (java.io.FileInputStream)4 WSDLException (javax.wsdl.WSDLException)4 WSDLException (org.apache.woden.WSDLException)4 WSDLArchiveInfo (org.wso2.carbon.apimgt.core.models.WSDLArchiveInfo)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 API (org.wso2.carbon.apimgt.core.models.API)3 FileOutputStream (java.io.FileOutputStream)2 MalformedURLException (java.net.MalformedURLException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Definition (javax.wsdl.Definition)2