use of org.apache.cloudstack.framework.events.EventTopic in project cloudstack by apache.
the class InMemoryEventBusTest method testPublish.
@Test
public void testPublish() throws Exception {
EventTopic topic = mock(EventTopic.class);
EventSubscriber subscriber = mock(EventSubscriber.class);
Event event = mock(Event.class);
InMemoryEventBus bus = new InMemoryEventBus();
UUID uuid = bus.subscribe(topic, subscriber);
assertNotNull(uuid);
String uuidStr = uuid.toString();
assertTrue(UuidUtils.validateUUID(uuidStr));
assertTrue(bus.totalSubscribers() == 1);
bus.publish(event);
verify(subscriber, times(1)).onEvent(event);
bus.unsubscribe(uuid, subscriber);
assertTrue(bus.totalSubscribers() == 0);
}
Aggregations