Search in sources :

Example 6 with APIManagerConfigurationServiceImpl

use of org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl in project carbon-apimgt by wso2.

the class APIProviderImplTest method init.

@Before
public void init() throws Exception {
    System.setProperty("carbon.home", APIProviderImplTest.class.getResource("/").getFile());
    PowerMockito.mockStatic(ApiMgtDAO.class);
    PowerMockito.mockStatic(GatewayArtifactsMgtDAO.class);
    PowerMockito.mockStatic(ScopesDAO.class);
    PowerMockito.mockStatic(PrivilegedCarbonContext.class);
    PowerMockito.mockStatic(RegistryUtils.class);
    PowerMockito.mockStatic(GovernanceUtils.class);
    PowerMockito.mockStatic(WorkflowExecutorFactory.class);
    PowerMockito.mockStatic(LifecycleBeanPopulator.class);
    PowerMockito.mockStatic(KeyManagerHolder.class);
    PowerMockito.mockStatic(Caching.class);
    PowerMockito.mockStatic(PaginationContext.class);
    PowerMockito.mockStatic(APIUtil.class);
    PowerMockito.mockStatic(APIGatewayManager.class);
    PowerMockito.mockStatic(CertificateManagerImpl.class);
    PowerMockito.mockStatic(RegistryPersistenceUtil.class);
    apimgtDAO = Mockito.mock(ApiMgtDAO.class);
    gatewayArtifactsMgtDAO = Mockito.mock(GatewayArtifactsMgtDAO.class);
    scopesDAO = Mockito.mock(ScopesDAO.class);
    keyManager = Mockito.mock(KeyManager.class);
    apiPersistenceInstance = Mockito.mock(APIPersistence.class);
    certificateManager = Mockito.mock(CertificateManagerImpl.class);
    Mockito.when(keyManager.getResourceByApiId(Mockito.anyString())).thenReturn(null);
    Mockito.when(keyManager.registerNewResource(Mockito.any(API.class), Mockito.any(Map.class))).thenReturn(true);
    KeyManagerDto keyManagerDto = new KeyManagerDto();
    keyManagerDto.setName("default");
    keyManagerDto.setKeyManager(keyManager);
    keyManagerDto.setIssuer("https://localhost");
    Map<String, KeyManagerDto> tenantKeyManagerDtoMap = new HashMap<>();
    tenantKeyManagerDtoMap.put("default", keyManagerDto);
    PowerMockito.when(KeyManagerHolder.getTenantKeyManagers("carbon.super")).thenReturn(tenantKeyManagerDtoMap);
    PowerMockito.when(CertificateManagerImpl.getInstance()).thenReturn(certificateManager);
    PowerMockito.when(APIUtil.isAPIManagementEnabled()).thenReturn(false);
    PowerMockito.when(APIUtil.replaceEmailDomainBack(Mockito.anyString())).thenReturn("admin");
    Mockito.when(APIUtil.replaceEmailDomain(Mockito.anyString())).thenReturn("admin");
    PrivilegedCarbonContext prcontext = Mockito.mock(PrivilegedCarbonContext.class);
    PowerMockito.when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(prcontext);
    PowerMockito.doNothing().when(prcontext).setUsername(Mockito.anyString());
    PowerMockito.doNothing().when(prcontext).setTenantDomain(Mockito.anyString(), Mockito.anyBoolean());
    artifactManager = Mockito.mock(GenericArtifactManager.class);
    registry = Mockito.mock(Registry.class);
    PowerMockito.when(APIUtil.getArtifactManager(any(Registry.class), Mockito.anyString())).thenReturn(artifactManager);
    artifact = Mockito.mock(GenericArtifact.class);
    gatewayManager = Mockito.mock(APIGatewayManager.class);
    Mockito.when(APIGatewayManager.getInstance()).thenReturn(gatewayManager);
    TestUtils.mockRegistryAndUserRealm(-1234);
    TestUtils.mockAPICacheClearence();
    TestUtils.mockAPIMConfiguration();
    mockDocumentationCreation();
    config = Mockito.mock(APIManagerConfiguration.class);
    APIManagerConfigurationService apiManagerConfigurationService = new APIManagerConfigurationServiceImpl(config);
    ServiceReferenceHolder.getInstance().setAPIManagerConfigurationService(apiManagerConfigurationService);
    APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
    GatewayArtifactSynchronizerProperties synchronizerProperties = new GatewayArtifactSynchronizerProperties();
    Mockito.when(config.getGatewayArtifactSynchronizerProperties()).thenReturn(synchronizerProperties);
    Mockito.when(config.getApiRecommendationEnvironment()).thenReturn(null);
    PowerMockito.when(APIUtil.replaceSystemProperty(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> {
        Object[] args = invocation.getArguments();
        return (String) args[0];
    });
    TestUtils.initConfigurationContextService(true);
    superTenantDomain = "carbon.super";
}
Also used : RegistryAuthorizationManager(org.wso2.carbon.registry.core.jdbc.realm.RegistryAuthorizationManager) StringUtils(org.apache.commons.lang.StringUtils) ApiTypeWrapper(org.wso2.carbon.apimgt.api.model.ApiTypeWrapper) APIPersistenceException(org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException) PaginationContext(org.wso2.carbon.registry.core.pagination.PaginationContext) LifecycleBean(org.wso2.carbon.governance.custom.lifecycles.checklist.beans.LifecycleBean) QuotaPolicy(org.wso2.carbon.apimgt.api.model.policy.QuotaPolicy) RealmService(org.wso2.carbon.user.core.service.RealmService) ResourceImpl(org.wso2.carbon.registry.core.ResourceImpl) ImportExportAPI(org.wso2.carbon.apimgt.impl.importexport.ImportExportAPI) Map(java.util.Map) XMLStreamException(javax.xml.stream.XMLStreamException) ApplicationPolicy(org.wso2.carbon.apimgt.api.model.policy.ApplicationPolicy) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) APIPolicy(org.wso2.carbon.apimgt.api.model.policy.APIPolicy) AuthorizationManager(org.wso2.carbon.user.api.AuthorizationManager) DocumentationType(org.wso2.carbon.apimgt.api.model.DocumentationType) GatewayArtifactSynchronizerProperties(org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties) ContentType(org.apache.http.entity.ContentType) Set(java.util.Set) WorkflowConstants(org.wso2.carbon.apimgt.impl.workflow.WorkflowConstants) HTTPVerbCondition(org.wso2.carbon.apimgt.api.model.policy.HTTPVerbCondition) RegistryPersistenceUtil(org.wso2.carbon.apimgt.persistence.utils.RegistryPersistenceUtil) UserStoreManager(org.wso2.carbon.user.core.UserStoreManager) Matchers.any(org.mockito.Matchers.any) IOUtils(org.apache.commons.io.IOUtils) SubscriptionPolicy(org.wso2.carbon.apimgt.api.model.policy.SubscriptionPolicy) APIImportExportException(org.wso2.carbon.apimgt.impl.importexport.APIImportExportException) SubscribedAPI(org.wso2.carbon.apimgt.api.model.SubscribedAPI) GraphQLSchemaDefinition(org.wso2.carbon.apimgt.impl.definitions.GraphQLSchemaDefinition) MultitenantUtils(org.wso2.carbon.utils.multitenancy.MultitenantUtils) Assert.assertFalse(org.junit.Assert.assertFalse) PublisherAPIProduct(org.wso2.carbon.apimgt.persistence.dto.PublisherAPIProduct) QName(javax.xml.namespace.QName) CarbonConstants(org.wso2.carbon.CarbonConstants) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) APIStore(org.wso2.carbon.apimgt.api.model.APIStore) BlockConditionNotFoundException(org.wso2.carbon.apimgt.api.BlockConditionNotFoundException) APIStateChangeSimpleWorkflowExecutor(org.wso2.carbon.apimgt.impl.workflow.APIStateChangeSimpleWorkflowExecutor) FaultGatewaysException(org.wso2.carbon.apimgt.api.FaultGatewaysException) UserRealm(org.wso2.carbon.user.api.UserRealm) GovernanceArtifact(org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifact) RunWith(org.junit.runner.RunWith) GlobalPolicy(org.wso2.carbon.apimgt.api.model.policy.GlobalPolicy) Association(org.wso2.carbon.registry.core.Association) SuppressStaticInitializationFor(org.powermock.core.classloader.annotations.SuppressStaticInitializationFor) ArrayList(java.util.ArrayList) DocumentationContent(org.wso2.carbon.apimgt.api.model.DocumentationContent) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) RegistryConstants(org.wso2.carbon.registry.core.RegistryConstants) WorkflowProperties(org.wso2.carbon.apimgt.impl.dto.WorkflowProperties) Resource(org.wso2.carbon.registry.core.Resource) APIStateChangeResponse(org.wso2.carbon.apimgt.api.model.APIStateChangeResponse) Collection(org.wso2.carbon.registry.core.Collection) PowerMockito(org.powermock.api.mockito.PowerMockito) Before(org.junit.Before) URITemplate(org.wso2.carbon.apimgt.api.model.URITemplate) DuplicateAPIException(org.wso2.carbon.apimgt.api.model.DuplicateAPIException) Condition(org.wso2.carbon.apimgt.api.model.policy.Condition) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) APIMgtResourceAlreadyExistsException(org.wso2.carbon.apimgt.api.APIMgtResourceAlreadyExistsException) ScopesDAO(org.wso2.carbon.apimgt.impl.dao.ScopesDAO) Field(java.lang.reflect.Field) APIProduct(org.wso2.carbon.apimgt.api.model.APIProduct) APIRevision(org.wso2.carbon.apimgt.api.model.APIRevision) ApiMgtDAO(org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO) File(java.io.File) Assert.assertNull(org.junit.Assert.assertNull) TreeMap(java.util.TreeMap) Subscriber(org.wso2.carbon.apimgt.api.model.Subscriber) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) KeyManagerHolder(org.wso2.carbon.apimgt.impl.factory.KeyManagerHolder) KeyManagerDto(org.wso2.carbon.apimgt.impl.dto.KeyManagerDto) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) GenericArtifactManager(org.wso2.carbon.governance.api.generic.GenericArtifactManager) RegistryContext(org.wso2.carbon.registry.core.config.RegistryContext) ArtifactSynchronizerException(org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.exception.ArtifactSynchronizerException) KeyManager(org.wso2.carbon.apimgt.api.model.KeyManager) APIProductMapper(org.wso2.carbon.apimgt.persistence.mapper.APIProductMapper) RegistryUtils(org.wso2.carbon.registry.core.utils.RegistryUtils) XMLInputFactory(javax.xml.stream.XMLInputFactory) PolicyConstants(org.wso2.carbon.apimgt.api.model.policy.PolicyConstants) APIPersistence(org.wso2.carbon.apimgt.persistence.APIPersistence) Pipeline(org.wso2.carbon.apimgt.api.model.policy.Pipeline) BlockConditionsDTO(org.wso2.carbon.apimgt.api.model.BlockConditionsDTO) XMLStreamReader(javax.xml.stream.XMLStreamReader) UserRegistry(org.wso2.carbon.registry.core.session.UserRegistry) GovernanceUtils(org.wso2.carbon.governance.api.util.GovernanceUtils) NotifierConstants(org.wso2.carbon.apimgt.impl.notification.NotifierConstants) NotificationExecutor(org.wso2.carbon.apimgt.impl.notification.NotificationExecutor) APIUtil(org.wso2.carbon.apimgt.impl.utils.APIUtil) UUID(java.util.UUID) DocumentSourceType(org.wso2.carbon.apimgt.api.model.Documentation.DocumentSourceType) WorkflowException(org.wso2.carbon.apimgt.impl.workflow.WorkflowException) List(java.util.List) JSONObject(org.json.simple.JSONObject) DocumentVisibility(org.wso2.carbon.apimgt.api.model.Documentation.DocumentVisibility) Modifier(java.lang.reflect.Modifier) ResourceFile(org.wso2.carbon.apimgt.api.model.ResourceFile) TenantManager(org.wso2.carbon.user.core.tenant.TenantManager) PublisherAPI(org.wso2.carbon.apimgt.persistence.dto.PublisherAPI) SortedMap(java.util.SortedMap) AssertNotNull(org.apache.synapse.unittest.testcase.data.classes.AssertNotNull) Provider(org.wso2.carbon.apimgt.api.model.Provider) Matchers(org.mockito.Matchers) UserStoreException(org.wso2.carbon.user.api.UserStoreException) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) HashMap(java.util.HashMap) HashSet(java.util.HashSet) APIProductIdentifier(org.wso2.carbon.apimgt.api.model.APIProductIdentifier) Property(org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) RequestCountLimit(org.wso2.carbon.apimgt.api.model.policy.RequestCountLimit) PowerMockRunner(org.powermock.modules.junit4.PowerMockRunner) API(org.wso2.carbon.apimgt.api.model.API) ServiceReferenceHolder(org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder) JavaUtils(org.apache.axis2.util.JavaUtils) NotificationDTO(org.wso2.carbon.apimgt.impl.notification.NotificationDTO) DEFAULT_DIALECT_URI(org.wso2.carbon.apimgt.impl.token.ClaimsRetriever.DEFAULT_DIALECT_URI) OMElement(org.apache.axiom.om.OMElement) Tier(org.wso2.carbon.apimgt.api.model.Tier) UserApplicationAPIUsage(org.wso2.carbon.apimgt.api.dto.UserApplicationAPIUsage) GovernanceException(org.wso2.carbon.governance.api.exception.GovernanceException) APIPublisher(org.wso2.carbon.apimgt.api.model.APIPublisher) WorkflowExecutorFactory(org.wso2.carbon.apimgt.impl.workflow.WorkflowExecutorFactory) Documentation(org.wso2.carbon.apimgt.api.model.Documentation) Assert.assertNotNull(org.junit.Assert.assertNotNull) CertificateManagerImpl(org.wso2.carbon.apimgt.impl.certificatemgt.CertificateManagerImpl) Caching(javax.cache.Caching) WorkflowExecutor(org.wso2.carbon.apimgt.impl.workflow.WorkflowExecutor) GatewayArtifactsMgtDAO(org.wso2.carbon.apimgt.impl.dao.GatewayArtifactsMgtDAO) GenericArtifact(org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact) ArtifactSaver(org.wso2.carbon.apimgt.impl.gatewayartifactsynchronizer.ArtifactSaver) WorkflowDTO(org.wso2.carbon.apimgt.impl.dto.WorkflowDTO) Mockito(org.mockito.Mockito) OMException(org.apache.axiom.om.OMException) Ignore(org.junit.Ignore) Registry(org.wso2.carbon.registry.core.Registry) CheckListItem(org.wso2.carbon.governance.custom.lifecycles.checklist.util.CheckListItem) StAXOMBuilder(org.apache.axiom.om.impl.builder.StAXOMBuilder) WorkflowStatus(org.wso2.carbon.apimgt.impl.workflow.WorkflowStatus) OASParserUtil(org.wso2.carbon.apimgt.impl.definitions.OASParserUtil) CORSConfiguration(org.wso2.carbon.apimgt.api.model.CORSConfiguration) Organization(org.wso2.carbon.apimgt.persistence.dto.Organization) LifecycleBeanPopulator(org.wso2.carbon.governance.custom.lifecycles.checklist.util.LifecycleBeanPopulator) InputStream(java.io.InputStream) GenericArtifact(org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact) GenericArtifactManager(org.wso2.carbon.governance.api.generic.GenericArtifactManager) HashMap(java.util.HashMap) GatewayArtifactsMgtDAO(org.wso2.carbon.apimgt.impl.dao.GatewayArtifactsMgtDAO) GatewayArtifactSynchronizerProperties(org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties) ScopesDAO(org.wso2.carbon.apimgt.impl.dao.ScopesDAO) ApiMgtDAO(org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO) KeyManagerDto(org.wso2.carbon.apimgt.impl.dto.KeyManagerDto) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) UserRegistry(org.wso2.carbon.registry.core.session.UserRegistry) Registry(org.wso2.carbon.registry.core.Registry) ImportExportAPI(org.wso2.carbon.apimgt.impl.importexport.ImportExportAPI) SubscribedAPI(org.wso2.carbon.apimgt.api.model.SubscribedAPI) PublisherAPI(org.wso2.carbon.apimgt.persistence.dto.PublisherAPI) API(org.wso2.carbon.apimgt.api.model.API) KeyManager(org.wso2.carbon.apimgt.api.model.KeyManager) CertificateManagerImpl(org.wso2.carbon.apimgt.impl.certificatemgt.CertificateManagerImpl) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) APIPersistence(org.wso2.carbon.apimgt.persistence.APIPersistence) Before(org.junit.Before)

Example 7 with APIManagerConfigurationServiceImpl

use of org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl in project carbon-apimgt by wso2.

the class UserSignUpWSWorkflowExecutorTest method init.

@Before
public void init() throws Exception {
    ServiceReferenceHolder serviceReferenceHolder = TestUtils.getServiceReferenceHolder();
    ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class);
    ConfigurationContext configurationContext = Mockito.mock(ConfigurationContext.class);
    RealmService realmService = Mockito.mock(RealmService.class);
    UserRealm userRealm = Mockito.mock(UserRealm.class);
    userStoreManager = Mockito.mock(UserStoreManager.class);
    TenantManager tenantManager = Mockito.mock(TenantManager.class);
    apiManagerConfiguration = Mockito.mock(APIManagerConfiguration.class);
    serviceClient = Mockito.mock(ServiceClient.class);
    APIManagerConfigurationService apiManagerConfigurationService = new APIManagerConfigurationServiceImpl(apiManagerConfiguration);
    PowerMockito.mockStatic(SelfSignUpUtil.class);
    PowerMockito.mockStatic(CarbonUtils.class);
    PowerMockito.mockStatic(APIUtil.class);
    PowerMockito.when(APIUtil.isAnalyticsEnabled()).thenReturn(true);
    PowerMockito.doNothing().when(CarbonUtils.class, "setBasicAccessSecurityHeaders", Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any());
    PowerMockito.when(serviceReferenceHolder.getContextService()).thenReturn(configurationContextService);
    PowerMockito.when(configurationContextService.getClientConfigContext()).thenReturn(configurationContext);
    PowerMockito.when(serviceReferenceHolder.getAPIManagerConfigurationService()).thenReturn(apiManagerConfigurationService);
    PowerMockito.whenNew(ServiceClient.class).withAnyArguments().thenReturn(serviceClient);
    Mockito.when(serviceReferenceHolder.getRealmService()).thenReturn(realmService);
    Mockito.when(realmService.getTenantManager()).thenReturn(tenantManager);
    Mockito.when(tenantManager.getTenantId(tenantDomain)).thenReturn(tenantID);
    Mockito.when(tenantManager.getTenantId(tenantDomain)).thenReturn(tenantID);
    Mockito.when(realmService.getTenantUserRealm(tenantID)).thenReturn(userRealm);
    Mockito.when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    apiMgtDAO = TestUtils.getApiMgtDAO();
    userSignUpWSWorkflowExecutor = new UserSignUpWSWorkflowExecutor();
    workflowDTO = new WorkflowDTO();
    workflowDTO.setCallbackUrl(callBackURL);
    workflowDTO.setTenantDomain(tenantDomain);
    workflowDTO.setExternalWorkflowReference(externalWFReference);
    workflowDTO.setWorkflowReference(testUsername + "@carbon.super");
}
Also used : ServiceReferenceHolder(org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) WorkflowDTO(org.wso2.carbon.apimgt.impl.dto.WorkflowDTO) APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration) APIManagerConfigurationService(org.wso2.carbon.apimgt.impl.APIManagerConfigurationService) UserStoreManager(org.wso2.carbon.user.core.UserStoreManager) ConfigurationContextService(org.wso2.carbon.utils.ConfigurationContextService) UserRealm(org.wso2.carbon.user.core.UserRealm) APIManagerConfigurationServiceImpl(org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl) RealmService(org.wso2.carbon.user.core.service.RealmService) ServiceClient(org.apache.axis2.client.ServiceClient) TenantManager(org.wso2.carbon.user.core.tenant.TenantManager) Before(org.junit.Before)

Example 8 with APIManagerConfigurationServiceImpl

use of org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl in project carbon-apimgt by wso2.

the class TokenGenTest method setUp.

@Before
public void setUp() throws Exception {
    PowerMockito.mockStatic(CarbonUtils.class);
    PowerMockito.mockStatic(SubscriptionDataHolder.class);
    ServerConfiguration serverConfiguration = Mockito.mock(ServerConfiguration.class);
    Mockito.when(serverConfiguration.getFirstProperty(APIConstants.PORT_OFFSET_CONFIG)).thenReturn("2");
    PowerMockito.when(CarbonUtils.getServerConfiguration()).thenReturn(serverConfiguration);
    String dbConfigPath = System.getProperty("APIManagerDBConfigurationPath");
    APIManagerConfiguration config = new APIManagerConfiguration();
    config.load(dbConfigPath);
    ServiceReferenceHolder.getInstance().setAPIManagerConfigurationService(new APIManagerConfigurationServiceImpl(config));
    SubscriptionDataStore subscriptionDataStore = Mockito.mock(SubscriptionDataStore.class);
    SubscriptionDataHolder subscriptionDataHolder = Mockito.mock(SubscriptionDataHolder.class);
    PowerMockito.when(SubscriptionDataHolder.getInstance()).thenReturn(subscriptionDataHolder);
    PowerMockito.when(SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)).thenReturn(subscriptionDataStore);
    Application application = new Application();
    application.setId(1);
    application.setName("app2");
    application.setUUID(UUID.randomUUID().toString());
    application.addAttribute("abc", "cde");
    Mockito.when(subscriptionDataStore.getApplicationById(1)).thenReturn(application);
}
Also used : APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration) APIManagerConfigurationServiceImpl(org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl) ServerConfiguration(org.wso2.carbon.base.ServerConfiguration) SubscriptionDataStore(org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore) Application(org.wso2.carbon.apimgt.keymgt.model.entity.Application) SubscriptionDataHolder(org.wso2.carbon.apimgt.keymgt.SubscriptionDataHolder) Before(org.junit.Before)

Example 9 with APIManagerConfigurationServiceImpl

use of org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl in project carbon-apimgt by wso2.

the class JWTSignatureAlgTestCase method setUp.

@Before
public void setUp() throws Exception {
    PowerMockito.mockStatic(CarbonUtils.class);
    ServerConfiguration serverConfiguration = Mockito.mock(ServerConfiguration.class);
    Mockito.when(serverConfiguration.getFirstProperty(APIConstants.PORT_OFFSET_CONFIG)).thenReturn("2");
    PowerMockito.when(CarbonUtils.getServerConfiguration()).thenReturn(serverConfiguration);
    String dbConfigPath = System.getProperty("APIManagerDBConfigurationPath");
    APIManagerConfiguration config = new APIManagerConfiguration();
    config.load(dbConfigPath);
    ServiceReferenceHolder.getInstance().setAPIManagerConfigurationService(new APIManagerConfigurationServiceImpl(config));
}
Also used : APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration) APIManagerConfigurationServiceImpl(org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl) ServerConfiguration(org.wso2.carbon.base.ServerConfiguration) Before(org.junit.Before)

Example 10 with APIManagerConfigurationServiceImpl

use of org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl in project carbon-apimgt by wso2.

the class GatewayArtifactsMgtDAOTest method setUp.

@Before
public void setUp() throws Exception {
    String dbConfigPath = System.getProperty("APIManagerDBConfigurationPath");
    APIManagerConfiguration config = new APIManagerConfiguration();
    initializeDatabase(dbConfigPath);
    config.load(dbConfigPath);
    ServiceReferenceHolder.getInstance().setAPIManagerConfigurationService(new APIManagerConfigurationServiceImpl(config));
    ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration().getGatewayArtifactSynchronizerProperties().setArtifactSynchronizerDataSource("java:/comp/env/jdbc/WSO2AM_DB");
    GatewayArtifactsMgtDBUtil.initialize();
    gatewayArtifactsMgtDAO = GatewayArtifactsMgtDAO.getInstance();
    APIMgtDBUtil.initialize();
    apiMgtDAO = ApiMgtDAO.getInstance();
}
Also used : APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration) APIManagerConfigurationServiceImpl(org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl) Before(org.junit.Before)

Aggregations

APIManagerConfigurationServiceImpl (org.wso2.carbon.apimgt.impl.APIManagerConfigurationServiceImpl)11 APIManagerConfiguration (org.wso2.carbon.apimgt.impl.APIManagerConfiguration)10 Before (org.junit.Before)9 APIManagerConfigurationService (org.wso2.carbon.apimgt.impl.APIManagerConfigurationService)4 Test (org.junit.Test)3 API (org.wso2.carbon.apimgt.api.model.API)3 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)3 WorkflowDTO (org.wso2.carbon.apimgt.impl.dto.WorkflowDTO)3 ServiceReferenceHolder (org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder)3 UserStoreManager (org.wso2.carbon.user.core.UserStoreManager)3 RealmService (org.wso2.carbon.user.core.service.RealmService)3 TenantManager (org.wso2.carbon.user.core.tenant.TenantManager)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)2 Environment (org.wso2.carbon.apimgt.api.model.Environment)2 KeyManager (org.wso2.carbon.apimgt.api.model.KeyManager)2 WebsubSubscriptionConfiguration (org.wso2.carbon.apimgt.api.model.WebsubSubscriptionConfiguration)2 Notifier (org.wso2.carbon.apimgt.impl.notifier.Notifier)2 APITemplateBuilderImpl (org.wso2.carbon.apimgt.rest.api.publisher.v1.common.template.APITemplateBuilderImpl)2