public NetworkSender(Monitor monitor, Configuration config, NetworkReceiver receiver, LogProvider logProvider) { this._monitor = monitor; this._config = config; this._receiver = receiver; this._msgLog = logProvider.getLog(this.GetType()); _me = URI.create(CLUSTER_SCHEME + "://0.0.0.0:" + config.Port()); receiver.AddNetworkChannelsListener(new NetworkChannelsListenerAnonymousInnerClass(this)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetURIWithLocalHost() public virtual void TestGetURIWithLocalHost() { NetworkReceiver networkReceiver = new NetworkReceiver(mock(typeof(NetworkReceiver.Monitor)), mock(typeof(NetworkReceiver.Configuration)), mock(typeof(LogProvider))); // We should NOT do a reverse DNS lookup for hostname. It might not be routed properly. URI uri = networkReceiver.GetURI(new InetSocketAddress("localhost", PORT)); assertEquals("Uri host is not localhost ip: " + uri.Host, "127.0.0.1", uri.Host); assertEquals(PORT, uri.Port); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetURIWithWildCard() public virtual void TestGetURIWithWildCard() { NetworkReceiver networkReceiver = new NetworkReceiver(mock(typeof(NetworkReceiver.Monitor)), mock(typeof(NetworkReceiver.Configuration)), mock(typeof(LogProvider))); // Wildcard should not be resolved here const string wildCard = "0.0.0.0"; URI uri = networkReceiver.GetURI(new InetSocketAddress(wildCard, PORT)); assertEquals(wildCard + " does not match Uri host: " + uri.Host, wildCard, uri.Host); assertEquals(PORT, uri.Port); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMessageReceivedOriginFix() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestMessageReceivedOriginFix() { LogProvider logProvider = mock(typeof(LogProvider)); Log log = mock(typeof(Log)); when(logProvider.GetLog(typeof(NetworkReceiver))).thenReturn(log); NetworkReceiver networkReceiver = new NetworkReceiver(mock(typeof(NetworkReceiver.Monitor)), mock(typeof(NetworkReceiver.Configuration)), logProvider); // This defines where message is coming from //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.net.InetSocketAddress inetSocketAddress = new java.net.InetSocketAddress("localhost", PORT); InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", PORT); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.jboss.netty.channel.Channel channel = mock(org.jboss.netty.channel.Channel.class); Channel channel = mock(typeof(Channel)); when(channel.LocalAddress).thenReturn(inetSocketAddress); when(channel.RemoteAddress).thenReturn(inetSocketAddress); ChannelHandlerContext ctx = mock(typeof(ChannelHandlerContext)); when(ctx.Channel).thenReturn(channel); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.com.message.Message message = org.neo4j.cluster.com.message.Message.to(() -> "test", new java.net.URI("cluster://anywhere")); Message message = Message.to(() => "test", new URI("cluster://anywhere")); MessageEvent messageEvent = mock(typeof(MessageEvent)); when(messageEvent.RemoteAddress).thenReturn(inetSocketAddress); when(messageEvent.Message).thenReturn(message); when(messageEvent.Channel).thenReturn(channel); // the original HEADER_FROM header should be ignored message.setHeader(Message.HEADER_FROM, "cluster://someplace:1234"); new Org.Neo4j.cluster.com.NetworkReceiver.MessageReceiver(networkReceiver).messageReceived(ctx, messageEvent); assertEquals("HEADER_FROM header should have been changed to visible ip address: " + message.getHeader(Message.HEADER_FROM), "cluster://127.0.0.1:1234", message.getHeader(Message.HEADER_FROM)); }
public MessageReceiver(NetworkReceiver outerInstance) { this._outerInstance = outerInstance; }
public NetworkNodePipelineFactory(NetworkReceiver outerInstance) { this._outerInstance = outerInstance; }