/* * This test is required to ensure compatibility with the previous version. If we fail on non existing HEADER_INSTANCE_ID * header then heartbeats may pause during rolling upgrades and cause timeouts, which we don't want. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRevertToInverseUriLookupIfNoInstanceIdHeader() public virtual void ShouldRevertToInverseUriLookupIfNoInstanceIdHeader() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<org.neo4j.cluster.com.message.Message> sentOut = new java.util.LinkedList<>(); IList <Message> sentOut = new LinkedList <Message>(); string instance2UriString = "ha://2"; // Given MessageHolder holder = mock(typeof(MessageHolder)); // The sender, which adds messages outgoing to the list above. doAnswer(invocation => { sentOut.Add(invocation.getArgument(0)); return(null); }).when(holder).offer(ArgumentMatchers.any <Message <MessageType> >()); ClusterContext mockContext = mock(typeof(ClusterContext)); ClusterConfiguration mockConfiguration = mock(typeof(ClusterConfiguration)); when(mockConfiguration.GetIdForUri(URI.create(instance2UriString))).thenReturn(new InstanceId(2)); when(mockConfiguration.Members).thenReturn(new HashMapAnonymousInnerClass6(this)); when(mockContext.Configuration).thenReturn(mockConfiguration); HeartbeatIAmAliveProcessor processor = new HeartbeatIAmAliveProcessor(holder, mockContext); Message incoming = Message.to(mock(typeof(MessageType)), URI.create("ha://someAwesomeInstanceInJapan")).setHeader(Message.HEADER_FROM, instance2UriString); // WHEN processor.Process(incoming); // THEN assertEquals(1, sentOut.Count); assertEquals(HeartbeatMessage.IAmAlive, sentOut[0].MessageType); assertEquals(new InstanceId(2), ((HeartbeatMessage.IAmAliveState)sentOut[0].Payload).Server); }