Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRejectDuplicateEntryAfterUsingPopulatingUpdater() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRejectDuplicateEntryAfterUsingPopulatingUpdater()
        {
            // given
            _populator = NewPopulator();

            string       valueString = "value1";
            IndexUpdater updater     = _populator.newPopulatingUpdater(_nodePropertyAccessor);

            updater.Process(add(1, _schemaDescriptor, valueString));
            AddUpdate(_populator, 2, valueString);

            Value value = Values.of(valueString);

            when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(value);
            when(_nodePropertyAccessor.getNodePropertyValue(2, PROPERTY_KEY_ID)).thenReturn(value);

            // when
            try
            {
                _populator.verifyDeferredConstraints(_nodePropertyAccessor);

                fail("should have thrown exception");
            }
            // then
            catch (IndexEntryConflictException conflict)
            {
                assertEquals(1, conflict.ExistingNodeId);
                assertEquals(value, conflict.SinglePropertyValue);
                assertEquals(2, conflict.AddedNodeId);
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCheckAllCollisionsFromPopulatorAdd() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCheckAllCollisionsFromPopulatorAdd()
        {
            // given
            _populator = NewPopulator();

            int          iterations = 228;      // This value has to be high enough to stress the EntrySet implementation
            IndexUpdater updater    = _populator.newPopulatingUpdater(_nodePropertyAccessor);

            for (int nodeId = 0; nodeId < iterations; nodeId++)
            {
                updater.Process(add(nodeId, _schemaDescriptor, 1));
                when(_nodePropertyAccessor.getNodePropertyValue(nodeId, PROPERTY_KEY_ID)).thenReturn(Values.of(nodeId));
            }

            // ... and the actual conflicting property:
            updater.Process(add(iterations, _schemaDescriptor, 1));
            when(_nodePropertyAccessor.getNodePropertyValue(iterations, PROPERTY_KEY_ID)).thenReturn(Values.of(1));                       // This collision is real!!!

            // when
            try
            {
                updater.Close();
                fail("should have thrown exception");
            }
            // then
            catch (IndexEntryConflictException conflict)
            {
                assertEquals(1, conflict.ExistingNodeId);
                assertEquals(Values.of(1), conflict.SinglePropertyValue);
                assertEquals(iterations, conflict.AddedNodeId);
            }
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRejectDuplicateEntryWhenUsingPopulatingUpdater() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRejectDuplicateEntryWhenUsingPopulatingUpdater()
        {
            // given
            _populator = NewPopulator();

            AddUpdate(_populator, 1, "value1");
            AddUpdate(_populator, 2, "value2");

            Value value = Values.of("value1");

            when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(value);
            when(_nodePropertyAccessor.getNodePropertyValue(3, PROPERTY_KEY_ID)).thenReturn(value);

            // when
            try
            {
                IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor);
                updater.Process(add(3, _schemaDescriptor, "value1"));
                updater.Close();

                fail("should have thrown exception");
            }
            // then
            catch (IndexEntryConflictException conflict)
            {
                assertEquals(1, conflict.ExistingNodeId);
                assertEquals(value, conflict.SinglePropertyValue);
                assertEquals(3, conflict.AddedNodeId);
            }
        }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReleaseSearcherProperlyAfterVerifyingDeferredConstraints() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReleaseSearcherProperlyAfterVerifyingDeferredConstraints()
        {
            // given
            _populator = NewPopulator();

            /*
             * This test was created due to a problem in closing an index updater after deferred constraints
             * had been verified, where it got stuck in a busy loop in ReferenceManager#acquire.
             */

            // GIVEN an index updater that we close
            OtherThreadExecutor <Void> executor = _cleanup.add(new OtherThreadExecutor <Void>("Deferred", null));

            executor.Execute((OtherThreadExecutor.WorkerCommand <Void, Void>)state =>
            {
                using (IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor))
                {                 // Just open it and let it be closed
                }
                return(null);
            });
            // ... and where we verify deferred constraints after
            executor.Execute((OtherThreadExecutor.WorkerCommand <Void, Void>)state =>
            {
                _populator.verifyDeferredConstraints(_nodePropertyAccessor);
                return(null);
            });

            // WHEN doing more index updating after that
            // THEN it should be able to complete within a very reasonable time
            executor.Execute((OtherThreadExecutor.WorkerCommand <Void, Void>)state =>
            {
                using (IndexUpdater secondUpdater = _populator.newPopulatingUpdater(_nodePropertyAccessor))
                {                 // Just open it and let it be closed
                }
                return(null);
            }, 5, SECONDS);
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveEntryForNodeThatHasAlreadyBeenIndexed() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRemoveEntryForNodeThatHasAlreadyBeenIndexed()
        {
            // given
            _populator = NewPopulator();

            AddUpdate(_populator, 1, "value1");

            // when
            IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor);

            updater.Process(remove(1, _schemaDescriptor, "value1"));

            _populator.close(true);

            // then
            assertEquals(Collections.EMPTY_LIST, GetAllNodes(Directory, "value1"));
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUpdateEntryForNodeThatHasPropertyRemovedAndThenAddedAgain() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUpdateEntryForNodeThatHasPropertyRemovedAndThenAddedAgain()
        {
            // given
            _populator = NewPopulator();

            AddUpdate(_populator, 1, "value1");

            // when
            IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor);

            updater.Process(remove(1, _schemaDescriptor, "value1"));
            updater.Process(add(1, _schemaDescriptor, "value1"));

            _populator.close(true);

            // then
            assertEquals(asList(1L), GetAllNodes(Directory, "value1"));
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToHandleSwappingOfIndexValues() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToHandleSwappingOfIndexValues()
        {
            // given
            _populator = NewPopulator();

            AddUpdate(_populator, 1, "value1");
            AddUpdate(_populator, 2, "value2");

            // when
            IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor);

            updater.Process(change(1, _schemaDescriptor, "value1", "value2"));
            updater.Process(change(2, _schemaDescriptor, "value2", "value1"));

            _populator.close(true);

            // then
            assertEquals(asList(2L), GetAllNodes(Directory, "value1"));
            assertEquals(asList(1L), GetAllNodes(Directory, "value2"));
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotRejectDuplicateEntryOnSameNodeIdAfterUsingPopulatingUpdater() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotRejectDuplicateEntryOnSameNodeIdAfterUsingPopulatingUpdater()
        {
            // given
            _populator = NewPopulator();

            when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(Values.of("value1"));

            IndexUpdater updater = _populator.newPopulatingUpdater(_nodePropertyAccessor);

            updater.Process(add(1, _schemaDescriptor, "value1"));
            updater.Process(change(1, _schemaDescriptor, "value1", "value1"));
            updater.Close();
            AddUpdate(_populator, 2, "value2");
            AddUpdate(_populator, 3, "value3");

            // when
            _populator.verifyDeferredConstraints(_nodePropertyAccessor);
            _populator.close(true);

            // then
            assertEquals(asList(1L), GetAllNodes(Directory, "value1"));
            assertEquals(asList(2L), GetAllNodes(Directory, "value2"));
            assertEquals(asList(3L), GetAllNodes(Directory, "value3"));
        }