use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class ResultBoltTest method testExecuteMessagesAreSent.
@Test
public void testExecuteMessagesAreSent() {
List<PubSubMessage> expected = asList(new PubSubMessage("42", "This is a PubSubMessage", new Metadata()), new PubSubMessage("43", "This is also a PubSubMessage", new Metadata()), new PubSubMessage("44", "This is still a PubSubMessage", new Metadata()));
List<Tuple> tuples = new ArrayList<>();
expected.forEach(m -> tuples.add(makeTuple(m.getId(), m.getContent(), m.getMetadata())));
for (int i = 0; i < tuples.size(); i++) {
bolt.execute(tuples.get(i));
Assert.assertEquals(publisher.getSent().get(i).getId(), expected.get(i).getId());
Assert.assertEquals(publisher.getSent().get(i).getContent(), expected.get(i).getContent());
Assert.assertEquals(publisher.getSent().get(i).getMetadata(), expected.get(i).getMetadata());
Assert.assertTrue(collector.wasNthAcked(tuples.get(i), i + 1));
Assert.assertEquals(collector.getAckedCount(), i + 1);
}
}
use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class DRPCQueryResultPubscriberTest method testReadingOkResponse.
@Test(timeOut = 5000L)
public void testReadingOkResponse() throws Exception {
PubSubMessage expected = new PubSubMessage("foo", "response");
CompletableFuture<Response> response = getOkFuture(getOkResponse(expected.asJSON()));
AsyncHttpClient mockClient = mockClientWith(response);
pubscriber.setClient(mockClient);
pubscriber.send(new PubSubMessage("foo", "bar"));
// This is async (but practically still very fast since we mocked the response), so need a timeout.
PubSubMessage actual = fetchAsync().get();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.getId(), expected.getId());
Assert.assertEquals(actual.getContent(), expected.getContent());
}
use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class DRPCQueryResultPubscriberTest method testReadingNullResponse.
@Test(timeOut = 5000L)
public void testReadingNullResponse() throws Exception {
CompletableFuture<Response> response = getOkFuture(null);
AsyncHttpClient mockClient = mockClientWith(response);
pubscriber.setClient(mockClient);
pubscriber.send(new PubSubMessage("foo", "bar"));
// This is async (but practically still very fast since we mocked the response), so need a timeout.
PubSubMessage actual = fetchAsync().get();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.getId(), "foo");
Assert.assertEquals(actual.getContent(), CANNOT_REACH_DRPC.asJSONClip());
}
use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class DRPCQueryResultPubscriberTest method testReadingNotOkResponse.
@Test(timeOut = 5000L)
public void testReadingNotOkResponse() throws Exception {
CompletableFuture<Response> response = getOkFuture(getNotOkResponse(500));
AsyncHttpClient mockClient = mockClientWith(response);
pubscriber.setClient(mockClient);
pubscriber.send(new PubSubMessage("foo", "bar"));
// This is async (but practically still very fast since we mocked the response), so need a timeout.
PubSubMessage actual = fetchAsync().get();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.getId(), "foo");
Assert.assertEquals(actual.getContent(), CANNOT_REACH_DRPC.asJSONClip());
}
use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class DRPCQueryResultPubscriberTest method testException.
@Test(timeOut = 5000L)
public void testException() throws Exception {
// This will hit a non-existent url and fail, testing our exceptions. Our connect and retry is low so even if
// block the full amount, it's still fast.
pubscriber.send(new PubSubMessage("foo", "bar"));
PubSubMessage actual = fetchAsync().get();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.getId(), "foo");
Assert.assertEquals(actual.getContent(), CANNOT_REACH_DRPC.asJSONClip());
}
Aggregations