Пример #1
0
 // separated test out so that other tests can call it.
 /// <exception cref="System.Exception"/>
 public static void TestProtoBufRpc(TestProtoBufRpc.TestRpcService client)
 {
     // Test ping method
     TestProtos.EmptyRequestProto emptyRequest = ((TestProtos.EmptyRequestProto)TestProtos.EmptyRequestProto
                                                  .NewBuilder().Build());
     client.Ping(null, emptyRequest);
     // Test echo method
     TestProtos.EchoRequestProto echoRequest = ((TestProtos.EchoRequestProto)TestProtos.EchoRequestProto
                                                .NewBuilder().SetMessage("hello").Build());
     TestProtos.EchoResponseProto echoResponse = client.Echo(null, echoRequest);
     Assert.Equal(echoResponse.GetMessage(), "hello");
     // Test error method - error should be thrown as RemoteException
     try
     {
         client.Error(null, emptyRequest);
         NUnit.Framework.Assert.Fail("Expected exception is not thrown");
     }
     catch (ServiceException e)
     {
         RemoteException    re  = (RemoteException)e.InnerException;
         RpcServerException rse = (RpcServerException)re.UnwrapRemoteException(typeof(RpcServerException
                                                                                      ));
         NUnit.Framework.Assert.IsNotNull(rse);
         Assert.True(re.GetErrorCode().Equals(RpcHeaderProtos.RpcResponseHeaderProto.RpcErrorCodeProto
                                              .ErrorRpcServer));
     }
 }
Пример #2
0
        /// <summary>Create a client proxy for the specified engine.</summary>
        /// <exception cref="System.IO.IOException"/>
        private RPCCallBenchmark.RpcServiceWrapper CreateRpcClient(RPCCallBenchmark.MyOptions
                                                                   opts)
        {
            IPEndPoint addr = NetUtils.CreateSocketAddr(opts.host, opts.GetPort());

            if (opts.rpcEngine == typeof(ProtobufRpcEngine))
            {
                TestProtoBufRpc.TestRpcService proxy = RPC.GetProxy <TestProtoBufRpc.TestRpcService
                                                                     >(0, addr, conf);
                return(new _RpcServiceWrapper_394(proxy));
            }
            else
            {
                if (opts.rpcEngine == typeof(WritableRpcEngine))
                {
                    TestRPC.TestProtocol proxy = RPC.GetProxy <TestRPC.TestProtocol>(TestRPC.TestProtocol
                                                                                     .versionID, addr, conf);
                    return(new _RpcServiceWrapper_407(proxy));
                }
                else
                {
                    throw new RuntimeException("unsupported engine: " + opts.rpcEngine);
                }
            }
        }
        public virtual void TestPBService()
        {
            // Set RPC engine to protobuf RPC engine
            Configuration conf2 = new Configuration();

            RPC.SetProtocolEngine(conf2, typeof(TestProtoBufRpc.TestRpcService), typeof(ProtobufRpcEngine
                                                                                        ));
            TestProtoBufRpc.TestRpcService client = RPC.GetProxy <TestProtoBufRpc.TestRpcService
                                                                  >(0, addr, conf2);
            TestProtoBufRpc.TestProtoBufRpc(client);
        }
Пример #4
0
 /// <exception cref="System.Exception"/>
 public virtual void TestProtoBufRandomException()
 {
     TestProtoBufRpc.TestRpcService client       = GetClient();
     TestProtos.EmptyRequestProto   emptyRequest = ((TestProtos.EmptyRequestProto)TestProtos.EmptyRequestProto
                                                    .NewBuilder().Build());
     try
     {
         client.Error2(null, emptyRequest);
     }
     catch (ServiceException se)
     {
         Assert.True(se.InnerException is RemoteException);
         RemoteException re = (RemoteException)se.InnerException;
         Assert.True(re.GetClassName().Equals(typeof(URISyntaxException)
                                              .FullName));
         Assert.True(re.Message.Contains("testException"));
         Assert.True(re.GetErrorCode().Equals(RpcHeaderProtos.RpcResponseHeaderProto.RpcErrorCodeProto
                                              .ErrorApplication));
     }
 }
Пример #5
0
 /// <exception cref="System.Exception"/>
 public virtual void TestProtoBufRpc()
 {
     TestProtoBufRpc.TestRpcService client = GetClient();
     TestProtoBufRpc(client);
 }
Пример #6
0
 public _RpcServiceWrapper_394(TestProtoBufRpc.TestRpcService proxy)
 {
     this.proxy = proxy;
 }