Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
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);
            }
        }
Пример #4
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);
            }
        }
Пример #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private UniqueLuceneIndexPopulator newPopulator() throws java.io.IOException
        private UniqueLuceneIndexPopulator NewPopulator()
        {
            UniqueLuceneIndexPopulator populator = new UniqueLuceneIndexPopulator(_index, _descriptor);

            populator.Create();
            return(populator);
        }
Пример #6
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);
            }
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void sampleEmptyIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SampleEmptyIndex()
        {
            _populator = NewPopulator();

            IndexSample sample = _populator.sampleResult();

            assertEquals(new IndexSample(), sample);
        }
Пример #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void addUpdate(UniqueLuceneIndexPopulator populator, long nodeId, Object value) throws java.io.IOException
        private static void AddUpdate(UniqueLuceneIndexPopulator populator, long nodeId, object value)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update = add(nodeId, descriptor.schema(), value);
            IndexEntryUpdate <object> update = add(nodeId, _descriptor.schema(), value);

            populator.Add(asList(update));
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void sampleIncludedUpdates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SampleIncludedUpdates()
        {
            LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel(1, 1);

            _populator = NewPopulator();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = java.util.Arrays.asList(add(1, schemaDescriptor, "foo"), add(2, schemaDescriptor, "bar"), add(3, schemaDescriptor, "baz"), add(4, schemaDescriptor, "qux"));
            IList <IndexEntryUpdate <object> > updates = Arrays.asList(add(1, schemaDescriptor, "foo"), add(2, schemaDescriptor, "bar"), add(3, schemaDescriptor, "baz"), add(4, schemaDescriptor, "qux"));

            updates.ForEach(_populator.includeSample);

            IndexSample sample = _populator.sampleResult();

            assertEquals(new IndexSample(4, 4, 4), sample);
        }
Пример #10
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"));
        }
Пример #11
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);
        }
Пример #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addUpdates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AddUpdates()
        {
            _populator = NewPopulator();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = java.util.Arrays.asList(add(1, schemaDescriptor, "aaa"), add(2, schemaDescriptor, "bbb"), add(3, schemaDescriptor, "ccc"));
            IList <IndexEntryUpdate <object> > updates = Arrays.asList(add(1, _schemaDescriptor, "aaa"), add(2, _schemaDescriptor, "bbb"), add(3, _schemaDescriptor, "ccc"));

            _populator.add(updates);

            _index.maybeRefreshBlocking();
            using (IndexReader reader = _index.IndexReader)
            {
                LongIterator allEntities = reader.Query(IndexQuery.exists(1));
                assertArrayEquals(new long[] { 1, 2, 3 }, PrimitiveLongCollections.asArray(allEntities));
            }
        }
Пример #13
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"));
        }
Пример #14
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"));
        }
Пример #15
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"));
        }
Пример #16
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);
        }
Пример #17
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"));
        }