Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void takeLabelLockForQueryWithIndexUsages() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TakeLabelLockForQueryWithIndexUsages()
        {
            string labelName   = "Human";
            Label  human       = Label.label(labelName);
            string propertyKey = "name";

            CreateIndex(human, propertyKey);

            using (Transaction transaction = DatabaseRule.beginTx())
            {
                Node node = DatabaseRule.createNode(human);
                node.SetProperty(propertyKey, RandomStringUtils.randomAscii(10));
                transaction.Success();
            }

            string query = "MATCH (n:" + labelName + ") where n." + propertyKey + " = \"Fry\" RETURN n ";

            IList <LockOperationRecord> lockOperationRecords = TraceQueryLocks(query);

            assertThat("Observed list of lock operations is: " + lockOperationRecords, lockOperationRecords, hasSize(1));

            LockOperationRecord operationRecord = lockOperationRecords[0];

            assertTrue(operationRecord.Acquisition);
            assertFalse(operationRecord.Exclusive);
            assertEquals(ResourceTypes.LABEL, operationRecord.ResourceType);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reTakeLabelLockForQueryWithIndexUsagesWhenSchemaStateWasUpdatedDuringLockOperations() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReTakeLabelLockForQueryWithIndexUsagesWhenSchemaStateWasUpdatedDuringLockOperations()
        {
            string labelName   = "Robot";
            Label  robot       = Label.label(labelName);
            string propertyKey = "name";

            CreateIndex(robot, propertyKey);

            using (Transaction transaction = DatabaseRule.beginTx())
            {
                Node node = DatabaseRule.createNode(robot);
                node.SetProperty(propertyKey, RandomStringUtils.randomAscii(10));
                transaction.Success();
            }

            string query = "MATCH (n:" + labelName + ") where n." + propertyKey + " = \"Bender\" RETURN n ";

            LockOperationListener       lockOperationListener = new OnceSchemaFlushListener(this);
            IList <LockOperationRecord> lockOperationRecords  = TraceQueryLocks(query, lockOperationListener);

            assertThat("Observed list of lock operations is: " + lockOperationRecords, lockOperationRecords, hasSize(3));

            LockOperationRecord operationRecord = lockOperationRecords[0];

            assertTrue(operationRecord.Acquisition);
            assertFalse(operationRecord.Exclusive);
            assertEquals(ResourceTypes.LABEL, operationRecord.ResourceType);

            LockOperationRecord operationRecord1 = lockOperationRecords[1];

            assertFalse(operationRecord1.Acquisition);
            assertFalse(operationRecord1.Exclusive);
            assertEquals(ResourceTypes.LABEL, operationRecord1.ResourceType);

            LockOperationRecord operationRecord2 = lockOperationRecords[2];

            assertTrue(operationRecord2.Acquisition);
            assertFalse(operationRecord2.Exclusive);
            assertEquals(ResourceTypes.LABEL, operationRecord2.ResourceType);
        }