use of org.wso2.broker.core.Broker in project carbon-apimgt by wso2.
the class APIGatewayPublisherImplTestCase method testDeleteAPIWhenAPIDoesNotHaveOwnGateway.
@Test
public void testDeleteAPIWhenAPIDoesNotHaveOwnGateway() throws GatewayException, ContainerBasedGatewayException {
APIGatewayPublisherImpl apiGatewayPublisher = new APIGatewayPublisherImpl();
Broker broker = Mockito.mock(BrokerImpl.class, Mockito.RETURNS_DEEP_STUBS);
BrokerUtil.initialize(broker);
ContainerBasedGatewayGenerator containerBasedGatewayGenerator = Mockito.mock(ContainerBasedGatewayGenerator.class);
apiGatewayPublisher.setContainerBasedGatewayGenerator(containerBasedGatewayGenerator);
List<String> labels = new ArrayList<>();
labels.add("label");
API api = SampleTestObjectCreator.createDefaultAPI().lifeCycleStatus(APIStatus.PUBLISHED.getStatus()).hasOwnGateway(false).labels(labels).build();
apiGatewayPublisher.deleteAPI(api);
Mockito.verify(containerBasedGatewayGenerator, Mockito.times(0)).removeContainerBasedGateway("label", api);
}
use of org.wso2.broker.core.Broker in project carbon-apimgt by wso2.
the class BrokerManager method start.
/**
* Starting the broker
*/
public static void start() {
try {
StartupContext startupContext = new StartupContext();
initConfigProvider(startupContext);
BrokerConfigProvider service = startupContext.getService(BrokerConfigProvider.class);
BrokerConfiguration brokerConfiguration = service.getConfigurationObject(BrokerConfiguration.NAMESPACE, BrokerConfiguration.class);
DataSource dataSource = getDataSource(brokerConfiguration.getDataSource());
startupContext.registerService(DataSource.class, dataSource);
restServer = new BrokerRestServer(startupContext);
broker = new Broker(startupContext);
broker.startMessageDelivery();
amqpServer = new Server(startupContext);
amqpServer.start();
restServer.start();
loadUsers();
} catch (Exception e) {
log.error("Error while starting broker", e);
}
}
use of org.wso2.broker.core.Broker in project carbon-apimgt by wso2.
the class APIGatewayPublisherImplTestCase method testDeleteAPIForException.
@Test(expected = GatewayException.class)
public void testDeleteAPIForException() throws GatewayException, ContainerBasedGatewayException {
APIGatewayPublisherImpl apiGatewayPublisher = new APIGatewayPublisherImpl();
Broker broker = Mockito.mock(BrokerImpl.class, Mockito.RETURNS_DEEP_STUBS);
BrokerUtil.initialize(broker);
ContainerBasedGatewayGenerator containerBasedGatewayGenerator = Mockito.mock(ContainerBasedGatewayGenerator.class);
apiGatewayPublisher.setContainerBasedGatewayGenerator(containerBasedGatewayGenerator);
Mockito.doThrow(ContainerBasedGatewayException.class).when(containerBasedGatewayGenerator).removeContainerBasedGateway(Mockito.any(), Mockito.any());
List<String> labels = new ArrayList<>();
labels.add("label");
API api = SampleTestObjectCreator.createDefaultAPI().lifeCycleStatus(APIStatus.PUBLISHED.getStatus()).hasOwnGateway(true).labels(labels).build();
apiGatewayPublisher.deleteAPI(api);
}
use of org.wso2.broker.core.Broker in project carbon-apimgt by wso2.
the class APIGatewayPublisherImplTestCase method testDeleteAPIWhenLabelAreEmpty.
@Test
public void testDeleteAPIWhenLabelAreEmpty() throws GatewayException, ContainerBasedGatewayException {
APIGatewayPublisherImpl apiGatewayPublisher = new APIGatewayPublisherImpl();
Broker broker = Mockito.mock(BrokerImpl.class, Mockito.RETURNS_DEEP_STUBS);
BrokerUtil.initialize(broker);
ContainerBasedGatewayGenerator containerBasedGatewayGenerator = Mockito.mock(ContainerBasedGatewayGenerator.class);
apiGatewayPublisher.setContainerBasedGatewayGenerator(containerBasedGatewayGenerator);
List<String> labels = new ArrayList<>();
API api = SampleTestObjectCreator.createDefaultAPI().lifeCycleStatus(APIStatus.PUBLISHED.getStatus()).hasOwnGateway(true).labels(labels).build();
apiGatewayPublisher.deleteAPI(api);
Mockito.verify(containerBasedGatewayGenerator, Mockito.times(0)).removeContainerBasedGateway("label", api);
}
use of org.wso2.broker.core.Broker in project carbon-apimgt by wso2.
the class APIGatewayPublisherImplTestCase method testDeleteAPIWhenAPIHasOwnGateway.
@Test
public void testDeleteAPIWhenAPIHasOwnGateway() throws GatewayException, ContainerBasedGatewayException {
APIGatewayPublisherImpl apiGatewayPublisher = new APIGatewayPublisherImpl();
Broker broker = Mockito.mock(BrokerImpl.class, Mockito.RETURNS_DEEP_STUBS);
BrokerUtil.initialize(broker);
ContainerBasedGatewayGenerator containerBasedGatewayGenerator = Mockito.mock(ContainerBasedGatewayGenerator.class);
apiGatewayPublisher.setContainerBasedGatewayGenerator(containerBasedGatewayGenerator);
List<String> labels = new ArrayList<>();
labels.add("label");
API api = SampleTestObjectCreator.createDefaultAPI().lifeCycleStatus(APIStatus.PUBLISHED.getStatus()).hasOwnGateway(true).labels(labels).build();
apiGatewayPublisher.deleteAPI(api);
Mockito.verify(containerBasedGatewayGenerator, Mockito.times(1)).removeContainerBasedGateway("label", api);
}
Aggregations