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

            int iterations = 228;               // This value has to be high enough to stress the EntrySet implementation

            for (int nodeId = 0; nodeId < iterations; nodeId++)
            {
                AddUpdate(_populator, nodeId, 1);
                when(_nodePropertyAccessor.getNodePropertyValue(nodeId, PROPERTY_KEY_ID)).thenReturn(Values.of(nodeId));
            }

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

            // when
            try
            {
                _populator.verifyDeferredConstraints(_nodePropertyAccessor);
                fail("should have thrown exception");
            }
            // then
            catch (IndexEntryConflictException conflict)
            {
                assertEquals(1, conflict.ExistingNodeId);
                assertEquals(Values.of(1), conflict.SinglePropertyValue);
                assertEquals(iterations, conflict.AddedNodeId);
            }
        }
示例#2
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);
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailAtVerificationStageWithAlreadyIndexedNumberValue() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailAtVerificationStageWithAlreadyIndexedNumberValue()
        {
            // given
            _populator = NewPopulator();

            AddUpdate(_populator, 1, 1);
            AddUpdate(_populator, 2, 2);
            AddUpdate(_populator, 3, 1);

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

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

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

            // Given we have a collision in our index...
            AddUpdate(_populator, 1, 1000000000000000001L);
            AddUpdate(_populator, 2, 2);
            AddUpdate(_populator, 3, 1000000000000000001L);

            // ... but the actual data in the store does not collide
            when(_nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID)).thenReturn(Values.of(1000000000000000001L));
            when(_nodePropertyAccessor.getNodePropertyValue(3, PROPERTY_KEY_ID)).thenReturn(Values.of(1000000000000000002L));

            // Then our verification should NOT fail:
            _populator.verifyDeferredConstraints(_nodePropertyAccessor);
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldVerifyThatThereAreNoDuplicates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldVerifyThatThereAreNoDuplicates()
        {
            // given
            _populator = NewPopulator();

            AddUpdate(_populator, 1, "value1");
            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"));
        }
示例#6
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);
        }
示例#7
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"));
        }