mirror of https://github.com/grpc/grpc-java.git
Implement unimplemented_method test
This commit is contained in:
parent
5ade1b726f
commit
7fc86e5549
|
|
@ -0,0 +1,151 @@
|
|||
package io.grpc.testing.integration;
|
||||
|
||||
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
|
||||
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.futureUnaryCall;
|
||||
import static io.grpc.MethodDescriptor.generateFullMethodName;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
||||
|
||||
@javax.annotation.Generated("by gRPC proto compiler")
|
||||
public class UnimplementedServiceGrpc {
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
public static final io.grpc.MethodDescriptor<com.google.protobuf.EmptyProtos.Empty,
|
||||
com.google.protobuf.EmptyProtos.Empty> METHOD_UNIMPLEMENTED_CALL =
|
||||
io.grpc.MethodDescriptor.create(
|
||||
io.grpc.MethodDescriptor.MethodType.UNARY,
|
||||
generateFullMethodName(
|
||||
"grpc.testing.UnimplementedService", "UnimplementedCall"),
|
||||
io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.EmptyProtos.Empty.parser()),
|
||||
io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.EmptyProtos.Empty.parser()));
|
||||
|
||||
public static UnimplementedServiceStub newStub(io.grpc.Channel channel) {
|
||||
return new UnimplementedServiceStub(channel);
|
||||
}
|
||||
|
||||
public static UnimplementedServiceBlockingStub newBlockingStub(
|
||||
io.grpc.Channel channel) {
|
||||
return new UnimplementedServiceBlockingStub(channel);
|
||||
}
|
||||
|
||||
public static UnimplementedServiceFutureStub newFutureStub(
|
||||
io.grpc.Channel channel) {
|
||||
return new UnimplementedServiceFutureStub(channel);
|
||||
}
|
||||
|
||||
public static interface UnimplementedService {
|
||||
|
||||
public void unimplementedCall(com.google.protobuf.EmptyProtos.Empty request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.EmptyProtos.Empty> responseObserver);
|
||||
}
|
||||
|
||||
public static interface UnimplementedServiceBlockingClient {
|
||||
|
||||
public com.google.protobuf.EmptyProtos.Empty unimplementedCall(com.google.protobuf.EmptyProtos.Empty request);
|
||||
}
|
||||
|
||||
public static interface UnimplementedServiceFutureClient {
|
||||
|
||||
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.EmptyProtos.Empty> unimplementedCall(
|
||||
com.google.protobuf.EmptyProtos.Empty request);
|
||||
}
|
||||
|
||||
public static class UnimplementedServiceStub extends io.grpc.stub.AbstractStub<UnimplementedServiceStub>
|
||||
implements UnimplementedService {
|
||||
private UnimplementedServiceStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private UnimplementedServiceStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected UnimplementedServiceStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new UnimplementedServiceStub(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void unimplementedCall(com.google.protobuf.EmptyProtos.Empty request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.EmptyProtos.Empty> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
channel.newCall(METHOD_UNIMPLEMENTED_CALL, callOptions), request, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnimplementedServiceBlockingStub extends io.grpc.stub.AbstractStub<UnimplementedServiceBlockingStub>
|
||||
implements UnimplementedServiceBlockingClient {
|
||||
private UnimplementedServiceBlockingStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private UnimplementedServiceBlockingStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected UnimplementedServiceBlockingStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new UnimplementedServiceBlockingStub(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.EmptyProtos.Empty unimplementedCall(com.google.protobuf.EmptyProtos.Empty request) {
|
||||
return blockingUnaryCall(
|
||||
channel.newCall(METHOD_UNIMPLEMENTED_CALL, callOptions), request);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnimplementedServiceFutureStub extends io.grpc.stub.AbstractStub<UnimplementedServiceFutureStub>
|
||||
implements UnimplementedServiceFutureClient {
|
||||
private UnimplementedServiceFutureStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private UnimplementedServiceFutureStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected UnimplementedServiceFutureStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new UnimplementedServiceFutureStub(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.EmptyProtos.Empty> unimplementedCall(
|
||||
com.google.protobuf.EmptyProtos.Empty request) {
|
||||
return futureUnaryCall(
|
||||
channel.newCall(METHOD_UNIMPLEMENTED_CALL, callOptions), request);
|
||||
}
|
||||
}
|
||||
|
||||
public static io.grpc.ServerServiceDefinition bindService(
|
||||
final UnimplementedService serviceImpl) {
|
||||
return io.grpc.ServerServiceDefinition.builder("grpc.testing.UnimplementedService")
|
||||
.addMethod(io.grpc.ServerMethodDefinition.create(
|
||||
METHOD_UNIMPLEMENTED_CALL,
|
||||
asyncUnaryCall(
|
||||
new io.grpc.stub.ServerCalls.UnaryMethod<
|
||||
com.google.protobuf.EmptyProtos.Empty,
|
||||
com.google.protobuf.EmptyProtos.Empty>() {
|
||||
@java.lang.Override
|
||||
public void invoke(
|
||||
com.google.protobuf.EmptyProtos.Empty request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.EmptyProtos.Empty> responseObserver) {
|
||||
serviceImpl.unimplementedCall(request, responseObserver);
|
||||
}
|
||||
}))).build();
|
||||
}
|
||||
}
|
||||
|
|
@ -34,12 +34,14 @@ public final class Test {
|
|||
").grpc.testing.StreamingOutputCallRespon" +
|
||||
"se(\0010\001\022i\n\016HalfDuplexCall\022(.grpc.testing." +
|
||||
"StreamingOutputCallRequest\032).grpc.testin" +
|
||||
"g.StreamingOutputCallResponse(\0010\0012\177\n\020Rec" +
|
||||
"onnectService\0221\n\005Start\022\023.grpc.testing.Em" +
|
||||
"pty\032\023.grpc.testing.Empty\0228\n\004Stop\022\023.grpc.",
|
||||
"testing.Empty\032\033.grpc.testing.ReconnectIn" +
|
||||
"foB\035\n\033io.grpc.testing.integrationb\006proto" +
|
||||
"3"
|
||||
"g.StreamingOutputCallResponse(\0010\0012U\n\024Uni" +
|
||||
"mplementedService\022=\n\021UnimplementedCall\022\023" +
|
||||
".grpc.testing.Empty\032\023.grpc.testing.Empty",
|
||||
"2\177\n\020ReconnectService\0221\n\005Start\022\023.grpc.tes" +
|
||||
"ting.Empty\032\023.grpc.testing.Empty\0228\n\004Stop\022" +
|
||||
"\023.grpc.testing.Empty\032\033.grpc.testing.Reco" +
|
||||
"nnectInfoB\035\n\033io.grpc.testing.integration" +
|
||||
"b\006proto3"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import io.grpc.Metadata;
|
|||
import io.grpc.ServerImpl;
|
||||
import io.grpc.ServerInterceptors;
|
||||
import io.grpc.Status;
|
||||
import io.grpc.StatusRuntimeException;
|
||||
import io.grpc.auth.ClientAuthInterceptor;
|
||||
import io.grpc.internal.GrpcUtil;
|
||||
import io.grpc.protobuf.ProtoUtils;
|
||||
|
|
@ -812,6 +813,19 @@ public abstract class AbstractTransportTest {
|
|||
authScope.contains(response.getOauthScope()));
|
||||
}
|
||||
|
||||
/** Sends an rpc to an unimplemented method on the server. */
|
||||
@Test(timeout = 10000)
|
||||
public void unimplementedMethod() {
|
||||
UnimplementedServiceGrpc.UnimplementedServiceBlockingStub stub =
|
||||
UnimplementedServiceGrpc.newBlockingStub(channel);
|
||||
try {
|
||||
stub.unimplementedCall(Empty.getDefaultInstance());
|
||||
fail();
|
||||
} catch (StatusRuntimeException e) {
|
||||
assertEquals(Status.UNIMPLEMENTED.getCode(), e.getStatus().getCode());
|
||||
}
|
||||
}
|
||||
|
||||
protected static void assertSuccess(StreamRecorder<?> recorder) {
|
||||
if (recorder.getError() != null) {
|
||||
throw new AssertionError(recorder.getError());
|
||||
|
|
|
|||
|
|
@ -72,6 +72,13 @@ service TestService {
|
|||
returns (stream StreamingOutputCallResponse);
|
||||
}
|
||||
|
||||
// A simple service NOT implemented at servers so clients can test for
|
||||
// that case.
|
||||
service UnimplementedService {
|
||||
// A call that no server should implement
|
||||
rpc UnimplementedCall(grpc.testing.Empty) returns(grpc.testing.Empty);
|
||||
}
|
||||
|
||||
// A service used to control reconnect server.
|
||||
service ReconnectService {
|
||||
rpc Start(grpc.testing.Empty) returns (grpc.testing.Empty);
|
||||
|
|
|
|||
Loading…
Reference in New Issue