//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNoticeCancelRequest() throws java.io.IOException, java.util.concurrent.ExecutionException, InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNoticeCancelRequest() { // given Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control(); TrackingMonitor monitor = new TrackingMonitorAnonymousInnerClass(this, barrier); int blocks = 10; int mergeFactor = 2; MutableLongSet uniqueKeys = new LongHashSet(); AtomicBoolean cancelled = new AtomicBoolean(); using (BlockStorage <MutableLong, MutableLong> storage = new BlockStorage <MutableLong, MutableLong>(_layout, heapBufferFactory(100), _fileSystem, _file, monitor), OtherThreadExecutor <Void> t2 = new OtherThreadExecutor <Void>("T2", null)) { while (monitor.BlockFlushedCallCount < blocks) { storage.Add(UniqueKey(uniqueKeys), new MutableLong()); } storage.DoneAdding(); // when starting to merge Future <object> merge = t2.ExecuteDontWait(command(() => storage.merge(mergeFactor, cancelled.get))); barrier.AwaitUninterruptibly(); // one merge iteration have now been done, set the cancellation flag cancelled.set(true); barrier.Release(); merge.get(); } // then there should not be any more merge iterations done, i.e. merge was cancelled assertEquals(1, monitor.MergeIterationCallCount); }