use of nl.minvenj.nfi.storm.kafka.util.KafkaMessageId in project kafka-spout by HolmesNL.
the class KafkaSpoutBufferBehaviourTest method testEmitOneAtATime.
@Test
public void testEmitOneAtATime() {
final KafkaMessageId id1 = new KafkaMessageId(1, 1234);
final KafkaMessageId id2 = new KafkaMessageId(1, 1235);
final byte[] message1 = { 5, 6, 7, 8 };
final byte[] message2 = { 9, 0, 1, 2 };
_subject._queue.add(id1);
_subject._queue.add(id2);
_subject._inProgress.put(id1, message1);
_subject._inProgress.put(id2, message2);
_subject.nextTuple();
final ArgumentCaptor<List> captor = forClass(List.class);
// subject should have emitted only the first message
verify(_subject._collector).emit(captor.capture(), eq(id1));
assertArrayEquals(message1, (byte[]) captor.getValue().get(0));
verifyNoMoreInteractions(_subject._collector);
}
use of nl.minvenj.nfi.storm.kafka.util.KafkaMessageId in project kafka-spout by HolmesNL.
the class KafkaSpoutBufferBehaviourTest method testEmitOnAvailable.
@Test
public void testEmitOnAvailable() {
final KafkaMessageId id = new KafkaMessageId(1, 1234);
final byte[] message = { 5, 6, 7, 8 };
_subject._queue.add(id);
_subject._inProgress.put(id, message);
// request to emit message and id
_subject.nextTuple();
final ArgumentCaptor<ByteBuffer> bufferCaptor = forClass(ByteBuffer.class);
final ArgumentCaptor<List> valuesCaptor = forClass(List.class);
// subject should have emitted a Values object identified by id
verify(_subject._serializationScheme).deserialize(bufferCaptor.capture());
assertArrayEquals(message, bufferCaptor.getValue().array());
verify(_subject._collector).emit(valuesCaptor.capture(), eq(id));
assertArrayEquals(message, (byte[]) valuesCaptor.getValue().get(0));
}
Aggregations