示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailToCreateConstraintIfConcurrentlyCreatedEntityLacksTheMandatoryProperty() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldFailToCreateConstraintIfConcurrentlyCreatedEntityLacksTheMandatoryProperty()
            {
                // when
                try
                {
                    Future <Void> nodeCreation;
                    using (Transaction tx = Db.beginTx())
                    {
                        CreateConstraint(Db, KEY, PROPERTY);

                        nodeCreation = Thread.executeAndAwait(CreateOffender(), null, waitingWhileIn(Owner, OffenderCreationMethodName()), WAIT_TIMEOUT_SECONDS, SECONDS);

                        tx.Success();
                    }
                    nodeCreation.get();
                    fail("expected exception");
                }
                // then, we either fail to create the constraint,
                catch (ConstraintViolationException e)
                {
                    assertThat(e.InnerException, instanceOf(typeof(CreateConstraintFailureException)));
                }
                // or we fail to create the offending node
                catch (ExecutionException e)
                {
                    assertThat(e.InnerException, instanceOf(typeof(ConstraintViolationException)));
                    assertThat(e.InnerException.InnerException, instanceOf(typeof(ConstraintViolationTransactionFailureException)));
                }
            }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private <T extends org.neo4j.graphdb.PropertyContainer> Resource<T> test(System.Func<T> setup, String... queries) throws InterruptedException, java.util.concurrent.ExecutionException
        private Resource <T> Test <T>(System.Func <T> setup, params string[] queries) where T : Org.Neo4j.Graphdb.PropertyContainer
        {
            System.Threading.CountdownEvent resourceLocked     = new System.Threading.CountdownEvent(1);
            System.Threading.CountdownEvent listQueriesLatch   = new System.Threading.CountdownEvent(1);
            System.Threading.CountdownEvent finishQueriesLatch = new System.Threading.CountdownEvent(1);
            T resource;

            using (Transaction tx = _db.beginTx())
            {
                resource = setup();
                tx.Success();
            }
            _threads.execute(parameter =>
            {
                using (Transaction tx = _db.beginTx())
                {
                    tx.AcquireWriteLock(resource);
                    resourceLocked.Signal();
                    listQueriesLatch.await();
                }
                return(null);
            }, null);
            resourceLocked.await();

            _threads.executeAndAwait(parameter =>
            {
                try
                {
                    using (Transaction tx = _db.beginTx())
                    {
                        foreach (string query in queries)
                        {
                            _db.execute(query).close();
                        }
                        tx.Success();
                    }
                }
                catch (Exception t)
                {
                    Console.WriteLine(t.ToString());
                    Console.Write(t.StackTrace);
                    throw new Exception(t);
                }
                finally
                {
                    finishQueriesLatch.Signal();
                }
                return(null);
            }, null, waitingWhileIn(typeof(GraphDatabaseFacade), "execute"), SECONDS_TIMEOUT, SECONDS);

            return(new Resource <T>(listQueriesLatch, finishQueriesLatch, resource));
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Resources.Life(STARTED) public void postStateUpdatesCountedOnlyForTransactionsGreaterThanRotationVersion() throws java.io.IOException, InterruptedException, java.util.concurrent.ExecutionException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PostStateUpdatesCountedOnlyForTransactionsGreaterThanRotationVersion()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Store store = resourceManager.managed(createTestStore());
            Store store = _resourceManager.managed(CreateTestStore());

            PreparedRotation rotation = store.PrepareRotation(2);

            UpdateStore(store, 4);
            UpdateStore(store, 3);
            UpdateStore(store, 1);
            UpdateStore(store, 2);

            assertEquals(2, rotation.Rotate());

            Future <long> rotationFuture = _threading.executeAndAwait(store.Rotation, 5L, thread => Thread.State.TIMED_WAITING == thread.State, 100, SECONDS);

            Thread.Sleep(TimeUnit.SECONDS.toMillis(1));

            assertFalse(rotationFuture.Done);
            UpdateStore(store, 5);

            assertEquals(5, rotationFuture.get().longValue());
        }