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);
}
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);
}
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());
}
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;
}
Aggregations