Source:
<code>public void testParallelProcessing() throws Exception { Tuple2<List<T>, Integer> testData = getTestData(); final AbstractArrowSourceFunction<T> arrowSourceFunction = createTestArrowSourceFunction(testData.f0, testData.f1); final AbstractStreamOperatorTestHarness<T> testHarness = new AbstractStreamOperatorTestHarness<>(new StreamSource<>(arrowSourceFunction), 2, 2, 0); testHarness.open(); <START> final Throwable[] error = new Throwable[2]; <END> final OneShotLatch latch = new OneShotLatch(); final AtomicInteger numOfEmittedElements = new AtomicInteger(0); Thread runner = new Thread(() -> { try { arrowSourceFunction.run(new DummySourceContext<T>() { @Override public void collect(T element) { if (numOfEmittedElements.incrementAndGet() == testData.f0.size()) { latch.trigger(); } } }); } catch (Throwable t) { error[0] = t; } }); runner.start(); final AbstractArrowSourceFunction<T> arrowSourceFunction2 = createTestArrowSourceFunction(testData.f0, testData.f1); final AbstractStreamOperatorTestHarness<T> testHarness2 = new AbstractStreamOperatorTestHarness<>(new StreamSource<>(arrowSourceFunction2), 2, 2, 1); testHarness2.open(); Thread runner2 = new Thread(() -> { try { arrowSourceFunction2.run(new DummySourceContext<T>() { @Override public void collect(T element) { if (numOfEmittedElements.incrementAndGet() == testData.f0.size()) { latch.trigger(); } } }); } catch (Throwable t) { error[1] = t; } }); runner2.start(); if (!latch.isTriggered()) { latch.await(); } runner.join(); runner2.join(); testHarness.close(); testHarness2.close(); Assert.assertNull(error[0]); Assert.assertNull(error[1]); Assert.assertEquals(testData.f0.size(), numOfEmittedElements.get()); }</code><technical_language>verify content of data</technical_language>

Target:
public void testParallelProcessing() throws Exception { Tuple2<List<T>, Integer> testData = getTestData(); final AbstractArrowSourceFunction<T> arrowSourceFunction = createTestArrowSourceFunction(testData.f0, testData.f1); final AbstractStreamOperatorTestHarness<T> testHarness = new AbstractStreamOperatorTestHarness<>(new StreamSource<>(arrowSourceFunction), 2, 2, 0); testHarness.open(); final Throwable[] error = new Throwable[2]; final OneShotLatch latch = new OneShotLatch(); final AtomicInteger numOfEmittedElements = new AtomicInteger(0); final List<T> results = new ArrayList<>(); Thread runner = new Thread(() -> { try { arrowSourceFunction.run(new DummySourceContext<T>() { @Override public void collect(T element) { results.add(typeSerializer.copy(element)); if (numOfEmittedElements.incrementAndGet() == testData.f0.size()) { latch.trigger(); } } }); } catch (Throwable t) { error[0] = t; } }); runner.start(); final AbstractArrowSourceFunction<T> arrowSourceFunction2 = createTestArrowSourceFunction(testData.f0, testData.f1); final AbstractStreamOperatorTestHarness<T> testHarness2 = new AbstractStreamOperatorTestHarness<>(new StreamSource<>(arrowSourceFunction2), 2, 2, 1); testHarness2.open(); Thread runner2 = new Thread(() -> { try { arrowSourceFunction2.run(new DummySourceContext<T>() { @Override public void collect(T element) { results.add(typeSerializer.copy(element)); if (numOfEmittedElements.incrementAndGet() == testData.f0.size()) { latch.trigger(); } } }); } catch (Throwable t) { error[1] = t; } }); runner2.start(); if (!latch.isTriggered()) { latch.await(); } runner.join(); runner2.join(); testHarness.close(); testHarness2.close(); Assert.assertNull(error[0]); Assert.assertNull(error[1]); Assert.assertEquals(testData.f0.size(), numOfEmittedElements.get()); checkElementsEquals(results, testData.f0); }