Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void givenClusterWithReadOnlySlaveWhenChangePropertyOnSlaveThenThrowException()
        public virtual void GivenClusterWithReadOnlySlaveWhenChangePropertyOnSlaveThenThrowException()
        {
            // Given
            ManagedCluster cluster = ClusterRule.startCluster();
            Node           node;
            HighlyAvailableGraphDatabase master = cluster.Master;

            using (Transaction tx = master.BeginTx())
            {
                node = master.CreateNode();
                tx.Success();
            }

            // When
            HighlyAvailableGraphDatabase readOnlySlave = cluster.GetMemberByServerId(new InstanceId(2));

            try
            {
                using (Transaction tx = readOnlySlave.BeginTx())
                {
                    Node slaveNode = readOnlySlave.GetNodeById(node.Id);

                    // Then
                    slaveNode.SetProperty("foo", "bar");
                    tx.Success();
                    fail("Should have thrown exception");
                }
            }
            catch (WriteOperationsNotAllowedException)
            {
                // Ok!
            }
        }
Esempio n. 2
0
        private void AssertLastTransactions(ManagedCluster cluster, params LastTxMapping[] transactionMappings)
        {
            StringBuilder failures = new StringBuilder();

            foreach (LastTxMapping mapping in transactionMappings)
            {
                GraphDatabaseAPI db = cluster.GetMemberByServerId(mapping.ServerId);
                mapping.Format(failures, GetLastTx(db));
            }
            assertEquals(failures.ToString(), 0, failures.Length);
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void givenClusterWithReadOnlySlaveWhenWriteTxOnSlaveThenCommitFails()
        public virtual void GivenClusterWithReadOnlySlaveWhenWriteTxOnSlaveThenCommitFails()
        {
            // When
            ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase readOnlySlave = cluster.GetMemberByServerId(new InstanceId(2));

            try
            {
                using (Transaction tx = readOnlySlave.BeginTx())
                {
                    readOnlySlave.CreateNode();
                    tx.Success();
                    fail("Should have thrown exception");
                }
            }
            catch (WriteOperationsNotAllowedException)
            {
                // Then
            }
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void givenClusterWithReadOnlySlaveWhenAddNewRelTypeOnSlaveThenThrowException()
        public virtual void GivenClusterWithReadOnlySlaveWhenAddNewRelTypeOnSlaveThenThrowException()
        {
            // Given
            ManagedCluster cluster = ClusterRule.startCluster();
            Node           node;
            Node           node2;
            HighlyAvailableGraphDatabase master = cluster.Master;

            using (Transaction tx = master.BeginTx())
            {
                node  = master.CreateNode();
                node2 = master.CreateNode();
                tx.Success();
            }

            // When
            HighlyAvailableGraphDatabase readOnlySlave = cluster.GetMemberByServerId(new InstanceId(2));

            try
            {
                using (Transaction tx = readOnlySlave.BeginTx())
                {
                    Node slaveNode  = readOnlySlave.GetNodeById(node.Id);
                    Node slaveNode2 = readOnlySlave.GetNodeById(node2.Id);

                    // Then
                    slaveNode.CreateRelationshipTo(slaveNode2, RelationshipType.withName("KNOWS"));
                    tx.Success();
                    fail("Should have thrown exception");
                }
            }
            catch (WriteOperationsNotAllowedException)
            {
                // Ok!
            }
        }
Esempio n. 5
0
 private int CreateTransactionOn(ManagedCluster cluster, InstanceId serverId)
 {
     return(CreateTransaction(cluster, cluster.GetMemberByServerId(serverId)));
 }