use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method init.
@BeforeClass
void init() {
File temp = Files.createTempDir();
temp.deleteOnExit();
System.setProperty("gwHome", temp.getAbsolutePath());
// Set the resource path, where contain composer test JS
System.setProperty("carbon.home", new File("src/test/resources").getAbsolutePath());
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;
}
});
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class APIStoreImplTestCase 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);
}
use of org.wso2.carbon.config.provider.ConfigProvider in project carbon-apimgt by wso2.
the class ServiceReferenceHolderTestCase method testGetAPIMAppConfiguration.
@Test
public void testGetAPIMAppConfiguration() throws ConfigurationException {
// // Happy Path
ServiceReferenceHolder instance = ServiceReferenceHolder.getInstance();
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
instance.setConfigProvider(configProvider);
APIMAppConfigurations expectedConfigs = new APIMAppConfigurations();
expectedConfigs.setApimBaseUrl("https://localhost:9443/");
Mockito.when(configProvider.getConfigurationObject(Mockito.any(Class.class))).thenReturn(expectedConfigs);
APIMAppConfigurations actualConfigs = instance.getAPIMAppConfiguration();
Assert.assertNotNull(actualConfigs);
Assert.assertEquals(expectedConfigs.getApimBaseUrl(), actualConfigs.getApimBaseUrl());
// // Error path
// // ConfigurationException
Mockito.when(configProvider.getConfigurationObject(Mockito.any(Class.class))).thenThrow(ConfigurationException.class);
actualConfigs = instance.getAPIMAppConfiguration();
Assert.assertNotNull(actualConfigs);
// // config provider is null
instance.setConfigProvider(null);
actualConfigs = instance.getAPIMAppConfiguration();
Assert.assertNotNull(actualConfigs);
}
Aggregations