Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReleaseLabelLockWhileAwaitingIndexPopulation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReleaseLabelLockWhileAwaitingIndexPopulation()
        {
            // given
            StubKernel      kernel          = new StubKernel(this);
            IndexingService indexingService = mock(typeof(IndexingService));

            NodePropertyAccessor nodePropertyAccessor = mock(typeof(NodePropertyAccessor));

            when(_schemaRead.indexGetCommittedId(_indexReference)).thenReturn(INDEX_ID);
            IndexProxy indexProxy = mock(typeof(IndexProxy));

            when(indexingService.getIndexProxy(anyLong())).thenReturn(indexProxy);
            when(indexingService.getIndexProxy(_descriptor)).thenReturn(indexProxy);

            when(_schemaRead.index(LABEL_ID, PROPERTY_KEY_ID)).thenReturn(IndexReference.NO_INDEX);

            ConstraintIndexCreator creator = new ConstraintIndexCreator(() => kernel, indexingService, nodePropertyAccessor, _logProvider);

            // when
            KernelTransactionImplementation transaction = CreateTransaction();

            creator.CreateUniquenessConstraintIndex(transaction, _descriptor, DefaultProvider);

            // then
            verify(transaction.StatementLocks().pessimistic()).releaseExclusive(ResourceTypes.LABEL, _descriptor.LabelId);

            verify(transaction.StatementLocks().pessimistic()).acquireExclusive(transaction.LockTracer(), ResourceTypes.LABEL, _descriptor.LabelId);
        }