Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUseServerGroupsFromConfig()
        public virtual void ShouldUseServerGroupsFromConfig()
        {
            // given
            const string myServerGroup           = "my_server_group";
            Config       configWithMyServerGroup = Config.defaults(CausalClusteringSettings.server_groups, myServerGroup);

            MemberId[]      myGroupMemberIds = memberIDs(10);
            TopologyService topologyService  = ConnectRandomlyToServerGroupStrategyImplTest.GetTopologyService(Collections.singletonList(myServerGroup), myGroupMemberIds, Collections.singletonList("your_server_group"));

            ConnectRandomlyWithinServerGroupStrategy strategy = new ConnectRandomlyWithinServerGroupStrategy();

            strategy.Inject(topologyService, configWithMyServerGroup, NullLogProvider.Instance, myGroupMemberIds[0]);

            // when
            Optional <MemberId> result = strategy.UpstreamDatabase();

            // then
            assertThat(result, contains(isIn(myGroupMemberIds)));
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void filtersSelf()
        public virtual void FiltersSelf()
        {
            // given
            string groupName = "groupName";
            Config config    = Config.defaults();

            config.Augment(CausalClusteringSettings.server_groups, groupName);

            // and
            ConnectRandomlyWithinServerGroupStrategy connectRandomlyWithinServerGroupStrategy = new ConnectRandomlyWithinServerGroupStrategy();
            MemberId myself = new MemberId(new System.Guid(123, 456));

            connectRandomlyWithinServerGroupStrategy.Inject(new TopologyServiceThatPrioritisesItself(myself, groupName), config, NullLogProvider.Instance, myself);

            // when
            Optional <MemberId> result = connectRandomlyWithinServerGroupStrategy.UpstreamDatabase();

            // then
            Assert.assertTrue(result.Present);
            Assert.assertNotEquals(myself, result.get());
        }