//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSetDiscoveryHeaderProperly() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSetDiscoveryHeaderProperly() { // GIVEN ClusterContext context = mock(typeof(ClusterContext)); when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance); when(context.GetUriForId(Id(2))).thenReturn(Uri(2)); when(context.JoiningInstances).thenReturn(singletonList(Uri(2))); IList <ConfigurationRequestState> discoveredInstances = new LinkedList <ConfigurationRequestState>(); when(context.DiscoveredInstances).thenReturn(discoveredInstances); TrackingMessageHolder outgoing = new TrackingMessageHolder(); ClusterMessage.ConfigurationTimeoutState timeoutState = new ClusterMessage.ConfigurationTimeoutState(3); Message <ClusterMessage> message = @internal(configurationTimeout, timeoutState); string discoveryHeader = "1,2,3"; when(context.GenerateDiscoveryHeader()).thenReturn(discoveryHeader); // WHEN // We receive a configuration request from an instance which we haven't contacted ClusterState.Discovery.handle(context, message, outgoing); // THEN // It shouldn't be added to the discovered instances assertEquals(discoveryHeader, outgoing.First().getHeader(DISCOVERED)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void proposer_rejectAcceptShouldCarryOnPayload() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ProposerRejectAcceptShouldCarryOnPayload() { // GIVEN string instanceId = "1"; PaxosInstance instance = new PaxosInstance(mock(typeof(PaxosInstanceStore)), new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)); Serializable payload = "myPayload"; instance.Propose(1, new IList <java.net.URI> { create("http://some-guy") }); instance.Ready(payload, true); instance.Pending(); ProposerContext context = mock(typeof(ProposerContext)); when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance); when(context.GetPaxosInstance(any(typeof(Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId)))).thenReturn(instance); when(context.MyId).thenReturn(new Org.Neo4j.cluster.InstanceId(parseInt(instanceId))); TrackingMessageHolder outgoing = new TrackingMessageHolder(); Message <ProposerMessage> message = to(rejectAccept, create("http://something"), new ProposerMessage.RejectAcceptState()).setHeader(INSTANCE, instanceId); // WHEN ProposerState.Proposer.handle(context, message, outgoing); // THEN verify(context).setTimeout(eq(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)), argThat((new MessageArgumentMatcher <>()).withPayload(payload))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void joinDeniedHandlingShouldKeepResponseConfiguration() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void JoinDeniedHandlingShouldKeepResponseConfiguration() { // GIVEN ClusterContext context = mock(typeof(ClusterContext)); when(context.GetLog(any(typeof(Type)))).thenReturn(NullLog.Instance); TrackingMessageHolder outgoing = new TrackingMessageHolder(); IDictionary <InstanceId, URI> members = members(1, 2); // WHEN a joining instance receives a denial to join ClusterState.Discovery.handle(context, to(joinDenied, Uri(2), ConfigurationResponseState(members)), outgoing); // THEN assert that the response contains the configuration verify(context).joinDenied(argThat((new ConfigurationResponseStateMatcher()).WithMembers(members))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void proposer_proposePhase1TimeoutShouldCarryOnPayload() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ProposerProposePhase1TimeoutShouldCarryOnPayload() { // GIVEN PaxosInstance instance = mock(typeof(PaxosInstance)); ProposerContext context = mock(typeof(ProposerContext)); when(context.GetPaxosInstance(any(typeof(Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId)))).thenReturn(instance); when(context.MyId).thenReturn(new Org.Neo4j.cluster.InstanceId(0)); TrackingMessageHolder outgoing = new TrackingMessageHolder(); string instanceId = "1"; Serializable payload = "myPayload"; Message <ProposerMessage> message = to(propose, create("http://something"), payload).setHeader(INSTANCE, instanceId); // WHEN ProposerState.Proposer.handle(context, message, outgoing); // THEN verify(context).setTimeout(eq(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)), argThat((new MessageArgumentMatcher <>()).withPayload(payload))); }
//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); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void proposer_promiseShouldCarryOnPayloadToPhase2Timeout() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ProposerPromiseShouldCarryOnPayloadToPhase2Timeout() { // GIVEN string instanceId = "1"; Serializable payload = "myPayload"; PaxosInstance instance = new PaxosInstance(mock(typeof(PaxosInstanceStore)), new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)); instance.Propose(1, new IList <java.net.URI> { create("http://some-guy") }); instance.Value_2 = payload; // don't blame me for making it package access. ProposerContext context = mock(typeof(ProposerContext)); when(context.GetPaxosInstance(any(typeof(Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId)))).thenReturn(instance); when(context.GetMinimumQuorumSize(anyList())).thenReturn(1); TrackingMessageHolder outgoing = new TrackingMessageHolder(); Message <ProposerMessage> message = to(promise, create("http://something"), new ProposerMessage.PromiseState(1, payload)).setHeader(INSTANCE, instanceId); // WHEN ProposerState.Proposer.handle(context, message, outgoing); // THEN verify(context).setTimeout(eq(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(instanceId)), argThat((new MessageArgumentMatcher <>()).withPayload(payload))); }
//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); }
//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); }