Search in sources :

Example 6 with Subscriber

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);
}
Also used : Subscriber(com.yahoo.bullet.pubsub.Subscriber) Publisher(com.yahoo.bullet.pubsub.Publisher) Test(org.testng.annotations.Test)

Aggregations

Subscriber (com.yahoo.bullet.pubsub.Subscriber)6 Test (org.testng.annotations.Test)6 Publisher (com.yahoo.bullet.pubsub.Publisher)4 BulletConfig (com.yahoo.bullet.common.BulletConfig)2