//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotDeadlock() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotDeadlock()
        {
            IList <TransactionRepresentation> transactions = CreateConstraintCreatingTransactions();
            Monitors         monitors = new Monitors();
            GraphDatabaseAPI db       = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).setMonitors(monitors).newImpermanentDatabase();

            Org.Neo4j.Test.Barrier_Control controller = new Org.Neo4j.Test.Barrier_Control();
            bool success = false;

            try
            {
                IndexingService.Monitor monitor = new MonitorAdapterAnonymousInnerClass(this, controller);
                monitors.AddMonitorListener(monitor);
                Future <object> applier = ApplyInT2(db, transactions);

                controller.Await();

                // At this point the index population has completed and the population thread is ready to
                // acquire the counts store read lock for initializing some samples there. We're starting the
                // check pointer, which will eventually put itself in queue for acquiring the write lock

                Future <object> checkPointer = T3.execute(state => Db.DependencyResolver.resolveDependency(typeof(CheckPointer)).forceCheckPoint(new SimpleTriggerInfo("MANUAL")));
                try
                {
                    T3.get().waitUntilWaiting(details => details.isAt(typeof(LockWrapper), "writeLock"));
                }
                catch (System.InvalidOperationException)
                {
                    // Thrown when the fix is in, basically it's thrown if the check pointer didn't get blocked
                    checkPointer.get();                              // to assert that no exception was thrown during in check point thread
                }

                // Alright the trap is set. Let the population thread move on and seal the deal
                controller.Release();

                // THEN these should complete
                applier.get(10, SECONDS);
                checkPointer.get(10, SECONDS);
                success = true;

                using (Transaction tx = Db.beginTx())
                {
                    ConstraintDefinition constraint = single(Db.schema().getConstraints(LABEL));
                    assertEquals(KEY, single(constraint.PropertyKeys));
                    tx.Success();
                }

                CreateNode(db, "A");
                try
                {
                    CreateNode(db, "A");
                    fail("Should have failed");
                }
                catch (ConstraintViolationException)
                {
                    // THEN good
                }
            }
            finally
            {
                if (!success)
                {
                    T2.interrupt();
                    T3.interrupt();
                    // so that shutdown won't hang too
                }
                Db.shutdown();
            }
        }