use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.
the class ProcessorTaskletTest_Blocking method setUp.
@Before
public void setUp() {
this.processor = new PassThroughProcessor();
this.context = new TestProcessorContext();
this.mockInput = IntStream.range(0, MOCK_INPUT_SIZE).boxed().collect(toList());
this.instreams = new ArrayList<>();
this.outstreams = new ArrayList<>();
}
use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.
the class ProcessorTaskletTest_Watermarks method setUp.
@Before
public void setUp() {
this.processor = new ProcessorWithWatermarks();
this.context = new TestProcessorContext();
this.instreams = new ArrayList<>();
this.outstreams = new ArrayList<>();
this.snapshotCollector = new MockOutboundCollector(0);
}
use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.
the class AbstractProcessorTest method before.
@Before
public void before() throws Exception {
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 = new TestProcessorContext();
p = new RegisteringMethodCallsP();
p.init(outbox, ctx);
tryProcessP = new SpecializedByOrdinalP();
tryProcessP.init(outbox, ctx);
nothingOverriddenP = new NothingOverriddenP();
nothingOverriddenP.init(outbox, ctx);
}
use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.
the class StreamEventJournalP_WmCoalescingTest method when_allPartitionsIdleAndThenRecover_then_wmOutput.
@Test
public void when_allPartitionsIdleAndThenRecover_then_wmOutput() throws Exception {
// Insert to map in parallel to verifyProcessor.
CountDownLatch latch = new CountDownLatch(1);
Thread updatingThread = new Thread(() -> uncheckRun(() -> {
// We will start after a delay so that the source will first become idle and then recover.
latch.await();
for (; ; ) {
map.put(partitionKeys[0], 12);
Thread.sleep(100);
}
}));
updatingThread.start();
Processor processor = createSupplier(asList(0, 1), 2000).get();
TestOutbox outbox = new TestOutbox(1024);
Queue<Object> outbox0 = outbox.queue(0);
processor.init(outbox, new TestProcessorContext().setHazelcastInstance(instance));
assertTrueEventually(() -> {
processor.complete();
// after we have the IDLE_MESSAGE, release the latch to let the other thread produce events
if (IDLE_MESSAGE.equals(outbox0.peek())) {
latch.countDown();
}
assertEquals(asList(IDLE_MESSAGE, wm(12), 12), outbox0.stream().distinct().collect(toList()));
});
updatingThread.interrupt();
updatingThread.join();
}
use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.
the class StreamJmsPTest method initializeProcessor.
private void initializeProcessor(String destinationName, boolean isQueue, FunctionEx<Message, String> projectionFn) throws Exception {
processorConnection = getConnectionFactory().createConnection();
processorConnection.start();
FunctionEx<Session, MessageConsumer> consumerFn = s -> s.createConsumer(isQueue ? s.createQueue(destinationName) : s.createTopic(destinationName));
if (projectionFn == null) {
projectionFn = m -> ((TextMessage) m).getText();
}
processor = new StreamJmsP<>(processorConnection, consumerFn, Message::getJMSMessageID, projectionFn, noEventTime(), NONE);
outbox = new TestOutbox(1);
processor.init(outbox, new TestProcessorContext());
}
Aggregations