@Test public void testEmitInSequence() { // test the happy path, emit batches in sequence Map meta = emitter.emitPartitionBatchNew(null, collectorMock, partition, null); String collected = collectorMock.getBuffer(); assertTrue(collected.startsWith("message" + 0)); // System.out.println("collected: " + collected); collectorMock.clear(); emitter.emitPartitionBatchNew(null, collectorMock, partition, meta); collected = collectorMock.getBuffer(); // System.out.println("collected: " + collected); assertTrue(collected.startsWith("message" + batchSize)); }
@Test public void testReEmit() { // test we can re-emit the second batch Map meta = emitter.emitPartitionBatchNew(null, collectorMock, partition, null); collectorMock.clear(); // emit second batch Map meta1 = emitter.emitPartitionBatchNew(null, collectorMock, partition, meta); String collected0 = collectorMock.getBuffer(); collectorMock.clear(); // re-emit second batch emitter.emitPartitionBatch(null, collectorMock, partition, meta1); String collected1 = collectorMock.getBuffer(); assertTrue(collected0.equals(collected1)); }