use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ContainerBasedGatewayConfigBuilderTestCase method testContainerBasedGatewayConfigBuilder.
@Test(description = "Test all the methods in ContainerBasedGatewayConfigBuilder")
public void testContainerBasedGatewayConfigBuilder() throws Exception {
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
ContainerBasedGatewayConfiguration config = Mockito.mock(ContainerBasedGatewayConfiguration.class);
Mockito.when(configProvider.getConfigurationObject(ContainerBasedGatewayConfiguration.class)).thenReturn(config);
ContainerBasedGatewayConfigBuilder.build(configProvider);
Assert.assertNotNull(ContainerBasedGatewayConfigBuilder.getContainerBasedGatewayConfiguration());
ContainerBasedGatewayConfigBuilder.clearContainerBasedGatewayConfig();
Assert.assertNull(ContainerBasedGatewayConfigBuilder.getContainerBasedGatewayConfiguration());
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ServiceDiscoveryConfigBuilderTestCase method testWhenExceptionThrownByConfigProvider.
@Test(description = "Test the flow where Config Provider throws an exception")
public void testWhenExceptionThrownByConfigProvider() throws Exception {
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
Mockito.doThrow(ConfigurationException.class).when(configProvider).getConfigurationObject(ServiceDiscoveryConfigurations.class);
ServiceDiscoveryConfigBuilder.build(configProvider);
Assert.assertNotNull(ServiceDiscoveryConfigBuilder.getServiceDiscoveryConfiguration());
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ServiceDiscoveryConfigBuilderTestCase method testServiceDiscoveryConfigBuilder.
@Test(description = "Test all the methods in ServiceDiscoveryConfigBuilder")
public void testServiceDiscoveryConfigBuilder() throws Exception {
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
ServiceDiscoveryConfigurations sdConfig = Mockito.mock(ServiceDiscoveryConfigurations.class);
Mockito.when(configProvider.getConfigurationObject(ServiceDiscoveryConfigurations.class)).thenReturn(sdConfig);
ServiceDiscoveryConfigBuilder.build(configProvider);
Assert.assertNotNull(ServiceDiscoveryConfigBuilder.getServiceDiscoveryConfiguration());
ServiceDiscoveryConfigBuilder.clearServiceDiscoveryConfig();
Assert.assertNull(ServiceDiscoveryConfigBuilder.getServiceDiscoveryConfiguration());
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ServiceReferenceHolder method getFeature.
/**
* Get feature details
*
* @param namespace Namespace
* @param featureName Name of the feature
* @return feature returns the feature details
*/
private Feature getFeature(String namespace, String featureName) {
Feature feature;
try {
if (configProvider != null) {
Map configs = (Map) configProvider.getConfigurationObject(namespace);
boolean enabled = false;
if (configs != null) {
enabled = (Boolean) configs.get(ConfigurationAPIConstants.ENABLED);
}
feature = new Feature(featureName, enabled);
return feature;
} else {
log.error("Configuration provider is null");
}
} catch (ConfigurationException e) {
log.error("Error getting configuration for namespace " + namespace, e);
}
feature = new Feature(featureName, false);
log.info("Setting default configurations for [feature] " + featureName + " and [namespace] " + namespace);
return feature;
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ConfigurationsAPITestCase method setup.
@BeforeTest
public void setup() throws Exception {
WorkflowExtensionsConfigBuilder.build(new ConfigProvider() {
@Override
public <T> T getConfigurationObject(Class<T> configClass) throws ConfigurationException {
T workflowConfig = (T) new WorkflowConfig();
return workflowConfig;
}
@Override
public Object getConfigurationObject(String s) throws ConfigurationException {
return null;
}
public <T> T getConfigurationObject(String s, Class<T> aClass) throws ConfigurationException {
return null;
}
});
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
ServiceReferenceHolder.getInstance().setConfigProvider(configProvider);
}
Aggregations