use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ScopeRegistrationServiceStubFactoryTest method testGetScopeRegistrationForWso2Is.
@Test
public void testGetScopeRegistrationForWso2Is() throws Exception {
KeyMgtConfigurations keyManagerConfiguration = new KeyMgtConfigurations();
keyManagerConfiguration.setKeyManagerImplClass(WSO2ISKeyManagerImpl.class.getCanonicalName());
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
APIMConfigurations apimConfigurations = new APIMConfigurations();
apimConfigurations.setKeyManagerConfigs(keyManagerConfiguration);
Mockito.when(configProvider.getConfigurationObject(APIMConfigurations.class)).thenReturn(apimConfigurations);
ServiceReferenceHolder.getInstance().setConfigProvider(configProvider);
ScopeRegistration scopeRegistration = ScopeRegistrationServiceStubFactory.getScopeRegistration();
Assert.assertTrue(scopeRegistration instanceof WSO2ISScopeRegistrationImpl);
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ServiceReferenceHolder method getAPIMAppConfiguration.
public APIMAppConfigurations getAPIMAppConfiguration() {
try {
if (configProvider != null) {
config = configProvider.getConfigurationObject(APIMAppConfigurations.class);
} else {
log.error("Configuration provider is null");
}
} catch (ConfigurationException e) {
log.error("Error getting config : org.wso2.carbon.apimgt.rest.api.authenticator.internal.APIMAppConfiguration", e);
}
if (config == null) {
config = new APIMAppConfigurations();
log.info("Setting default configurations...");
}
return config;
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ServiceReferenceHolderTestCase method testGetRestAPIConfigurationMap.
@Test
public void testGetRestAPIConfigurationMap() throws ConfigurationException {
// // Happy Path
ServiceReferenceHolder instance = ServiceReferenceHolder.getInstance();
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
instance.setConfigProvider(configProvider);
Map<String, String> expectedConfigMap = new HashMap<>();
expectedConfigMap.put("apimBaseUrl", "https://localhost:9443/");
Mockito.when(configProvider.getConfigurationObject("xxx-namespace-xxx")).thenReturn(expectedConfigMap);
Map<String, String> actualConfigMap = instance.getRestAPIConfigurationMap("xxx-namespace-xxx");
Assert.assertEquals(expectedConfigMap, actualConfigMap);
// // Error path
// // ConfigurationException
Mockito.when(configProvider.getConfigurationObject("xxx-namespace-xxx")).thenThrow(ConfigurationException.class);
actualConfigMap = instance.getRestAPIConfigurationMap("xxx-namespace-xxx");
Assert.assertNull(actualConfigMap);
// // config provider is null
instance.setConfigProvider(null);
actualConfigMap = instance.getRestAPIConfigurationMap("xxx-namespace-xxx");
Assert.assertNull(actualConfigMap);
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class APIGatewayPublisherImplTestCase method testGetContainerBasedGatewayGenerator.
@Test
public void testGetContainerBasedGatewayGenerator() throws ContainerBasedGatewayException, ConfigurationException {
APIGatewayPublisherImpl apiGatewayPublisher = new APIGatewayPublisherImpl();
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
ContainerBasedGatewayConfiguration containerBasedGatewayConfig = new ContainerBasedGatewayConfiguration();
Mockito.when(configProvider.getConfigurationObject(ContainerBasedGatewayConfiguration.class)).thenReturn(containerBasedGatewayConfig);
ContainerBasedGatewayConfigBuilder.build(configProvider);
ContainerBasedGatewayGenerator containerBasedGatewayGenerator = apiGatewayPublisher.getContainerBasedGatewayGenerator();
Assert.assertNotNull(containerBasedGatewayGenerator);
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class APIGatewayPublisherImplTestCase method testGetContainerBasedGatewayGeneratorForException.
@Test(expected = ContainerBasedGatewayException.class)
public void testGetContainerBasedGatewayGeneratorForException() throws ContainerBasedGatewayException, ConfigurationException {
APIGatewayPublisherImpl apiGatewayPublisher = new APIGatewayPublisherImpl();
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
ContainerBasedGatewayConfiguration containerBasedGatewayConfig = new ContainerBasedGatewayConfiguration();
containerBasedGatewayConfig.setImplClass("org.wso2.invalid.class.name");
Mockito.when(configProvider.getConfigurationObject(ContainerBasedGatewayConfiguration.class)).thenReturn(containerBasedGatewayConfig);
ContainerBasedGatewayConfigBuilder.build(configProvider);
ContainerBasedGatewayGenerator containerBasedGatewayGenerator = apiGatewayPublisher.getContainerBasedGatewayGenerator();
Assert.assertNotNull(containerBasedGatewayGenerator);
}
Aggregations