use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class PubSubTest method testConstructorRuntimeExceptionThrowsPubSubException.
@Test(expectedExceptions = PubSubException.class)
public void testConstructorRuntimeExceptionThrowsPubSubException() throws PubSubException {
BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
config.set(MockPubSub.MOCK_MESSAGE_NAME, "");
config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "");
PubSub.from(config);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class PubSubTest method testMockPubSubCreation.
@Test
public void testMockPubSubCreation() throws PubSubException {
BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
String mockMessage = UUID.randomUUID().toString();
config.set(MockPubSub.MOCK_MESSAGE_NAME, mockMessage);
PubSub testPubSub = PubSub.from(config);
Assert.assertEquals(testPubSub.getClass(), MockPubSub.class);
Assert.assertEquals(testPubSub.getSubscriber().receive().getContent(), mockMessage);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class PubSubTest method testSwitchingContext.
@Test
public void testSwitchingContext() throws PubSubException {
BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
config.set(MockPubSub.MOCK_MESSAGE_NAME, "");
PubSub pubSub = PubSub.from(config);
Assert.assertEquals(pubSub.getClass(), MockPubSub.class);
Assert.assertEquals(pubSub.getContext(), PubSub.Context.QUERY_SUBMISSION);
Assert.assertTrue(pubSub.getSubscriber().receive().getContent().isEmpty());
// No switch
pubSub.switchContext(PubSub.Context.QUERY_PROCESSING, new BulletConfig());
Assert.assertEquals(pubSub.getContext(), PubSub.Context.QUERY_PROCESSING);
Assert.assertTrue(pubSub.getSubscriber().receive().getContent().isEmpty());
// Switch
BulletConfig newConfig = new BulletConfig("src/test/resources/test_config.yaml");
newConfig.set(MockPubSub.MOCK_MESSAGE_NAME, "foo");
pubSub.switchContext(PubSub.Context.QUERY_SUBMISSION, newConfig);
Assert.assertEquals(pubSub.getContext(), PubSub.Context.QUERY_SUBMISSION);
Assert.assertEquals(pubSub.getSubscriber().receive().getContent(), "foo");
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class RESTPubSubTest method testGetPublishers.
@Test
public void testGetPublishers() throws PubSubException {
BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_SUBMISSION");
RESTPubSub pubSub = new RESTPubSub(config);
List<Publisher> publishers = pubSub.getPublishers(8);
Assert.assertNotNull(publishers);
Assert.assertTrue(publishers.get(0) instanceof RESTQueryPublisher);
Assert.assertTrue(publishers.get(7) instanceof RESTQueryPublisher);
config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_PROCESSING");
pubSub = new RESTPubSub(config);
publishers = pubSub.getPublishers(8);
Assert.assertNotNull(publishers);
Assert.assertTrue(publishers.get(0) instanceof RESTResultPublisher);
Assert.assertTrue(publishers.get(7) instanceof RESTResultPublisher);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class RESTPubSubTest method testGetSubscriber.
@Test
public void testGetSubscriber() throws PubSubException {
BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_SUBMISSION");
RESTPubSub pubSub = new RESTPubSub(config);
Subscriber subscriber = pubSub.getSubscriber();
Assert.assertNotNull(subscriber);
Assert.assertTrue(subscriber instanceof RESTSubscriber);
config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_PROCESSING");
pubSub = new RESTPubSub(config);
subscriber = pubSub.getSubscriber();
Assert.assertNotNull(subscriber);
Assert.assertTrue(subscriber instanceof RESTSubscriber);
}
Aggregations