Search in sources :

Example 21 with ConfigProvider

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;
        }
    });
}
Also used : WorkflowConfig(org.wso2.carbon.apimgt.core.models.WorkflowConfig) ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) ConfigurationException(org.wso2.carbon.config.ConfigurationException) File(java.io.File) BeforeClass(org.testng.annotations.BeforeClass)

Example 22 with ConfigProvider

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);
}
Also used : WorkflowConfig(org.wso2.carbon.apimgt.core.models.WorkflowConfig) ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) ConfigurationException(org.wso2.carbon.config.ConfigurationException) BeforeTest(org.testng.annotations.BeforeTest)

Example 23 with 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);
}
Also used : ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) APIMAppConfigurations(org.wso2.carbon.apimgt.rest.api.authenticator.configuration.models.APIMAppConfigurations) Test(org.junit.Test)

Aggregations

ConfigProvider (org.wso2.carbon.config.provider.ConfigProvider)17 ConfigurationException (org.wso2.carbon.config.ConfigurationException)9 Test (org.testng.annotations.Test)8 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 ContainerBasedGatewayConfiguration (org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration)3 WorkflowConfig (org.wso2.carbon.apimgt.core.models.WorkflowConfig)3 Feature (org.wso2.carbon.apimgt.rest.api.configurations.models.Feature)3 Path (java.nio.file.Path)2 Map (java.util.Map)2 BeforeTest (org.testng.annotations.BeforeTest)2 BrokerConfigProvider (org.wso2.broker.common.BrokerConfigProvider)2 APIMConfigurations (org.wso2.carbon.apimgt.core.configuration.models.APIMConfigurations)2 APIMAppConfigurations (org.wso2.carbon.apimgt.rest.api.authenticator.configuration.models.APIMAppConfigurations)2 APIMUIConfigurations (org.wso2.carbon.apimgt.rest.api.configurations.models.APIMUIConfigurations)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 File (java.io.File)1 Context (javax.naming.Context)1 NamingException (javax.naming.NamingException)1 BundleContext (org.osgi.framework.BundleContext)1