//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 testResponseDeserialzeRuntimeException() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testResponseDeserialzeRuntimeException()
        {
            NormalRequestBodyCustomSerializer s1 = new NormalRequestBodyCustomSerializer();
            ExceptionStringCustomSerializer   s2 = new ExceptionStringCustomSerializer(false, false, false, true);

//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!");
            string      ret  = null;

            try
            {
                ret = (string)client.invokeSync(addr, body, 1000);
                Assert.Null("Should not reach here!");
            }
            catch (DeserializationException e)
            {
                logger.LogError("", e);
                Assert.False(e.ServerSide);
                Assert.Null(ret);
                Assert.True(s1.Serialized);
                Assert.True(s1.Deserialized);
                Assert.True(s2.Serialized);
                Assert.True(s2.Deserialized);
            }
            catch (System.Exception)
            {
                Assert.Null("Should not reach here!");
            }
        }
 //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
 //ORIGINAL LINE: @After public void stop()
 public void Dispose()
 {
     CustomSerializerManager.clear();
     try
     {
         server.stop();
         Thread.Sleep(100);
     }
     catch (ThreadInterruptedException e)
     {
         logger.LogError("Stop server failed!", e);
     }
 }
        //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 testIllegalType() throws Exception
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testIllegalType()
        {
            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);

            RequestBody req = new RequestBody(1, "hello world sync");

            for (int i = 0; i < invokeTimes; i++)
            {
                try
                {
                    byte          testCodec     = (byte)i;
                    InvokeContext invokeContext = new InvokeContext();
                    invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, (int)testCodec);
                    string res = (string)client.invokeSync(addr, req, invokeContext, 3000);
                    logger.LogWarning("Result received in sync: " + res);
                    Assert.Equal(RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM", res);

                    Assert.Equal(testCodec, s1.ContentSerializer);
                    Assert.Equal(testCodec, s2.ContentSerializer);
                }
                catch (ArgumentException e)
                {
                    logger.LogError("ArgumentException", e);
                    Assert.True(true);
                    return;
                }
                catch (ThreadInterruptedException e)
                {
                    string errMsg = "ThreadInterruptedException caught in sync!";
                    logger.LogError(errMsg, e);
                    Assert.Null(errMsg);
                }
                Assert.Null("Should not reach here!");
            }

            Assert.True(serverConnectProcessor.Connected);
            Assert.Equal(1, serverConnectProcessor.ConnectTimes);
            Assert.Equal(invokeTimes, serverUserProcessor.InvokeTimes);
        }
        //ORIGINAL LINE: @Test public void testFuture() throws ThreadInterruptedException
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testFuture()
        {
            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);

            RequestBody req = new RequestBody(2, "hello world future");

            for (int i = 0; i < invokeTimes; i++)
            {
                try
                {
                    byte          testCodec     = (byte)i;
                    InvokeContext invokeContext = new InvokeContext();
                    invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, testCodec);

                    RpcResponseFuture future = client.invokeWithFuture(addr, req, invokeContext, 3000);
                    string            res    = (string)future.get();
                    Assert.Equal(RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM", res);

                    Assert.Equal(testCodec, s1.ContentSerializer);
                    Assert.Equal(testCodec, s2.ContentSerializer);
                }
                catch (RemotingException e)
                {
                    string errMsg = "RemotingException caught in future!";
                    logger.LogError(errMsg, e);
                    Assert.Null(errMsg);
                }
                catch (ThreadInterruptedException e)
                {
                    string errMsg = "ThreadInterruptedException caught in future!";
                    logger.LogError(errMsg, e);
                    Assert.Null(errMsg);
                }
            }

            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);
        }
        //ORIGINAL LINE: @Test public void testNormalCustomSerializer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testNormalCustomSerializer()
        {
            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);

            RequestBody body = new RequestBody(1, "hello world!");
            string      ret  = (string)client.invokeSync(addr, body, 1000);

            Assert.Equal(RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM", ret);
            Assert.True(s1.Serialized);
            Assert.True(s1.Deserialized);
            Assert.True(s2.Serialized);
            Assert.True(s2.Deserialized);
        }
        //ORIGINAL LINE: @Test public void testOneway() throws ThreadInterruptedException
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testOneway()
        {
            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);

            RequestBody req = new RequestBody(2, "hello world oneway");

            for (int i = 0; i < invokeTimes; i++)
            {
                try
                {
                    byte          testCodec     = (byte)i;
                    InvokeContext invokeContext = new InvokeContext();
                    invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, testCodec);
                    client.oneway(addr, req, invokeContext);

                    Assert.Equal(testCodec, s1.ContentSerializer);
                    Assert.Equal(255, s2.ContentSerializer);
                    Thread.Sleep(100);
                }
                catch (RemotingException e)
                {
                    string errMsg = "RemotingException caught in oneway!";
                    logger.LogError(errMsg, e);
                    Assert.Null(errMsg);
                }
            }

            Assert.True(serverConnectProcessor.Connected);
            Assert.Equal(1, serverConnectProcessor.ConnectTimes);
            Assert.Equal(invokeTimes, serverUserProcessor.InvokeTimes);
        }
        //ORIGINAL LINE: @Test public void testCallback() throws ThreadInterruptedException
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testCallback()
        {
            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);

            RequestBody req = new RequestBody(1, "hello world callback");
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final java.util.List<String> rets = new java.util.ArrayList<String>(1);
            IList <string> rets = new List <string>(1);

            for (int i = 0; i < invokeTimes; i++)
            {
                //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);

                byte          testCodec     = (byte)i;
                InvokeContext invokeContext = new InvokeContext();
                invokeContext.put(InvokeContext.BOLT_CUSTOM_SERIALIZER, testCodec);

                try
                {
                    client.invokeWithCallback(addr, req, invokeContext, new InvokeCallbackAnonymousInnerClass(this, rets, latch), 1000);
                }
                catch (RemotingException e)
                {
                    if (!latch.IsSet)
                    {
                        latch.Signal();
                    }
                    string errMsg = "RemotingException caught in callback!";
                    logger.LogError(errMsg, e);
                    Assert.Null(errMsg);
                }
                try
                {
                    latch.Wait();
                }
                catch (ThreadInterruptedException e)
                {
                    string errMsg = "ThreadInterruptedException caught in callback!";
                    logger.LogError(errMsg, e);
                    Assert.Null(errMsg);
                }
                if (rets.Count == 0)
                {
                    Assert.Null("No result! Maybe exception caught!");
                }
                Assert.Equal(RequestBody.DEFAULT_SERVER_RETURN_STR + "RANDOM", rets[0]);
                rets.Clear();

                Assert.Equal(testCodec, s1.ContentSerializer);
                Assert.Equal(testCodec, s2.ContentSerializer);
            }

            Assert.True(serverConnectProcessor.Connected);
            Assert.Equal(1, serverConnectProcessor.ConnectTimes);
            Assert.Equal(invokeTimes, serverUserProcessor.InvokeTimes);
        }
 static BasicUsage_ExecutorSelector_Test()
 {
     CustomSerializerManager.registerCustomSerializer(typeof(RequestBody), new CustomHeaderSerializer());
 }