コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void joinDeniedTimeoutShouldBeHandledWithExceptionIncludingConfiguration() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void JoinDeniedTimeoutShouldBeHandledWithExceptionIncludingConfiguration()
        {
            // GIVEN
            ClusterContext context = mock(typeof(ClusterContext));
            IDictionary <InstanceId, URI> existingMembers = Members(1, 2);

            when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance);
            when(context.JoiningInstances).thenReturn(Collections.emptyList());
            when(context.HasJoinBeenDenied()).thenReturn(true);
            when(context.JoinDeniedConfigurationResponseState).thenReturn(ConfigurationResponseState(existingMembers));
            TrackingMessageHolder outgoing = new TrackingMessageHolder();

            // WHEN the join denial actually takes effect (signaled by a join timeout locally)
            ClusterState.Joining.handle(context, to(ClusterMessage.JoiningTimeout, Uri(2)).setHeader(Message.HEADER_CONVERSATION_ID, "bla"), outgoing);

            // THEN assert that the failure contains the received configuration
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.cluster.com.message.Message<? extends org.neo4j.cluster.com.message.MessageType> response = outgoing.single();
            Message <MessageType>       response        = outgoing.Single();
            ClusterEntryDeniedException deniedException = response.Payload;

            assertEquals(existingMembers, deniedException.ConfigurationResponseState.Members);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void joinDeniedResponseShouldContainRespondersConfiguration() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void JoinDeniedResponseShouldContainRespondersConfiguration()
        {
            // GIVEN
            ClusterContext context = mock(typeof(ClusterContext));
            IDictionary <InstanceId, URI> existingMembers = Members(1, 2);

            when(context.IsCurrentlyAlive(any(typeof(InstanceId)))).thenReturn(true);
            when(context.Members).thenReturn(existingMembers);
            when(context.Configuration).thenReturn(ClusterConfiguration(existingMembers));
            when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance);
            TrackingMessageHolder    outgoing = new TrackingMessageHolder();
            Message <ClusterMessage> message  = to(configurationRequest, Uri(1), Configuration(2)).setHeader(Message.HEADER_FROM, Uri(2).ToString());

            // WHEN an instance responds to a join request, responding that the joining instance cannot join
            ClusterState.Entered.handle(context, message, outgoing);

            // THEN assert that the responding instance sends its configuration along with the response
            Message <ClusterMessage> response = outgoing.Single();

            assertTrue(response.Payload is ConfigurationResponseState);
            ConfigurationResponseState responseState = response.Payload;

            assertEquals(existingMembers, responseState.Members);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotDenyJoinToInstanceThatRejoinsBeforeTimingOut() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotDenyJoinToInstanceThatRejoinsBeforeTimingOut()
        {
            // GIVEN
            ClusterContext context = mock(typeof(ClusterContext));
            IDictionary <InstanceId, URI> existingMembers = Members(1, 2);

            when(context.IsCurrentlyAlive(Id(2))).thenReturn(true);
            when(context.Members).thenReturn(existingMembers);
            when(context.Configuration).thenReturn(ClusterConfiguration(existingMembers));
            when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance);
            when(context.GetUriForId(Id(2))).thenReturn(Uri(2));
            TrackingMessageHolder    outgoing = new TrackingMessageHolder();
            Message <ClusterMessage> message  = to(configurationRequest, Uri(1), Configuration(2)).setHeader(Message.HEADER_FROM, Uri(2).ToString());

            // WHEN the join denial actually takes effect (signaled by a join timeout locally)
            ClusterState.Entered.handle(context, message, outgoing);

            // THEN assert that the failure contains the received configuration
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.cluster.com.message.Message<? extends org.neo4j.cluster.com.message.MessageType> response = outgoing.single();
            Message <MessageType> response = outgoing.Single();

            assertEquals(ClusterMessage.ConfigurationResponse, response.MessageType);
        }