示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConnectToGroupDefinedInStrategySpecificConfig()
        public virtual void ShouldConnectToGroupDefinedInStrategySpecificConfig()
        {
            // given
            const string targetServerGroup           = "target_server_group";
            Config       configWithTargetServerGroup = Config.defaults(CausalClusteringSettings.connect_randomly_to_server_group_strategy, targetServerGroup);

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

            ConnectRandomlyToServerGroupStrategy strategy = new ConnectRandomlyToServerGroupStrategy();

            strategy.Inject(topologyService, configWithTargetServerGroup, NullLogProvider.Instance, targetGroupMemberIds[0]);

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

            // then
            assertThat(result, contains(isIn(targetGroupMemberIds)));
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void doesNotConnectToSelf()
        public virtual void DoesNotConnectToSelf()
        {
            // given
            ConnectRandomlyToServerGroupStrategy connectRandomlyToServerGroupStrategy = new ConnectRandomlyToServerGroupStrategy();
            MemberId myself = new MemberId(new System.Guid(1234, 5678));

            // and
            LogProvider logProvider = NullLogProvider.Instance;
            Config      config      = Config.defaults();

            config.Augment(CausalClusteringSettings.connect_randomly_to_server_group_strategy, "firstGroup");
            TopologyService topologyService = new TopologyServiceThatPrioritisesItself(myself, "firstGroup");

            connectRandomlyToServerGroupStrategy.Inject(topologyService, config, logProvider, myself);

            // when
            Optional <MemberId> found = connectRandomlyToServerGroupStrategy.UpstreamDatabase();

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