@Test
public void shouldApplyBackPressure() throws Exception
{
int backPressureThreshold = 10;
BlockableMonitor monitor = new BlockableMonitor();
try ( OtherThreadExecutor<Void> t2 = new OtherThreadExecutor<>( "T2", null );
BadCollector badCollector = new BadCollector( NULL_OUTPUT_STREAM, UNLIMITED_TOLERANCE, COLLECT_ALL, backPressureThreshold, false, monitor ) )
{
for ( int i = 0; i < backPressureThreshold; i++ )
{
badCollector.collectDuplicateNode( i, i, "group" );
}
Future<Object> enqueue = t2.executeDontWait( command( () -> badCollector.collectDuplicateNode( 999, 999, "group" ) ) );
t2.waitUntilWaiting( waitDetails -> waitDetails.isAt( BadCollector.class, "collect" ) );
monitor.unblock();
enqueue.get();
}
}