//ORIGINAL LINE: @Test public void testServerSyncUsingAddress() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testServerSyncUsingAddress() { Connection clientConn = client.createStandaloneConnection(ip, port, 1000); string remote = clientConn.Channel.RemoteAddress.ToString(); string local = clientConn.Channel.LocalAddress.ToString(); logger.LogWarning("Client say local:" + local); logger.LogWarning("Client say remote:" + remote); for (int i = 0; i < invokeTimes; i++) { InvokeContext invokeContext = new InvokeContext(); RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR); string serverres = (string)client.invokeSync(clientConn, req1, invokeContext, 1000); Assert.Equal(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR); invokeContext.clear(); Assert.NotNull(serverConnectProcessor.Connection); // only when client invoked, the remote address can be get by UserProcessor // otherwise, please use ConnectionEventProcessor string remoteAddr = serverUserProcessor.RemoteAddr; RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR); string clientres = (string)server.RpcServer.invokeSync(remoteAddr, req, invokeContext, 1000); Assert.Equal(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR); Assert.Equal(IPAddress.Loopback.MapToIPv6(), invokeContext.get(InvokeContext.SERVER_LOCAL_IP)); Assert.Equal(IPAddress.Loopback.MapToIPv6(), invokeContext.get(InvokeContext.SERVER_REMOTE_IP)); Assert.NotNull(invokeContext.get(InvokeContext.SERVER_LOCAL_PORT)); Assert.NotNull(invokeContext.get(InvokeContext.SERVER_REMOTE_PORT)); } Assert.True(serverConnectProcessor.Connected); Assert.Equal(1, serverConnectProcessor.ConnectTimes); Assert.Equal(invokeTimes, serverUserProcessor.InvokeTimes); }
//ORIGINAL LINE: @Test public void testServerSyncUsingConnection() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testServerSyncUsingConnection() { Connection clientConn = client.createStandaloneConnection(ip, port, 1000); for (int i = 0; i < invokeTimes; i++) { InvokeContext invokeContext = new InvokeContext(); RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR); string serverres = (string)client.invokeSync(clientConn, req1, invokeContext, 1000); Assert.Equal(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR); Assert.NotNull(serverConnectProcessor.Connection); Connection serverConn = serverConnectProcessor.Connection; invokeContext.clear(); RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR); string clientres = (string)server.RpcServer.invokeSync(serverConn, req, invokeContext, 1000); Assert.Equal(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR); Assert.Equal(IPAddress.Loopback.MapToIPv6(), invokeContext.get(InvokeContext.SERVER_LOCAL_IP)); Assert.Equal(IPAddress.Loopback.MapToIPv6(), invokeContext.get(InvokeContext.SERVER_REMOTE_IP)); Assert.NotNull(invokeContext.get(InvokeContext.SERVER_LOCAL_PORT)); Assert.NotNull(invokeContext.get(InvokeContext.SERVER_REMOTE_PORT)); } Assert.True(serverConnectProcessor.Connected); Assert.Equal(1, serverConnectProcessor.ConnectTimes); Assert.Equal(invokeTimes, serverUserProcessor.InvokeTimes); }
//ORIGINAL LINE: @Test public void testInvokeContextCustomSerializer_FUTURE() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testInvokeContextCustomSerializer_FUTURE() { NormalRequestBodyCustomSerializer_InvokeContext s1 = new NormalRequestBodyCustomSerializer_InvokeContext(); NormalStringCustomSerializer_InvokeContext s2 = new NormalStringCustomSerializer_InvokeContext(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: CustomSerializerManager.registerCustomSerializer(typeof(RequestBody), s1); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: CustomSerializerManager.registerCustomSerializer(typeof(string), s2); RequestBody body = new RequestBody(1, "hello world!"); InvokeContext invokeContext = new InvokeContext(); invokeContext.putIfAbsent(NormalRequestBodyCustomSerializer_InvokeContext.SERIALTYPE_KEY, NormalRequestBodyCustomSerializer_InvokeContext.SERIALTYPE1_value); RpcResponseFuture future = client.invokeWithFuture(addr, body, invokeContext, 1000); string ret = (string)future.get(1000); Assert.Equal(RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM", ret); Assert.True(s1.Serialized); Assert.True(s1.Deserialized); invokeContext.clear(); invokeContext.putIfAbsent(NormalRequestBodyCustomSerializer_InvokeContext.SERIALTYPE_KEY, NormalRequestBodyCustomSerializer_InvokeContext.SERIALTYPE2_value); future = client.invokeWithFuture(addr, body, invokeContext, 1000); ret = (string)future.get(1000); Assert.Equal(NormalStringCustomSerializer_InvokeContext.UNIVERSAL_RESP, ret); Assert.True(s1.Serialized); Assert.True(s1.Deserialized); }
//ORIGINAL LINE: @Test public void testServerSyncUsingAddress() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testServerSyncUsingAddress() { NormalRequestBodyCustomSerializer s1 = new NormalRequestBodyCustomSerializer(); NormalStringCustomSerializer s2 = new NormalStringCustomSerializer(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: CustomSerializerManager.registerCustomSerializer(typeof(RequestBody), s1); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: CustomSerializerManager.registerCustomSerializer(typeof(string), s2); Connection clientConn = client.createStandaloneConnection(ip, port, 1000); string remote = clientConn.Channel.RemoteAddress.ToString(); string local = clientConn.Channel.LocalAddress.ToString(); logger.LogWarning("Client say local:" + local); logger.LogWarning("Client say remote:" + remote); for (int i = 0; i < invokeTimes; i++) { byte testCodec = (byte)i; InvokeContext invokeContext = new InvokeContext(); invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, testCodec); RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR); string serverres = (string)client.invokeSync(clientConn, req1, invokeContext, 1000); Assert.Equal(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM"); Assert.Equal(testCodec, s1.ContentSerializer); Assert.Equal(testCodec, s2.ContentSerializer); invokeContext.clear(); invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, (byte)(testCodec + 1)); s1.reset(); s2.reset(); Assert.NotNull(serverConnectProcessor.Connection); // only when client invoked, the remote address can be get by UserProcessor // otherwise, please use ConnectionEventProcessor string remoteAddr = serverUserProcessor.RemoteAddr; RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR); string clientres = (string)server.RpcServer.invokeSync(remoteAddr, req, invokeContext, 1000); Assert.Equal(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR + "RANDOM"); Assert.Equal(testCodec + 1, s1.ContentSerializer); Assert.Equal(testCodec + 1, s2.ContentSerializer); } Assert.True(serverConnectProcessor.Connected); Assert.Equal(1, serverConnectProcessor.ConnectTimes); Assert.Equal(invokeTimes, serverUserProcessor.InvokeTimes); }
//ORIGINAL LINE: @Test public void testInvokeContextCustomSerializer_CALLBACK() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testInvokeContextCustomSerializer_CALLBACK() { NormalRequestBodyCustomSerializer_InvokeContext s1 = new NormalRequestBodyCustomSerializer_InvokeContext(); NormalStringCustomSerializer_InvokeContext s2 = new NormalStringCustomSerializer_InvokeContext(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: CustomSerializerManager.registerCustomSerializer(typeof(RequestBody), s1); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: CustomSerializerManager.registerCustomSerializer(typeof(string), s2); RequestBody body = new RequestBody(1, "hello world!"); InvokeContext invokeContext = new InvokeContext(); invokeContext.putIfAbsent(NormalRequestBodyCustomSerializer_InvokeContext.SERIALTYPE_KEY, NormalRequestBodyCustomSerializer_InvokeContext.SERIALTYPE1_value); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<Object> rets = new java.util.ArrayList<Object>(); IList <object> rets = new List <object>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountdownEvent latch = new java.util.concurrent.CountdownEvent(1); CountdownEvent latch = new CountdownEvent(1); client.invokeWithCallback(addr, body, invokeContext, new InvokeCallbackAnonymousInnerClass(this, rets, latch), 1000); latch.Wait(); string ret = (string)rets[0]; Assert.Equal(RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM", ret); Assert.True(s1.Serialized); Assert.True(s1.Deserialized); invokeContext.clear(); invokeContext.putIfAbsent(NormalRequestBodyCustomSerializer_InvokeContext.SERIALTYPE_KEY, NormalRequestBodyCustomSerializer_InvokeContext.SERIALTYPE2_value); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountdownEvent latch1 = new java.util.concurrent.CountdownEvent(1); CountdownEvent latch1 = new CountdownEvent(1); client.invokeWithCallback(addr, body, invokeContext, new InvokeCallbackAnonymousInnerClass2(this, rets, latch1), 1000); latch1.Wait(); ret = (string)rets[0]; Assert.Equal(NormalStringCustomSerializer_InvokeContext.UNIVERSAL_RESP, ret); Assert.True(s1.Serialized); Assert.True(s1.Deserialized); }