コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowOtherHostToCompleteIfFirstHostRollsBackTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowOtherHostToCompleteIfFirstHostRollsBackTransaction()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();

            HighlyAvailableGraphDatabase slave1 = cluster.AnySlave;
            HighlyAvailableGraphDatabase slave2 = cluster.GetAnySlave(slave1);

            // when
            Future <bool> created;

            using (Transaction tx = slave1.BeginTx())
            {
                slave1.CreateNode(_label).setProperty(PROPERTY_KEY, "value4");

                created = OtherThread.execute(CreateNode(slave2, _label.name(), PROPERTY_KEY, "value4"));

                assertThat(OtherThread, Waiting);

                tx.Failure();
            }

            // then
            assertTrue("creating data that conflicts only with rolled back data should pass", created.get());
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPreventConcurrentCreationOfConflictingDataOnSeparateHosts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPreventConcurrentCreationOfConflictingDataOnSeparateHosts()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();

            HighlyAvailableGraphDatabase slave1 = cluster.AnySlave;
            HighlyAvailableGraphDatabase slave2 = cluster.GetAnySlave(slave1);

            // when
            Future <bool> created;

            using (Transaction tx = slave1.BeginTx())
            {
                slave1.CreateNode(_label).setProperty(PROPERTY_KEY, "value3");

                created = OtherThread.execute(CreateNode(slave2, _label.name(), PROPERTY_KEY, "value3"));

                assertThat(OtherThread, Waiting);

                tx.Success();
            }

            // then
            assertFalse("creating violating data should fail", created.get());
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPreventConcurrentCreationOfConflictingNonStringPropertyOnMasterAndSlave() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPreventConcurrentCreationOfConflictingNonStringPropertyOnMasterAndSlave()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();

            HighlyAvailableGraphDatabase master = cluster.Master;
            HighlyAvailableGraphDatabase slave  = cluster.AnySlave;

            // when
            Future <bool> created;

            using (Transaction tx = master.BeginTx())
            {
                master.CreateNode(_label).setProperty(PROPERTY_KEY, 0x0099CC);

                created = OtherThread.execute(CreateNode(slave, _label.name(), PROPERTY_KEY, 0x0099CC));

                assertThat(OtherThread, Waiting);

                tx.Success();
            }

            // then
            assertFalse("creating violating data should fail", created.get());
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createBufferedIdComponentsByDefault()
        public virtual void CreateBufferedIdComponentsByDefault()
        {
            ClusterManager.ManagedCluster managedCluster     = ClusterRule.startCluster();
            DependencyResolver            dependencyResolver = managedCluster.Master.DependencyResolver;

            IdController       idController       = dependencyResolver.ResolveDependency(typeof(IdController));
            IdGeneratorFactory idGeneratorFactory = dependencyResolver.ResolveDependency(typeof(IdGeneratorFactory));

            assertThat(idController, instanceOf(typeof(BufferedIdController)));
            assertThat(idGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void Setup()
		 {
			  CustomGraphDatabaseFactory customGraphDatabaseFactory = new CustomGraphDatabaseFactory( this );
			  _cluster = ClusterRule.withSharedSetting( GraphDatabaseSettings.snapshot_query, TRUE ).withDbFactory( customGraphDatabaseFactory ).startCluster();
			  HighlyAvailableGraphDatabase master = _cluster.Master;
			  for ( int i = 0; i < 3; i++ )
			  {
					using ( Transaction tx = master.BeginTx() )
					{
						 master.CreateNode( _nodeLabel );
						 tx.Success();
					}
			  }
			  _cluster.sync();
		 }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            _cluster = ClusterRule.startCluster();
            _slave   = _cluster.AnySlave;

            // Create some basic data
            using (Transaction tx = _slave.beginTx())
            {
                Node node = _slave.createNode(Label.label("Person"));
                node.SetProperty("name", "Bob");
                node.CreateRelationshipTo(_slave.createNode(), RelationshipType.withName("KNOWS"));

                tx.Success();
            }

            // And now monitor the master for incoming calls
            _cluster.Master.DependencyResolver.resolveDependency(typeof(Monitors)).addMonitorListener(_masterMonitor);
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void creatingConstraintOnSlaveIsNotAllowed()
        public virtual void CreatingConstraintOnSlaveIsNotAllowed()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase  slave   = cluster.AnySlave;

            slave.BeginTx();
            try
            {
                ConstraintCreator constraintCreator = slave.Schema().constraintFor(Label.label("LabelName")).assertPropertyIsUnique("PropertyName");

                // when
                constraintCreator.Create();
                fail("should have thrown exception");
            }
            catch (ConstraintViolationException e)
            {
                assertThat(e.Message, equalTo("Modifying the database schema can only be done on the master server, " + "this server is a slave. Please issue schema modification commands directly to the master."));
            }
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowCreationOfNonConflictingDataOnSeparateHosts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowCreationOfNonConflictingDataOnSeparateHosts()
        {
            // given
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();

            HighlyAvailableGraphDatabase slave1 = cluster.AnySlave;
            HighlyAvailableGraphDatabase slave2 = cluster.GetAnySlave(slave1);

            // when
            Future <bool> created;

            using (Transaction tx = slave1.BeginTx())
            {
                slave1.CreateNode(_label).setProperty(PROPERTY_KEY, "value1");

                created = OtherThread.execute(CreateNode(slave2, _label.name(), PROPERTY_KEY, "value2"));
                tx.Success();
            }

            // then
            assertTrue("creating non-conflicting data should pass", created.get());
        }
コード例 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _cluster = ClusterRule.withSharedSetting(HaSettings.ReadTimeout, "1s").withSharedSetting(HaSettings.StateSwitchTimeout, "2s").withSharedSetting(HaSettings.ComChunkSize, "1024").withCluster(clusterOfSize(2)).startCluster();
        }
コード例 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            Cluster = ClusterRule.startCluster();
        }