use of com.yahoo.bullet.pubsub.Subscriber in project bullet-storm by yahoo.
the class DRPCPubSubTest method testQuerySubmissionOneInstanceIsTheSameInstance.
@Test
public void testQuerySubmissionOneInstanceIsTheSameInstance() throws Exception {
config.set(DRPCConfig.PUBSUB_CONTEXT_NAME, PubSub.Context.QUERY_SUBMISSION.name());
DRPCPubSub pubSub = new DRPCPubSub(config);
Publisher publisher = pubSub.getPublisher();
Subscriber subscriber = pubSub.getSubscriber();
Assert.assertTrue(publisher == subscriber);
// All future calls just return the same instance
Assert.assertTrue(publisher == pubSub.getPublisher());
Assert.assertTrue(subscriber == pubSub.getSubscriber());
Assert.assertTrue(pubSub.getPublisher() == pubSub.getSubscriber());
// So do calls to get multiples after
List<Publisher> publishers = pubSub.getPublishers(42);
List<Subscriber> subscribers = pubSub.getSubscribers(20);
Assert.assertEquals(publishers.size(), 1);
Assert.assertEquals(subscribers.size(), 1);
Assert.assertEquals(publishers.get(0), publisher);
Assert.assertEquals(subscribers.get(0), subscriber);
}
Aggregations