Merge pull request #8463 from ncteisen/csharp_unimplemented_method

Implement Csharp Unimplemented Method
pull/8484/head
Noah Eisen 8 years ago committed by GitHub
commit 13ca42dbae
  1. 6
      doc/interop-test-descriptions.md
  2. 16
      src/csharp/Grpc.IntegrationTesting/InteropClient.cs
  3. 8
      src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs
  4. 37
      src/csharp/Grpc.IntegrationTesting/Test.cs
  5. 105
      src/csharp/Grpc.IntegrationTesting/TestGrpc.cs

@ -779,21 +779,21 @@ Client asserts:
### unimplemented_method ### unimplemented_method
This test verifies that calling an unimplemented RPC method returns the This test verifies that calling an unimplemented RPC method returns the
UNIMPLEMENTED status code. UNIMPLEMENTED status code.
Server features: Server features:
N/A N/A
Procedure: Procedure:
* Client calls `grpc.testing.TestService/UnimplementedMethod` with an empty * Client calls `grpc.testing.TestService/UnimplementedCall` with an empty
request (defined as `grpc.testing.Empty`): request (defined as `grpc.testing.Empty`):
``` ```
{ {
} }
``` ```
Client asserts: Client asserts:
* received status code is 12 (UNIMPLEMENTED) * received status code is 12 (UNIMPLEMENTED)

@ -195,8 +195,11 @@ namespace Grpc.IntegrationTesting
case "status_code_and_message": case "status_code_and_message":
await RunStatusCodeAndMessageAsync(client); await RunStatusCodeAndMessageAsync(client);
break; break;
case "unimplemented_service":
RunUnimplementedService(new UnimplementedService.UnimplementedServiceClient(channel));
break;
case "unimplemented_method": case "unimplemented_method":
RunUnimplementedMethod(new UnimplementedService.UnimplementedServiceClient(channel)); RunUnimplementedMethod(client);
break; break;
case "client_compressed_unary": case "client_compressed_unary":
RunClientCompressedUnary(client); RunClientCompressedUnary(client);
@ -577,7 +580,16 @@ namespace Grpc.IntegrationTesting
Console.WriteLine("Passed!"); Console.WriteLine("Passed!");
} }
public static void RunUnimplementedMethod(UnimplementedService.UnimplementedServiceClient client) public static void RunUnimplementedService(UnimplementedService.UnimplementedServiceClient client)
{
Console.WriteLine("running unimplemented_service");
var e = Assert.Throws<RpcException>(() => client.UnimplementedCall(new Empty()));
Assert.AreEqual(StatusCode.Unimplemented, e.Status.StatusCode);
Console.WriteLine("Passed!");
}
public static void RunUnimplementedMethod(TestService.TestServiceClient client)
{ {
Console.WriteLine("running unimplemented_method"); Console.WriteLine("running unimplemented_method");
var e = Assert.Throws<RpcException>(() => client.UnimplementedCall(new Empty())); var e = Assert.Throws<RpcException>(() => client.UnimplementedCall(new Empty()));

@ -145,10 +145,16 @@ namespace Grpc.IntegrationTesting
await InteropClient.RunStatusCodeAndMessageAsync(client); await InteropClient.RunStatusCodeAndMessageAsync(client);
} }
[Test]
public void UnimplementedService()
{
InteropClient.RunUnimplementedService(new UnimplementedService.UnimplementedServiceClient(channel));
}
[Test] [Test]
public void UnimplementedMethod() public void UnimplementedMethod()
{ {
InteropClient.RunUnimplementedMethod(new UnimplementedService.UnimplementedServiceClient(channel)); InteropClient.RunUnimplementedMethod(client);
} }
} }
} }

@ -24,25 +24,28 @@ namespace Grpc.Testing {
string.Concat( string.Concat(
"CiFzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL3Rlc3QucHJvdG8SDGdycGMudGVz", "CiFzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL3Rlc3QucHJvdG8SDGdycGMudGVz",
"dGluZxoic3JjL3Byb3RvL2dycGMvdGVzdGluZy9lbXB0eS5wcm90bxolc3Jj", "dGluZxoic3JjL3Byb3RvL2dycGMvdGVzdGluZy9lbXB0eS5wcm90bxolc3Jj",
"L3Byb3RvL2dycGMvdGVzdGluZy9tZXNzYWdlcy5wcm90bzK7BAoLVGVzdFNl", "L3Byb3RvL2dycGMvdGVzdGluZy9tZXNzYWdlcy5wcm90bzLLBQoLVGVzdFNl",
"cnZpY2USNQoJRW1wdHlDYWxsEhMuZ3JwYy50ZXN0aW5nLkVtcHR5GhMuZ3Jw", "cnZpY2USNQoJRW1wdHlDYWxsEhMuZ3JwYy50ZXN0aW5nLkVtcHR5GhMuZ3Jw",
"Yy50ZXN0aW5nLkVtcHR5EkYKCVV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Nl",
"cnZpY2USOwoFU3RhcnQSHS5ncnBjLnRlc3RpbmcuUmVjb25uZWN0UGFyYW1z",
"GhMuZ3JwYy50ZXN0aW5nLkVtcHR5EjgKBFN0b3ASEy5ncnBjLnRlc3Rpbmcu",
"RW1wdHkaGy5ncnBjLnRlc3RpbmcuUmVjb25uZWN0SW5mb2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Grpc.Testing.EmptyReflection.Descriptor, global::Grpc.Testing.MessagesReflection.Descriptor, }, new pbr::FileDescriptor[] { global::Grpc.Testing.EmptyReflection.Descriptor, global::Grpc.Testing.MessagesReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null)); new pbr::GeneratedClrTypeInfo(null, null));

@ -71,6 +71,13 @@ namespace Grpc.Testing {
__Marshaller_SimpleRequest, __Marshaller_SimpleRequest,
__Marshaller_SimpleResponse); __Marshaller_SimpleResponse);
static readonly Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse> __Method_CacheableUnaryCall = new Method<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>(
MethodType.Unary,
__ServiceName,
"CacheableUnaryCall",
__Marshaller_SimpleRequest,
__Marshaller_SimpleResponse);
static readonly Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse> __Method_StreamingOutputCall = new Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse>( static readonly Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse> __Method_StreamingOutputCall = new Method<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse>(
MethodType.ServerStreaming, MethodType.ServerStreaming,
__ServiceName, __ServiceName,
@ -99,6 +106,13 @@ namespace Grpc.Testing {
__Marshaller_StreamingOutputCallRequest, __Marshaller_StreamingOutputCallRequest,
__Marshaller_StreamingOutputCallResponse); __Marshaller_StreamingOutputCallResponse);
static readonly Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty> __Method_UnimplementedCall = new Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>(
MethodType.Unary,
__ServiceName,
"UnimplementedCall",
__Marshaller_Empty,
__Marshaller_Empty);
/// <summary>Service descriptor</summary> /// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{ {
@ -124,6 +138,16 @@ namespace Grpc.Testing {
throw new RpcException(new Status(StatusCode.Unimplemented, "")); throw new RpcException(new Status(StatusCode.Unimplemented, ""));
} }
/// <summary>
/// One request followed by one response. Response has cache control
/// headers set such that a caching HTTP proxy (such as GFE) can
/// satisfy subsequent requests.
/// </summary>
public virtual global::System.Threading.Tasks.Task<global::Grpc.Testing.SimpleResponse> CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, ServerCallContext context)
{
throw new RpcException(new Status(StatusCode.Unimplemented, ""));
}
/// <summary> /// <summary>
/// One request followed by a sequence of responses (streamed download). /// One request followed by a sequence of responses (streamed download).
/// The server returns the payload with client desired type and sizes. /// The server returns the payload with client desired type and sizes.
@ -163,6 +187,15 @@ namespace Grpc.Testing {
throw new RpcException(new Status(StatusCode.Unimplemented, "")); throw new RpcException(new Status(StatusCode.Unimplemented, ""));
} }
/// <summary>
/// The test server will not implement this method. It will be used
/// to test the behavior when clients call unimplemented methods.
/// </summary>
public virtual global::System.Threading.Tasks.Task<global::Grpc.Testing.Empty> UnimplementedCall(global::Grpc.Testing.Empty request, ServerCallContext context)
{
throw new RpcException(new Status(StatusCode.Unimplemented, ""));
}
} }
/// <summary>Client for TestService</summary> /// <summary>Client for TestService</summary>
@ -245,6 +278,42 @@ namespace Grpc.Testing {
return CallInvoker.AsyncUnaryCall(__Method_UnaryCall, null, options, request); return CallInvoker.AsyncUnaryCall(__Method_UnaryCall, null, options, request);
} }
/// <summary> /// <summary>
/// One request followed by one response. Response has cache control
/// headers set such that a caching HTTP proxy (such as GFE) can
/// satisfy subsequent requests.
/// </summary>
public virtual global::Grpc.Testing.SimpleResponse CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
return CacheableUnaryCall(request, new CallOptions(headers, deadline, cancellationToken));
}
/// <summary>
/// One request followed by one response. Response has cache control
/// headers set such that a caching HTTP proxy (such as GFE) can
/// satisfy subsequent requests.
/// </summary>
public virtual global::Grpc.Testing.SimpleResponse CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_CacheableUnaryCall, null, options, request);
}
/// <summary>
/// One request followed by one response. Response has cache control
/// headers set such that a caching HTTP proxy (such as GFE) can
/// satisfy subsequent requests.
/// </summary>
public virtual AsyncUnaryCall<global::Grpc.Testing.SimpleResponse> CacheableUnaryCallAsync(global::Grpc.Testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
return CacheableUnaryCallAsync(request, new CallOptions(headers, deadline, cancellationToken));
}
/// <summary>
/// One request followed by one response. Response has cache control
/// headers set such that a caching HTTP proxy (such as GFE) can
/// satisfy subsequent requests.
/// </summary>
public virtual AsyncUnaryCall<global::Grpc.Testing.SimpleResponse> CacheableUnaryCallAsync(global::Grpc.Testing.SimpleRequest request, CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_CacheableUnaryCall, null, options, request);
}
/// <summary>
/// One request followed by a sequence of responses (streamed download). /// One request followed by a sequence of responses (streamed download).
/// The server returns the payload with client desired type and sizes. /// The server returns the payload with client desired type and sizes.
/// </summary> /// </summary>
@ -314,6 +383,38 @@ namespace Grpc.Testing {
{ {
return CallInvoker.AsyncDuplexStreamingCall(__Method_HalfDuplexCall, null, options); return CallInvoker.AsyncDuplexStreamingCall(__Method_HalfDuplexCall, null, options);
} }
/// <summary>
/// The test server will not implement this method. It will be used
/// to test the behavior when clients call unimplemented methods.
/// </summary>
public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
return UnimplementedCall(request, new CallOptions(headers, deadline, cancellationToken));
}
/// <summary>
/// The test server will not implement this method. It will be used
/// to test the behavior when clients call unimplemented methods.
/// </summary>
public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_UnimplementedCall, null, options, request);
}
/// <summary>
/// The test server will not implement this method. It will be used
/// to test the behavior when clients call unimplemented methods.
/// </summary>
public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> UnimplementedCallAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
return UnimplementedCallAsync(request, new CallOptions(headers, deadline, cancellationToken));
}
/// <summary>
/// The test server will not implement this method. It will be used
/// to test the behavior when clients call unimplemented methods.
/// </summary>
public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> UnimplementedCallAsync(global::Grpc.Testing.Empty request, CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_UnimplementedCall, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary> /// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override TestServiceClient NewInstance(ClientBaseConfiguration configuration) protected override TestServiceClient NewInstance(ClientBaseConfiguration configuration)
{ {
@ -327,10 +428,12 @@ namespace Grpc.Testing {
return ServerServiceDefinition.CreateBuilder() return ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_EmptyCall, serviceImpl.EmptyCall) .AddMethod(__Method_EmptyCall, serviceImpl.EmptyCall)
.AddMethod(__Method_UnaryCall, serviceImpl.UnaryCall) .AddMethod(__Method_UnaryCall, serviceImpl.UnaryCall)
.AddMethod(__Method_CacheableUnaryCall, serviceImpl.CacheableUnaryCall)
.AddMethod(__Method_StreamingOutputCall, serviceImpl.StreamingOutputCall) .AddMethod(__Method_StreamingOutputCall, serviceImpl.StreamingOutputCall)
.AddMethod(__Method_StreamingInputCall, serviceImpl.StreamingInputCall) .AddMethod(__Method_StreamingInputCall, serviceImpl.StreamingInputCall)
.AddMethod(__Method_FullDuplexCall, serviceImpl.FullDuplexCall) .AddMethod(__Method_FullDuplexCall, serviceImpl.FullDuplexCall)
.AddMethod(__Method_HalfDuplexCall, serviceImpl.HalfDuplexCall).Build(); .AddMethod(__Method_HalfDuplexCall, serviceImpl.HalfDuplexCall)
.AddMethod(__Method_UnimplementedCall, serviceImpl.UnimplementedCall).Build();
} }
} }

Loading…
Cancel
Save