Search in sources :

Example 16 with EndpointAdminServiceProxy

use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy in project carbon-apimgt by wso2.

the class APIGatewayAdminTest method getSequenceForTenant.

@Test
public void getSequenceForTenant() throws Exception {
    RESTAPIAdminServiceProxy restapiAdminServiceProxy = Mockito.mock(RESTAPIAdminServiceProxy.class);
    EndpointAdminServiceProxy endpointAdminServiceProxy = Mockito.mock(EndpointAdminServiceProxy.class);
    SequenceAdminServiceProxy sequenceAdminServiceProxy = Mockito.mock(SequenceAdminServiceProxy.class);
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMElement test1 = fac.createOMElement("test1", "", "");
    Mockito.when(sequenceAdminServiceProxy.getSequence(name)).thenReturn(test1);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(restapiAdminServiceProxy, endpointAdminServiceProxy, sequenceAdminServiceProxy);
    Assert.assertEquals(apiGatewayAdmin.getSequence(name), test1);
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) RESTAPIAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy) OMElement(org.apache.axiom.om.OMElement) EndpointAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy) SequenceAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy) Test(org.junit.Test)

Example 17 with EndpointAdminServiceProxy

use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy in project carbon-apimgt by wso2.

the class APIGatewayAdminTest method isExistingSequence.

@Test
public void isExistingSequence() throws Exception {
    RESTAPIAdminServiceProxy restapiAdminServiceProxy = Mockito.mock(RESTAPIAdminServiceProxy.class);
    EndpointAdminServiceProxy endpointAdminServiceProxy = Mockito.mock(EndpointAdminServiceProxy.class);
    SequenceAdminServiceProxy sequenceAdminServiceProxy = Mockito.mock(SequenceAdminServiceProxy.class);
    Mockito.when(sequenceAdminServiceProxy.isExistingSequence(name)).thenReturn(true);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(restapiAdminServiceProxy, endpointAdminServiceProxy, sequenceAdminServiceProxy);
    Assert.assertEquals(apiGatewayAdmin.isExistingSequence(name), true);
}
Also used : RESTAPIAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy) EndpointAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy) SequenceAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy) Test(org.junit.Test)

Example 18 with EndpointAdminServiceProxy

use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy in project carbon-apimgt by wso2.

the class GatewayUtils method retrieveDeployedEndpoints.

public static List<String> retrieveDeployedEndpoints(String apiName, String version, String tenantDomain) throws APIManagementException {
    List<String> deployedEndpoints = new ArrayList<>();
    try {
        MessageContext.setCurrentMessageContext(createAxis2MessageContext());
        EndpointAdminServiceProxy endpointAdminServiceProxy = new EndpointAdminServiceProxy(tenantDomain);
        String productionEndpointKey = apiName.concat("--v").concat(version).concat("_APIproductionEndpoint");
        String sandboxEndpointKey = apiName.concat("--v").concat(version).concat("_APIsandboxEndpoint");
        if (endpointAdminServiceProxy.isEndpointExist(productionEndpointKey)) {
            String entry = endpointAdminServiceProxy.getEndpoint(productionEndpointKey);
            deployedEndpoints.add(entry);
        }
        if (endpointAdminServiceProxy.isEndpointExist(sandboxEndpointKey)) {
            String entry = endpointAdminServiceProxy.getEndpoint(sandboxEndpointKey);
            deployedEndpoints.add(entry);
        }
    } catch (AxisFault e) {
        throw new APIManagementException("Error in fetching deployed endpoints from Synapse Configuration", e, ExceptionCodes.INTERNAL_ERROR);
    } finally {
        MessageContext.destroyCurrentMessageContext();
    }
    return deployedEndpoints;
}
Also used : AxisFault(org.apache.axis2.AxisFault) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) ArrayList(java.util.ArrayList)

Example 19 with EndpointAdminServiceProxy

use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy in project carbon-apimgt by wso2.

the class EndpointAdminServiceProxyTestCase method testCheckEndpointExistBeforeDelete.

@Test
public void testCheckEndpointExistBeforeDelete() {
    EndpointAdminServiceProxy endpointAdminServiceProxy = null;
    String endpointName = "PizzaShackAPI--v1.0.0_APIproductionEndpoint";
    String[] endpointArray = { "PizzaShackAPI--v1.0.0_APIproductionEndpoint", "PizzaShackAPI--v1.0.0_APIsandboxEndpoint" };
    String tenantDomain = "wso2.com";
    try {
        endpointAdminServiceProxy = new EndpointAdminServiceProxy(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        EndpointAdmin endpointAdmin = Mockito.mock(EndpointAdmin.class);
        Mockito.when(endpointAdmin.deleteEndpoint(endpointName)).thenReturn(true);
        Mockito.when(endpointAdmin.deleteEndpointForTenant(endpointName, tenantDomain)).thenReturn(true);
        Mockito.when(endpointAdmin.getEndPointsNames()).thenReturn(endpointArray);
        Mockito.when(endpointAdmin.getEndPointsNamesForTenant(tenantDomain)).thenReturn(endpointArray);
        endpointAdminServiceProxy.setEndpointAdmin(endpointAdmin);
    } catch (Exception e) {
        Assert.fail("Exception while testing CheckEndpointExistBeforeDelete");
    }
}
Also used : EndpointAdmin(org.wso2.carbon.endpoint.service.EndpointAdmin) Test(org.junit.Test)

Example 20 with EndpointAdminServiceProxy

use of org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy in project carbon-apimgt by wso2.

the class EndpointAdminServiceProxyTestCase method testAddEndpoint.

@Test
public void testAddEndpoint() {
    EndpointAdminServiceProxy endpointAdminServiceProxy = null;
    try {
        endpointAdminServiceProxy = new EndpointAdminServiceProxy(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        EndpointAdmin endpointAdmin = Mockito.mock(EndpointAdmin.class);
        Mockito.when(endpointAdmin.addEndpoint(Mockito.anyString())).thenReturn(true);
        endpointAdminServiceProxy.setEndpointAdmin(endpointAdmin);
    } catch (Exception e) {
        Assert.fail("Exception while testing addEndpoint");
    }
    try {
        endpointAdminServiceProxy.addEndpoint(Mockito.anyString());
    } catch (AxisFault e) {
        Assert.fail("AxisFault while testing addEndpoint");
    }
    try {
        endpointAdminServiceProxy.addEndpoint(Mockito.anyString());
    } catch (AxisFault e) {
        Assert.fail("AxisFault while testing addEndpoint");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) EndpointAdmin(org.wso2.carbon.endpoint.service.EndpointAdmin) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)17 EndpointAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.EndpointAdminServiceProxy)14 RESTAPIAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy)10 SequenceAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.SequenceAdminServiceProxy)10 AxisFault (org.apache.axis2.AxisFault)7 OMElement (org.apache.axiom.om.OMElement)4 EndpointAdmin (org.wso2.carbon.endpoint.service.EndpointAdmin)4 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 OMFactory (org.apache.axiom.om.OMFactory)2 API (org.wso2.carbon.apimgt.api.model.API)2 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)2 LocalEntryServiceProxy (org.wso2.carbon.apimgt.gateway.utils.LocalEntryServiceProxy)2 MediationSecurityAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.MediationSecurityAdminServiceProxy)2 CertificateManager (org.wso2.carbon.apimgt.impl.certificatemgt.CertificateManager)2 ArrayList (java.util.ArrayList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 CredentialDto (org.wso2.carbon.apimgt.api.gateway.CredentialDto)1 GatewayContentDTO (org.wso2.carbon.apimgt.api.gateway.GatewayContentDTO)1