Search in sources :

Example 1 with ContainerBasedGatewayConfiguration

use of org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration 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);
}
Also used : ContainerBasedGatewayConfiguration(org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration) ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) Test(org.junit.Test)

Example 2 with ContainerBasedGatewayConfiguration

use of org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration 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);
}
Also used : ContainerBasedGatewayConfiguration(org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration) ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) Test(org.junit.Test)

Example 3 with ContainerBasedGatewayConfiguration

use of org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration 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());
}
Also used : ContainerBasedGatewayConfiguration(org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration) ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) Test(org.testng.annotations.Test)

Example 4 with ContainerBasedGatewayConfiguration

use of org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method getContainerBasedGatewayGenerator.

/**
 * Get Container Based Gateway Generator
 *
 * @return containerBasedGatewayGenerator
 * @throws ContainerBasedGatewayException if error occurred while initializing container based gateway generator
 */
public ContainerBasedGatewayGenerator getContainerBasedGatewayGenerator() throws ContainerBasedGatewayException {
    if (containerBasedGatewayGenerator == null) {
        try {
            ContainerBasedGatewayConfiguration containerBasedGatewayConfiguration = ContainerBasedGatewayConfigBuilder.getContainerBasedGatewayConfiguration();
            String implClassName = containerBasedGatewayConfiguration.getImplClass();
            Map<String, String> implParameters = containerBasedGatewayConfiguration.getImplParameters();
            containerBasedGatewayGenerator = (ContainerBasedGatewayGenerator) Class.forName(implClassName).newInstance();
            containerBasedGatewayGenerator.initImpl(implParameters);
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            throw new ContainerBasedGatewayException("Error occurred while initializing container based gateway " + "generator", e, ExceptionCodes.ERROR_INITIALIZING_DEDICATED_CONTAINER_BASED_GATEWAY);
        }
    }
    return containerBasedGatewayGenerator;
}
Also used : ContainerBasedGatewayConfiguration(org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration) ContainerBasedGatewayException(org.wso2.carbon.apimgt.core.exception.ContainerBasedGatewayException)

Aggregations

ContainerBasedGatewayConfiguration (org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration)4 ConfigProvider (org.wso2.carbon.config.provider.ConfigProvider)3 Test (org.junit.Test)2 Test (org.testng.annotations.Test)1 ContainerBasedGatewayException (org.wso2.carbon.apimgt.core.exception.ContainerBasedGatewayException)1