Search in sources :

Example 1 with RegistryServiceHolder

use of org.wso2.carbon.mediation.registry.RegistryServiceHolder in project carbon-apimgt by wso2.

the class GatewayUtilsTestCase method setup.

@Before
public void setup() {
    System.setProperty("carbon.home", "jhkjn");
    PowerMockito.mockStatic(PrivilegedCarbonContext.class);
    PowerMockito.mockStatic(ServiceReferenceHolder.class);
    PowerMockito.mockStatic(RegistryServiceHolder.class);
    PowerMockito.mockStatic(SubscriptionDataHolder.class);
    PrivilegedCarbonContext privilegedCarbonContext = Mockito.mock(PrivilegedCarbonContext.class);
    serviceReferenceHolder = Mockito.mock(ServiceReferenceHolder.class);
    RegistryServiceHolder registryServiceHolder = Mockito.mock(RegistryServiceHolder.class);
    RegistryService registryService = Mockito.mock(RegistryService.class);
    userRegistry = Mockito.mock(UserRegistry.class);
    resource = Mockito.mock(Resource.class);
    PowerMockito.when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext);
    PowerMockito.when(ServiceReferenceHolder.getInstance()).thenReturn(serviceReferenceHolder);
    PowerMockito.when(RegistryServiceHolder.getInstance()).thenReturn(registryServiceHolder);
    Mockito.when(registryServiceHolder.getRegistryService()).thenReturn(registryService);
    Mockito.when(privilegedCarbonContext.getTenantId()).thenReturn(tenantID);
    Mockito.when(privilegedCarbonContext.getTenantDomain()).thenReturn("carbon.super");
    try {
        Mockito.when(registryService.getConfigSystemRegistry(tenantID)).thenReturn(userRegistry);
    } catch (RegistryException e) {
        fail("Error while mocking registryService.getConfigSystemRegistry");
    }
    try {
        Mockito.when(userRegistry.get(path)).thenReturn(resource);
    } catch (RegistryException e) {
        fail("Error while mocking userRegistry.get(path)");
    }
}
Also used : ServiceReferenceHolder(org.wso2.carbon.apimgt.gateway.internal.ServiceReferenceHolder) RegistryServiceHolder(org.wso2.carbon.mediation.registry.RegistryServiceHolder) Resource(org.wso2.carbon.registry.core.Resource) UserRegistry(org.wso2.carbon.registry.core.session.UserRegistry) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 ServiceReferenceHolder (org.wso2.carbon.apimgt.gateway.internal.ServiceReferenceHolder)1 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)1 RegistryServiceHolder (org.wso2.carbon.mediation.registry.RegistryServiceHolder)1 Resource (org.wso2.carbon.registry.core.Resource)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1 RegistryService (org.wso2.carbon.registry.core.service.RegistryService)1 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)1