Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void requirePropertyFromMultipleNodeKeys()
            public virtual void RequirePropertyFromMultipleNodeKeys()
            {
                Label label = Label.label("multiNodeKeyLabel");

                SchemaHelper.createNodeKeyConstraint(Db, label, "property1", "property2");
                SchemaHelper.createNodeKeyConstraint(Db, label, "property2", "property3");
                SchemaHelper.createNodeKeyConstraint(Db, label, "property3", "property4");

                assertException(() =>
                {
                    using (Org.Neo4j.Graphdb.Transaction transaction = Db.beginTx())
                    {
                        Node node = Db.createNode(label);
                        node.setProperty("property1", "1");
                        node.setProperty("property2", "2");
                        transaction.Success();
                    }
                }, typeof(ConstraintViolationException), "Node(0) with label `multiNodeKeyLabel` must have the properties `property2, property3`");

                assertException(() =>
                {
                    using (Org.Neo4j.Graphdb.Transaction transaction = Db.beginTx())
                    {
                        Node node = Db.createNode(label);
                        node.setProperty("property1", "1");
                        node.setProperty("property2", "2");
                        node.setProperty("property3", "3");
                        transaction.Success();
                    }
                }, typeof(ConstraintViolationException), "Node(1) with label `multiNodeKeyLabel` must have the properties `property3, property4`");
            }
Exemple #2
0
        private void TestDateTypeWithPrecedingInLinedLong(Value value)
        {
            _node1.setProperty("l1", 255);                 // Setting these low bits was triggering a bug in some date types decision on formatting
            string key = "dt";

            _node1.setProperty(key, value);
            NewTransaction();

            object property = _node1.getProperty(key);

            assertEquals(value.AsObjectCopy(), property);
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("boxing") @Override public Void beforeCommit(org.neo4j.graphdb.event.TransactionData data)
            public override Void BeforeCommit(TransactionData data)
            {
                if (Iterables.count(data.CreatedRelationships()) == 0)
                {
                    return(null);
                }

                Node.setProperty("counter", (( long? )Node.removeProperty("counter")) + 1);
                return(null);
            }
Exemple #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void createSomeData(int items, org.neo4j.causalclustering.discovery.Cluster<?> cluster) throws Exception
        public static void CreateSomeData <T1>(int items, Cluster <T1> cluster)
        {
            for (int i = 0; i < items; i++)
            {
                cluster.CoreTx((db, tx) =>
                {
                    Node node = Db.createNode(_label);
                    node.setProperty("foobar", "baz_bat");
                    tx.success();
                });
            }
        }
Exemple #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static org.neo4j.causalclustering.discovery.CoreClusterMember createLabelledNodesWithProperty(org.neo4j.causalclustering.discovery.Cluster<?> cluster, int numberOfNodes, org.neo4j.graphdb.Label label, System.Func<org.neo4j.helpers.collection.Pair<String,Object>> propertyPair) throws Exception
        public static CoreClusterMember CreateLabelledNodesWithProperty <T1>(Cluster <T1> cluster, int numberOfNodes, Label label, System.Func <Pair <string, object> > propertyPair)
        {
            CoreClusterMember last = null;

            for (int i = 0; i < numberOfNodes; i++)
            {
                last = cluster.CoreTx((db, tx) =>
                {
                    Node node = Db.createNode(label);
                    node.setProperty(propertyPair().first(), propertyPair().other());
                    tx.success();
                });
            }
            return(last);
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord()
        {
            Race race = new Race();

            long[]     latestNodeId = new long[1];
            AtomicLong writes       = new AtomicLong();
            AtomicLong reads        = new AtomicLong();
            long       endTime      = currentTimeMillis() + SECONDS.toMillis(2);

            race.WithEndCondition(() => (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime);
            race.AddContestant(() =>
            {
                using (Transaction tx = Db.beginTx())
                {
                    Node node       = Db.createNode();
                    latestNodeId[0] = node.Id;
                    node.setProperty("largeProperty", LONG_STRING_VALUE);
                    tx.success();
                }
                writes.incrementAndGet();
            });
            race.AddContestant(() =>
            {
                try
                {
                    using (Transaction tx = Db.GraphDatabaseAPI.beginTx())
                    {
                        Node node = Db.GraphDatabaseAPI.getNodeById(latestNodeId[0]);

                        foreach (string propertyKey in node.PropertyKeys)
                        {
                            node.getProperty(propertyKey);
                        }
                        tx.success();
                    }
                }
                catch (NotFoundException e)
                {
                    if (Exceptions.contains(e, typeof(InvalidRecordException)))
                    {
                        throw e;
                    }
                }
                reads.incrementAndGet();
            });
            race.Go();
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void clusterShouldNotElectNewLeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ClusterShouldNotElectNewLeader()
        {
            // given
            int leaderId = 0;

            ClusterRule.withInstanceCoreParam(CausalClusteringSettings.refuse_to_be_leader, x =>
            {
                if (x == leaderId)
                {
                    return("false");
                }
                else
                {
                    return("true");
                }
            });

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.createCluster();
            Cluster <object> cluster = ClusterRule.createCluster();

            cluster.Start();
            assertEquals(leaderId, cluster.AwaitLeader().serverId());

            cluster.CoreTx((db, tx) =>
            {
                Node node = Db.createNode(label("boo"));
                node.setProperty("foobar", "baz_bat");
                tx.success();
            });

            // When
            cluster.RemoveCoreMemberWithServerId(leaderId);

            // Then
            try
            {
                cluster.AwaitLeader(10, SECONDS);

                fail("Should not have elected a leader");
            }
            catch (TimeoutException)
            {
                // Successful
            }
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord()
        {
            Race race = new Race();

            long[]     latestNodeId = new long[1];
            AtomicLong writes       = new AtomicLong();
            AtomicLong reads        = new AtomicLong();
            long       endTime      = currentTimeMillis() + SECONDS.toMillis(2);

            race.WithEndCondition(() => (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime);
            race.AddContestant(() =>
            {
                using (Transaction tx = Db.beginTx())
                {
                    Node node       = Db.createNode();
                    latestNodeId[0] = node.Id;
                    node.setProperty("largeProperty", LONG_STRING_VALUE);
                    tx.success();
                }
                writes.incrementAndGet();
            });
            race.AddContestant(() =>
            {
                try
                {
                    using (Transaction tx = Db.GraphDatabaseAPI.beginTx())
                    {
                        Node node = Db.GraphDatabaseAPI.getNodeById(latestNodeId[0]);
                        foreach (string propertyKey in node.PropertyKeys)
                        {
                            node.getProperty(propertyKey);
                        }
                        tx.success();
                    }
                }
                catch (NotFoundException)
                {
                    // This will catch nodes not found (expected) and also PropertyRecords not found (shouldn't happen
                    // but handled in shouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord)
                }
                reads.incrementAndGet();
            });
            race.Go();
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void validateIndexedNodePropertiesInLucene()
        internal virtual void ValidateIndexedNodePropertiesInLucene()
        {
            setUp(default_schema_provider.name(), GraphDatabaseSettings.SchemaIndex.NATIVE10.providerName());
            Label  label        = Label.label("indexedNodePropertiesTestLabel");
            string propertyName = "indexedNodePropertyName";

            CreateIndex(label, propertyName);

            using (Transaction ignored = _database.beginTx())
            {
                _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
            }

            System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () =>
            {
                using (Transaction transaction = _database.beginTx())
                {
                    Node node = _database.createNode(label);
                    node.setProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1));
                    transaction.success();
                }
            });
            assertThat(argumentException.Message, equalTo("Property value size is too large for index. Please see index documentation for limitations."));
        }
Exemple #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void validateIndexedNodePropertiesInNativeBtree()
        internal virtual void ValidateIndexedNodePropertiesInNativeBtree()
        {
            setUp();
            Label  label        = Label.label("indexedNodePropertiesTestLabel");
            string propertyName = "indexedNodePropertyName";

            CreateIndex(label, propertyName);

            using (Transaction ignored = _database.beginTx())
            {
                _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
            }

            System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () =>
            {
                using (Transaction transaction = _database.beginTx())
                {
                    Node node = _database.createNode(label);
                    node.setProperty(propertyName, StringUtils.repeat("a", keyValueSizeCapFromPageSize(PAGE_SIZE) + 1));
                    transaction.success();
                }
            });
            assertThat(argumentException.Message, containsString("is too large to index into this particular index. Please see index documentation for limitations."));
        }