use of com.hazelcast.jet.core.test.TestOutbox in project hazelcast-jet by hazelcast.
the class StreamEventJournalPTest method when_lostItems.
@Test
public void when_lostItems() {
TestOutbox outbox = new TestOutbox(new int[] { 16 }, 16);
Processor p = supplier.get();
p.init(outbox, new TestProcessorContext());
// overflow the journal
fillJournal(CAPACITY_PER_PARTITION + 1);
// fill and consume
List<Object> actual = new ArrayList<>();
assertTrueEventually(() -> {
assertFalse("Processor should never complete", p.complete());
outbox.drainQueueAndReset(0, actual, true);
assertTrue("consumed different number of items than expected", actual.size() == JOURNAL_CAPACITY);
}, 3);
}
use of com.hazelcast.jet.core.test.TestOutbox in project hazelcast-jet by hazelcast.
the class StreamEventJournalPTest method assertRestore.
private void assertRestore(List<Entry> snapshotItems) {
Processor p = supplier.get();
TestOutbox newOutbox = new TestOutbox(new int[] { 16 }, 16);
List<Object> output = new ArrayList<>();
p.init(newOutbox, new TestProcessorContext());
TestInbox inbox = new TestInbox();
inbox.addAll(snapshotItems);
p.restoreFromSnapshot(inbox);
p.finishSnapshotRestore();
assertTrueEventually(() -> {
assertFalse("Processor should never complete", p.complete());
newOutbox.drainQueueAndReset(0, output, true);
assertEquals("consumed different number of items than expected", JOURNAL_CAPACITY, output.size());
}, 3);
}
use of com.hazelcast.jet.core.test.TestOutbox in project hazelcast-jet by hazelcast.
the class StreamEventJournalPTest method when_newData.
@Test
public void when_newData() {
TestOutbox outbox = new TestOutbox(new int[] { 16 }, 16);
List<Object> actual = new ArrayList<>();
Processor p = supplier.get();
p.init(outbox, new TestProcessorContext());
fillJournal(CAPACITY_PER_PARTITION);
// consume
assertTrueEventually(() -> {
assertFalse("Processor should never complete", p.complete());
outbox.drainQueueAndReset(0, actual, true);
assertEquals("consumed different number of items than expected", JOURNAL_CAPACITY, actual.size());
assertEquals(IntStream.range(0, JOURNAL_CAPACITY).boxed().collect(Collectors.toSet()), new HashSet<>(actual));
}, 3);
fillJournal(CAPACITY_PER_PARTITION);
// consume again
assertTrueEventually(() -> {
assertFalse("Processor should never complete", p.complete());
outbox.drainQueueAndReset(0, actual, true);
assertEquals("consumed different number of items than expected", JOURNAL_CAPACITY + 2, actual.size());
assertEquals(IntStream.range(0, JOURNAL_CAPACITY).boxed().collect(Collectors.toSet()), new HashSet<>(actual));
}, 3);
}
use of com.hazelcast.jet.core.test.TestOutbox in project hazelcast-jet by hazelcast.
the class StreamFilesPTest method initializeProcessor.
private void initializeProcessor(String glob) {
if (glob == null) {
glob = "*";
}
processor = new StreamFilesP(workDir.getAbsolutePath(), UTF_8, glob, 1, 0, Util::entry);
outbox = new TestOutbox(1);
Context ctx = new TestProcessorContext().setLogger(Logger.getLogger(StreamFilesP.class));
processor.init(outbox, ctx);
}
use of com.hazelcast.jet.core.test.TestOutbox in project hazelcast-jet by hazelcast.
the class AbstractProcessorTest method before.
@Before
public void before() {
inbox = new TestInbox();
inbox.add(MOCK_ITEM);
int[] capacities = new int[OUTBOX_BUCKET_COUNT];
Arrays.fill(capacities, 1);
outbox = new TestOutbox(capacities);
final Processor.Context ctx = mock(Processor.Context.class);
Mockito.when(ctx.logger()).thenReturn(mock(ILogger.class));
p = new RegisteringMethodCallsP();
p.init(outbox, ctx);
tryProcessP = new SpecializedByOrdinalP();
tryProcessP.init(outbox, ctx);
nothingOverriddenP = new NothingOverriddenP();
nothingOverriddenP.init(outbox, ctx);
}
Aggregations