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 switchToMasterShouldIgnoreWildcardInConfig() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SwitchToMasterShouldIgnoreWildcardInConfig()
        {
            // SwitchToMaster is used to advertise to the rest of the cluster and advertising 0.0.0.0 makes no sense

            // given
            Config config = Config.defaults(stringMap(ClusterSettings.server_id.name(), "1", HaSettings.ha_server.name(), "0.0.0.0:6001"));
            URI    me     = new URI("ha://127.0.0.1");

            MasterServer masterServer = mock(typeof(MasterServer));

            // when
            when(masterServer.SocketAddress).thenReturn(new InetSocketAddress("192.168.1.1", 6001));

            URI result = SwitchToMaster.GetMasterUri(me, masterServer, config);

            // then
            assertEquals("Wrong address", "ha://192.168.1.1:6001?serverId=1", result.ToString());

            // when masterServer is 0.0.0.0
            when(masterServer.SocketAddress).thenReturn(new InetSocketAddress(6001));

            result = SwitchToMaster.GetMasterUri(me, masterServer, config);

            // then
            assertEquals("Wrong address", "ha://127.0.0.1:6001?serverId=1", result.ToString());
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void switchToMasterShouldUseIPv6ConfigSettingIfSuitable() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SwitchToMasterShouldUseIPv6ConfigSettingIfSuitable()
        {
            // given
            Config config = Config.defaults(stringMap(ClusterSettings.server_id.name(), "1", HaSettings.ha_server.name(), "[fe80::1]:6001"));
            URI    me     = new URI("ha://[::1]");

            MasterServer masterServer = mock(typeof(MasterServer));

            // when
            when(masterServer.SocketAddress).thenReturn(new InetSocketAddress("[fe80::1]", 6001));

            URI result = SwitchToMaster.GetMasterUri(me, masterServer, config);

            // then
            assertEquals("Wrong address", "ha://[fe80::1]:6001?serverId=1", result.ToString());
        }
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 switchToMasterShouldHandleNoIpInConfig() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SwitchToMasterShouldHandleNoIpInConfig()
        {
            Config config = Config.defaults(stringMap(ClusterSettings.server_id.name(), "1", HaSettings.ha_server.name(), ":6001"));

            MasterServer masterServer = mock(typeof(MasterServer));
            URI          me           = new URI("ha://127.0.0.1");

            // when
            when(masterServer.SocketAddress).thenReturn(new InetSocketAddress("192.168.1.1", 6001));

            URI result = SwitchToMaster.GetMasterUri(me, masterServer, config);

            // then
            assertEquals("Wrong address", "ha://192.168.1.1:6001?serverId=1", result.ToString());

            // when masterServer is 0.0.0.0
            when(masterServer.SocketAddress).thenReturn(new InetSocketAddress(6001));

            result = SwitchToMaster.GetMasterUri(me, masterServer, config);

            // then
            assertEquals("Wrong address", "ha://127.0.0.1:6001?serverId=1", result.ToString());
        }