mirror of https://github.com/grpc/grpc-java.git
all: migrate .proto files from testing-proto to interop-testing
and provide a simple protobuf service for test in testing-proto instead.
This commit is contained in:
parent
2f6e2c87ab
commit
0a36c9d8a3
|
|
@ -3,6 +3,16 @@ apply plugin: 'application'
|
|||
description = "gRPC: Integration Testing"
|
||||
startScripts.enabled = false
|
||||
|
||||
// Add dependency on the protobuf plugin
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath libraries.protobuf_plugin
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':grpc-auth'),
|
||||
project(':grpc-core'),
|
||||
|
|
@ -11,13 +21,14 @@ dependencies {
|
|||
project(':grpc-protobuf'),
|
||||
project(':grpc-stub'),
|
||||
project(':grpc-testing'),
|
||||
project(':grpc-testing-proto'),
|
||||
libraries.junit,
|
||||
libraries.mockito,
|
||||
libraries.netty_tcnative,
|
||||
libraries.oauth_client
|
||||
}
|
||||
|
||||
configureProtoCompilation()
|
||||
|
||||
test {
|
||||
// For the automated tests, use Jetty ALPN.
|
||||
jvmArgs "-javaagent:" + configurations.alpnagent.asPath
|
||||
|
|
@ -78,3 +89,11 @@ applicationDistribution.into("bin") {
|
|||
from(http2_client)
|
||||
fileMode = 0755
|
||||
}
|
||||
|
||||
// Let intellij projects refer to generated code
|
||||
idea {
|
||||
module {
|
||||
sourceDirs += file("${projectDir}/src/generated/main/java")
|
||||
sourceDirs += file("${projectDir}/src/generated/main/grpc")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,407 @@
|
|||
package io.grpc.testing.protobuf;
|
||||
|
||||
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;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* A simple service for test.
|
||||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.6.0-SNAPSHOT)",
|
||||
comments = "Source: io/grpc/testing/protobuf/simpleservice.proto")
|
||||
public final class SimpleServiceGrpc {
|
||||
|
||||
private SimpleServiceGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "grpc.testing.SimpleService";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
|
||||
public static final io.grpc.MethodDescriptor<io.grpc.testing.protobuf.SimpleRequest,
|
||||
io.grpc.testing.protobuf.SimpleResponse> METHOD_UNARY_RPC =
|
||||
io.grpc.MethodDescriptor.<io.grpc.testing.protobuf.SimpleRequest, io.grpc.testing.protobuf.SimpleResponse>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(
|
||||
"grpc.testing.SimpleService", "UnaryRpc"))
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.grpc.testing.protobuf.SimpleRequest.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.grpc.testing.protobuf.SimpleResponse.getDefaultInstance()))
|
||||
.build();
|
||||
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
|
||||
public static final io.grpc.MethodDescriptor<io.grpc.testing.protobuf.SimpleRequest,
|
||||
io.grpc.testing.protobuf.SimpleResponse> METHOD_CLIENT_STREAMING_RPC =
|
||||
io.grpc.MethodDescriptor.<io.grpc.testing.protobuf.SimpleRequest, io.grpc.testing.protobuf.SimpleResponse>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
|
||||
.setFullMethodName(generateFullMethodName(
|
||||
"grpc.testing.SimpleService", "ClientStreamingRpc"))
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.grpc.testing.protobuf.SimpleRequest.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.grpc.testing.protobuf.SimpleResponse.getDefaultInstance()))
|
||||
.build();
|
||||
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
|
||||
public static final io.grpc.MethodDescriptor<io.grpc.testing.protobuf.SimpleRequest,
|
||||
io.grpc.testing.protobuf.SimpleResponse> METHOD_SERVER_STREAMING_RPC =
|
||||
io.grpc.MethodDescriptor.<io.grpc.testing.protobuf.SimpleRequest, io.grpc.testing.protobuf.SimpleResponse>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
|
||||
.setFullMethodName(generateFullMethodName(
|
||||
"grpc.testing.SimpleService", "ServerStreamingRpc"))
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.grpc.testing.protobuf.SimpleRequest.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.grpc.testing.protobuf.SimpleResponse.getDefaultInstance()))
|
||||
.build();
|
||||
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
|
||||
public static final io.grpc.MethodDescriptor<io.grpc.testing.protobuf.SimpleRequest,
|
||||
io.grpc.testing.protobuf.SimpleResponse> METHOD_BIDI_STREAMING_RPC =
|
||||
io.grpc.MethodDescriptor.<io.grpc.testing.protobuf.SimpleRequest, io.grpc.testing.protobuf.SimpleResponse>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
|
||||
.setFullMethodName(generateFullMethodName(
|
||||
"grpc.testing.SimpleService", "BidiStreamingRpc"))
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.grpc.testing.protobuf.SimpleRequest.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.grpc.testing.protobuf.SimpleResponse.getDefaultInstance()))
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Creates a new async stub that supports all call types for the service
|
||||
*/
|
||||
public static SimpleServiceStub newStub(io.grpc.Channel channel) {
|
||||
return new SimpleServiceStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
|
||||
*/
|
||||
public static SimpleServiceBlockingStub newBlockingStub(
|
||||
io.grpc.Channel channel) {
|
||||
return new SimpleServiceBlockingStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ListenableFuture-style stub that supports unary calls on the service
|
||||
*/
|
||||
public static SimpleServiceFutureStub newFutureStub(
|
||||
io.grpc.Channel channel) {
|
||||
return new SimpleServiceFutureStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* A simple service for test.
|
||||
* </pre>
|
||||
*/
|
||||
public static abstract class SimpleServiceImplBase implements io.grpc.BindableService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple unary RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public void unaryRpc(io.grpc.testing.protobuf.SimpleRequest request,
|
||||
io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(METHOD_UNARY_RPC, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple client-to-server streaming RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleRequest> clientStreamingRpc(
|
||||
io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse> responseObserver) {
|
||||
return asyncUnimplementedStreamingCall(METHOD_CLIENT_STREAMING_RPC, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple server-to-client streaming RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public void serverStreamingRpc(io.grpc.testing.protobuf.SimpleRequest request,
|
||||
io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(METHOD_SERVER_STREAMING_RPC, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple bidirectional streaming RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleRequest> bidiStreamingRpc(
|
||||
io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse> responseObserver) {
|
||||
return asyncUnimplementedStreamingCall(METHOD_BIDI_STREAMING_RPC, responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
METHOD_UNARY_RPC,
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.grpc.testing.protobuf.SimpleRequest,
|
||||
io.grpc.testing.protobuf.SimpleResponse>(
|
||||
this, METHODID_UNARY_RPC)))
|
||||
.addMethod(
|
||||
METHOD_CLIENT_STREAMING_RPC,
|
||||
asyncClientStreamingCall(
|
||||
new MethodHandlers<
|
||||
io.grpc.testing.protobuf.SimpleRequest,
|
||||
io.grpc.testing.protobuf.SimpleResponse>(
|
||||
this, METHODID_CLIENT_STREAMING_RPC)))
|
||||
.addMethod(
|
||||
METHOD_SERVER_STREAMING_RPC,
|
||||
asyncServerStreamingCall(
|
||||
new MethodHandlers<
|
||||
io.grpc.testing.protobuf.SimpleRequest,
|
||||
io.grpc.testing.protobuf.SimpleResponse>(
|
||||
this, METHODID_SERVER_STREAMING_RPC)))
|
||||
.addMethod(
|
||||
METHOD_BIDI_STREAMING_RPC,
|
||||
asyncBidiStreamingCall(
|
||||
new MethodHandlers<
|
||||
io.grpc.testing.protobuf.SimpleRequest,
|
||||
io.grpc.testing.protobuf.SimpleResponse>(
|
||||
this, METHODID_BIDI_STREAMING_RPC)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* A simple service for test.
|
||||
* </pre>
|
||||
*/
|
||||
public static final class SimpleServiceStub extends io.grpc.stub.AbstractStub<SimpleServiceStub> {
|
||||
private SimpleServiceStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private SimpleServiceStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected SimpleServiceStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new SimpleServiceStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple unary RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public void unaryRpc(io.grpc.testing.protobuf.SimpleRequest request,
|
||||
io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(METHOD_UNARY_RPC, getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple client-to-server streaming RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleRequest> clientStreamingRpc(
|
||||
io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse> responseObserver) {
|
||||
return asyncClientStreamingCall(
|
||||
getChannel().newCall(METHOD_CLIENT_STREAMING_RPC, getCallOptions()), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple server-to-client streaming RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public void serverStreamingRpc(io.grpc.testing.protobuf.SimpleRequest request,
|
||||
io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse> responseObserver) {
|
||||
asyncServerStreamingCall(
|
||||
getChannel().newCall(METHOD_SERVER_STREAMING_RPC, getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple bidirectional streaming RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleRequest> bidiStreamingRpc(
|
||||
io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse> responseObserver) {
|
||||
return asyncBidiStreamingCall(
|
||||
getChannel().newCall(METHOD_BIDI_STREAMING_RPC, getCallOptions()), responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* A simple service for test.
|
||||
* </pre>
|
||||
*/
|
||||
public static final class SimpleServiceBlockingStub extends io.grpc.stub.AbstractStub<SimpleServiceBlockingStub> {
|
||||
private SimpleServiceBlockingStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private SimpleServiceBlockingStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected SimpleServiceBlockingStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new SimpleServiceBlockingStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple unary RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public io.grpc.testing.protobuf.SimpleResponse unaryRpc(io.grpc.testing.protobuf.SimpleRequest request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), METHOD_UNARY_RPC, getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple server-to-client streaming RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public java.util.Iterator<io.grpc.testing.protobuf.SimpleResponse> serverStreamingRpc(
|
||||
io.grpc.testing.protobuf.SimpleRequest request) {
|
||||
return blockingServerStreamingCall(
|
||||
getChannel(), METHOD_SERVER_STREAMING_RPC, getCallOptions(), request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* A simple service for test.
|
||||
* </pre>
|
||||
*/
|
||||
public static final class SimpleServiceFutureStub extends io.grpc.stub.AbstractStub<SimpleServiceFutureStub> {
|
||||
private SimpleServiceFutureStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private SimpleServiceFutureStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected SimpleServiceFutureStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new SimpleServiceFutureStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Simple unary RPC.
|
||||
* </pre>
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.protobuf.SimpleResponse> unaryRpc(
|
||||
io.grpc.testing.protobuf.SimpleRequest request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(METHOD_UNARY_RPC, getCallOptions()), request);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int METHODID_UNARY_RPC = 0;
|
||||
private static final int METHODID_SERVER_STREAMING_RPC = 1;
|
||||
private static final int METHODID_CLIENT_STREAMING_RPC = 2;
|
||||
private static final int METHODID_BIDI_STREAMING_RPC = 3;
|
||||
|
||||
private static final class MethodHandlers<Req, Resp> implements
|
||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
|
||||
private final SimpleServiceImplBase serviceImpl;
|
||||
private final int methodId;
|
||||
|
||||
MethodHandlers(SimpleServiceImplBase serviceImpl, int methodId) {
|
||||
this.serviceImpl = serviceImpl;
|
||||
this.methodId = methodId;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("unchecked")
|
||||
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
case METHODID_UNARY_RPC:
|
||||
serviceImpl.unaryRpc((io.grpc.testing.protobuf.SimpleRequest) request,
|
||||
(io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse>) responseObserver);
|
||||
break;
|
||||
case METHODID_SERVER_STREAMING_RPC:
|
||||
serviceImpl.serverStreamingRpc((io.grpc.testing.protobuf.SimpleRequest) request,
|
||||
(io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse>) responseObserver);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("unchecked")
|
||||
public io.grpc.stub.StreamObserver<Req> invoke(
|
||||
io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
case METHODID_CLIENT_STREAMING_RPC:
|
||||
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.clientStreamingRpc(
|
||||
(io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse>) responseObserver);
|
||||
case METHODID_BIDI_STREAMING_RPC:
|
||||
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.bidiStreamingRpc(
|
||||
(io.grpc.stub.StreamObserver<io.grpc.testing.protobuf.SimpleResponse>) responseObserver);
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class SimpleServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.getDescriptor();
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
|
||||
|
||||
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
|
||||
io.grpc.ServiceDescriptor result = serviceDescriptor;
|
||||
if (result == null) {
|
||||
synchronized (SimpleServiceGrpc.class) {
|
||||
result = serviceDescriptor;
|
||||
if (result == null) {
|
||||
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
|
||||
.setSchemaDescriptor(new SimpleServiceDescriptorSupplier())
|
||||
.addMethod(METHOD_UNARY_RPC)
|
||||
.addMethod(METHOD_CLIENT_STREAMING_RPC)
|
||||
.addMethod(METHOD_SERVER_STREAMING_RPC)
|
||||
.addMethod(METHOD_BIDI_STREAMING_RPC)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/grpc/testing/protobuf/simpleservice.proto
|
||||
|
||||
package io.grpc.testing.protobuf;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* A simple request message type for test.
|
||||
* </pre>
|
||||
*
|
||||
* Protobuf type {@code grpc.testing.SimpleRequest}
|
||||
*/
|
||||
public final class SimpleRequest extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:grpc.testing.SimpleRequest)
|
||||
SimpleRequestOrBuilder {
|
||||
// Use SimpleRequest.newBuilder() to construct.
|
||||
private SimpleRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private SimpleRequest() {
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
|
||||
}
|
||||
private SimpleRequest(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
default: {
|
||||
if (!input.skipField(tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleRequest_descriptor;
|
||||
}
|
||||
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleRequest_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.grpc.testing.protobuf.SimpleRequest.class, io.grpc.testing.protobuf.SimpleRequest.Builder.class);
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
}
|
||||
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.grpc.testing.protobuf.SimpleRequest)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.grpc.testing.protobuf.SimpleRequest other = (io.grpc.testing.protobuf.SimpleRequest) obj;
|
||||
|
||||
boolean result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleRequest parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.grpc.testing.protobuf.SimpleRequest prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* A simple request message type for test.
|
||||
* </pre>
|
||||
*
|
||||
* Protobuf type {@code grpc.testing.SimpleRequest}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:grpc.testing.SimpleRequest)
|
||||
io.grpc.testing.protobuf.SimpleRequestOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleRequest_descriptor;
|
||||
}
|
||||
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleRequest_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.grpc.testing.protobuf.SimpleRequest.class, io.grpc.testing.protobuf.SimpleRequest.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.grpc.testing.protobuf.SimpleRequest.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleRequest_descriptor;
|
||||
}
|
||||
|
||||
public io.grpc.testing.protobuf.SimpleRequest getDefaultInstanceForType() {
|
||||
return io.grpc.testing.protobuf.SimpleRequest.getDefaultInstance();
|
||||
}
|
||||
|
||||
public io.grpc.testing.protobuf.SimpleRequest build() {
|
||||
io.grpc.testing.protobuf.SimpleRequest result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public io.grpc.testing.protobuf.SimpleRequest buildPartial() {
|
||||
io.grpc.testing.protobuf.SimpleRequest result = new io.grpc.testing.protobuf.SimpleRequest(this);
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
public Builder clone() {
|
||||
return (Builder) super.clone();
|
||||
}
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
Object value) {
|
||||
return (Builder) super.setField(field, value);
|
||||
}
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return (Builder) super.clearField(field);
|
||||
}
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return (Builder) super.clearOneof(oneof);
|
||||
}
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, Object value) {
|
||||
return (Builder) super.setRepeatedField(field, index, value);
|
||||
}
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
Object value) {
|
||||
return (Builder) super.addRepeatedField(field, value);
|
||||
}
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.grpc.testing.protobuf.SimpleRequest) {
|
||||
return mergeFrom((io.grpc.testing.protobuf.SimpleRequest)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.grpc.testing.protobuf.SimpleRequest other) {
|
||||
if (other == io.grpc.testing.protobuf.SimpleRequest.getDefaultInstance()) return this;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.grpc.testing.protobuf.SimpleRequest parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.grpc.testing.protobuf.SimpleRequest) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:grpc.testing.SimpleRequest)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:grpc.testing.SimpleRequest)
|
||||
private static final io.grpc.testing.protobuf.SimpleRequest DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.grpc.testing.protobuf.SimpleRequest();
|
||||
}
|
||||
|
||||
public static io.grpc.testing.protobuf.SimpleRequest getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<SimpleRequest>
|
||||
PARSER = new com.google.protobuf.AbstractParser<SimpleRequest>() {
|
||||
public SimpleRequest parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new SimpleRequest(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<SimpleRequest> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<SimpleRequest> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
public io.grpc.testing.protobuf.SimpleRequest getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/grpc/testing/protobuf/simpleservice.proto
|
||||
|
||||
package io.grpc.testing.protobuf;
|
||||
|
||||
public interface SimpleRequestOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:grpc.testing.SimpleRequest)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
}
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/grpc/testing/protobuf/simpleservice.proto
|
||||
|
||||
package io.grpc.testing.protobuf;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* A simple response message type for test.
|
||||
* </pre>
|
||||
*
|
||||
* Protobuf type {@code grpc.testing.SimpleResponse}
|
||||
*/
|
||||
public final class SimpleResponse extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:grpc.testing.SimpleResponse)
|
||||
SimpleResponseOrBuilder {
|
||||
// Use SimpleResponse.newBuilder() to construct.
|
||||
private SimpleResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private SimpleResponse() {
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet
|
||||
getUnknownFields() {
|
||||
return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
|
||||
}
|
||||
private SimpleResponse(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
default: {
|
||||
if (!input.skipField(tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(
|
||||
e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleResponse_descriptor;
|
||||
}
|
||||
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleResponse_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.grpc.testing.protobuf.SimpleResponse.class, io.grpc.testing.protobuf.SimpleResponse.Builder.class);
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
}
|
||||
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof io.grpc.testing.protobuf.SimpleResponse)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
io.grpc.testing.protobuf.SimpleResponse other = (io.grpc.testing.protobuf.SimpleResponse) obj;
|
||||
|
||||
boolean result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static io.grpc.testing.protobuf.SimpleResponse parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(io.grpc.testing.protobuf.SimpleResponse prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* <pre>
|
||||
* A simple response message type for test.
|
||||
* </pre>
|
||||
*
|
||||
* Protobuf type {@code grpc.testing.SimpleResponse}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:grpc.testing.SimpleResponse)
|
||||
io.grpc.testing.protobuf.SimpleResponseOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleResponse_descriptor;
|
||||
}
|
||||
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleResponse_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
io.grpc.testing.protobuf.SimpleResponse.class, io.grpc.testing.protobuf.SimpleResponse.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using io.grpc.testing.protobuf.SimpleResponse.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3
|
||||
.alwaysUseFieldBuilders) {
|
||||
}
|
||||
}
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return io.grpc.testing.protobuf.SimpleServiceProto.internal_static_grpc_testing_SimpleResponse_descriptor;
|
||||
}
|
||||
|
||||
public io.grpc.testing.protobuf.SimpleResponse getDefaultInstanceForType() {
|
||||
return io.grpc.testing.protobuf.SimpleResponse.getDefaultInstance();
|
||||
}
|
||||
|
||||
public io.grpc.testing.protobuf.SimpleResponse build() {
|
||||
io.grpc.testing.protobuf.SimpleResponse result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public io.grpc.testing.protobuf.SimpleResponse buildPartial() {
|
||||
io.grpc.testing.protobuf.SimpleResponse result = new io.grpc.testing.protobuf.SimpleResponse(this);
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
public Builder clone() {
|
||||
return (Builder) super.clone();
|
||||
}
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
Object value) {
|
||||
return (Builder) super.setField(field, value);
|
||||
}
|
||||
public Builder clearField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return (Builder) super.clearField(field);
|
||||
}
|
||||
public Builder clearOneof(
|
||||
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return (Builder) super.clearOneof(oneof);
|
||||
}
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index, Object value) {
|
||||
return (Builder) super.setRepeatedField(field, index, value);
|
||||
}
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
Object value) {
|
||||
return (Builder) super.addRepeatedField(field, value);
|
||||
}
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof io.grpc.testing.protobuf.SimpleResponse) {
|
||||
return mergeFrom((io.grpc.testing.protobuf.SimpleResponse)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(io.grpc.testing.protobuf.SimpleResponse other) {
|
||||
if (other == io.grpc.testing.protobuf.SimpleResponse.getDefaultInstance()) return this;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
io.grpc.testing.protobuf.SimpleResponse parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage = (io.grpc.testing.protobuf.SimpleResponse) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:grpc.testing.SimpleResponse)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:grpc.testing.SimpleResponse)
|
||||
private static final io.grpc.testing.protobuf.SimpleResponse DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new io.grpc.testing.protobuf.SimpleResponse();
|
||||
}
|
||||
|
||||
public static io.grpc.testing.protobuf.SimpleResponse getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<SimpleResponse>
|
||||
PARSER = new com.google.protobuf.AbstractParser<SimpleResponse>() {
|
||||
public SimpleResponse parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new SimpleResponse(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<SimpleResponse> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<SimpleResponse> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
public io.grpc.testing.protobuf.SimpleResponse getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/grpc/testing/protobuf/simpleservice.proto
|
||||
|
||||
package io.grpc.testing.protobuf;
|
||||
|
||||
public interface SimpleResponseOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:grpc.testing.SimpleResponse)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: io/grpc/testing/protobuf/simpleservice.proto
|
||||
|
||||
package io.grpc.testing.protobuf;
|
||||
|
||||
public final class SimpleServiceProto {
|
||||
private SimpleServiceProto() {}
|
||||
public static void registerAllExtensions(
|
||||
com.google.protobuf.ExtensionRegistryLite registry) {
|
||||
}
|
||||
|
||||
public static void registerAllExtensions(
|
||||
com.google.protobuf.ExtensionRegistry registry) {
|
||||
registerAllExtensions(
|
||||
(com.google.protobuf.ExtensionRegistryLite) registry);
|
||||
}
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_grpc_testing_SimpleRequest_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_grpc_testing_SimpleRequest_fieldAccessorTable;
|
||||
static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_grpc_testing_SimpleResponse_descriptor;
|
||||
static final
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_grpc_testing_SimpleResponse_fieldAccessorTable;
|
||||
|
||||
public static com.google.protobuf.Descriptors.FileDescriptor
|
||||
getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
private static com.google.protobuf.Descriptors.FileDescriptor
|
||||
descriptor;
|
||||
static {
|
||||
java.lang.String[] descriptorData = {
|
||||
"\n,io/grpc/testing/protobuf/simpleservice" +
|
||||
".proto\022\014grpc.testing\"\017\n\rSimpleRequest\"\020\n" +
|
||||
"\016SimpleResponse2\327\002\n\rSimpleService\022G\n\010Una" +
|
||||
"ryRpc\022\033.grpc.testing.SimpleRequest\032\034.grp" +
|
||||
"c.testing.SimpleResponse\"\000\022S\n\022ClientStre" +
|
||||
"amingRpc\022\033.grpc.testing.SimpleRequest\032\034." +
|
||||
"grpc.testing.SimpleResponse\"\000(\001\022S\n\022Serve" +
|
||||
"rStreamingRpc\022\033.grpc.testing.SimpleReque" +
|
||||
"st\032\034.grpc.testing.SimpleResponse\"\0000\001\022S\n\020" +
|
||||
"BidiStreamingRpc\022\033.grpc.testing.SimpleRe",
|
||||
"quest\032\034.grpc.testing.SimpleResponse\"\000(\0010" +
|
||||
"\001B0\n\030io.grpc.testing.protobufB\022SimpleSer" +
|
||||
"viceProtoP\001b\006proto3"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
|
||||
public com.google.protobuf.ExtensionRegistry assignDescriptors(
|
||||
com.google.protobuf.Descriptors.FileDescriptor root) {
|
||||
descriptor = root;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor
|
||||
.internalBuildGeneratedFileFrom(descriptorData,
|
||||
new com.google.protobuf.Descriptors.FileDescriptor[] {
|
||||
}, assigner);
|
||||
internal_static_grpc_testing_SimpleRequest_descriptor =
|
||||
getDescriptor().getMessageTypes().get(0);
|
||||
internal_static_grpc_testing_SimpleRequest_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_grpc_testing_SimpleRequest_descriptor,
|
||||
new java.lang.String[] { });
|
||||
internal_static_grpc_testing_SimpleResponse_descriptor =
|
||||
getDescriptor().getMessageTypes().get(1);
|
||||
internal_static_grpc_testing_SimpleResponse_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_grpc_testing_SimpleResponse_descriptor,
|
||||
new java.lang.String[] { });
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(outer_class_scope)
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2017, gRPC Authors
|
||||
// All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// An integration test service that covers all the method signature permutations
|
||||
// of unary/streaming requests/responses.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package grpc.testing;
|
||||
|
||||
option java_package = "io.grpc.testing.protobuf";
|
||||
option java_outer_classname = "SimpleServiceProto";
|
||||
option java_multiple_files = true;
|
||||
|
||||
// A simple service for test.
|
||||
service SimpleService {
|
||||
// Simple unary RPC.
|
||||
rpc UnaryRpc (SimpleRequest) returns (SimpleResponse) {}
|
||||
|
||||
// Simple client-to-server streaming RPC.
|
||||
rpc ClientStreamingRpc (stream SimpleRequest) returns (SimpleResponse) {}
|
||||
|
||||
// Simple server-to-client streaming RPC.
|
||||
rpc ServerStreamingRpc (SimpleRequest) returns (stream SimpleResponse) {}
|
||||
|
||||
// Simple bidirectional streaming RPC.
|
||||
rpc BidiStreamingRpc (stream SimpleRequest) returns (stream SimpleResponse) {}
|
||||
}
|
||||
|
||||
// A simple request message type for test.
|
||||
message SimpleRequest {
|
||||
}
|
||||
|
||||
// A simple response message type for test.
|
||||
message SimpleResponse {
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright 2017, gRPC Authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.grpc.testing.protobuf;
|
||||
|
||||
import static io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING;
|
||||
import static io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING;
|
||||
import static io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING;
|
||||
import static io.grpc.MethodDescriptor.MethodType.UNARY;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import io.grpc.MethodDescriptor;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Test to verify that the proto file simpleservice.proto generates the expected service. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class SimpleServiceTest {
|
||||
@Test
|
||||
public void serviceDescriptor() {
|
||||
assertEquals("grpc.testing.SimpleService", SimpleServiceGrpc.getServiceDescriptor().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serviceMethodDescriotrs() {
|
||||
MethodDescriptor<SimpleRequest, SimpleResponse> genericTypeShouldMatchWhenAssigned;
|
||||
|
||||
genericTypeShouldMatchWhenAssigned = SimpleServiceGrpc.METHOD_UNARY_RPC;
|
||||
assertEquals(UNARY, genericTypeShouldMatchWhenAssigned.getType());
|
||||
|
||||
genericTypeShouldMatchWhenAssigned = SimpleServiceGrpc.METHOD_CLIENT_STREAMING_RPC;
|
||||
assertEquals(CLIENT_STREAMING, genericTypeShouldMatchWhenAssigned.getType());
|
||||
|
||||
genericTypeShouldMatchWhenAssigned = SimpleServiceGrpc.METHOD_SERVER_STREAMING_RPC;
|
||||
assertEquals(SERVER_STREAMING, genericTypeShouldMatchWhenAssigned.getType());
|
||||
|
||||
genericTypeShouldMatchWhenAssigned = SimpleServiceGrpc.METHOD_BIDI_STREAMING_RPC;
|
||||
assertEquals(BIDI_STREAMING, genericTypeShouldMatchWhenAssigned.getType());
|
||||
}
|
||||
}
|
||||
|
|
@ -18,15 +18,13 @@ package io.grpc.testing;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.EmptyProtos;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.Server;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import io.grpc.testing.integration.Messages;
|
||||
import io.grpc.testing.integration.TestServiceGrpc;
|
||||
import io.grpc.testing.protobuf.SimpleRequest;
|
||||
import io.grpc.testing.protobuf.SimpleResponse;
|
||||
import io.grpc.testing.protobuf.SimpleServiceGrpc;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
|
@ -59,21 +57,15 @@ public class GrpcServerRuleTest {
|
|||
|
||||
grpcServerRule1.getServiceRegistry().addService(testService);
|
||||
|
||||
TestServiceGrpc.TestServiceBlockingStub stub =
|
||||
TestServiceGrpc.newBlockingStub(grpcServerRule1.getChannel());
|
||||
SimpleServiceGrpc.SimpleServiceBlockingStub stub =
|
||||
SimpleServiceGrpc.newBlockingStub(grpcServerRule1.getChannel());
|
||||
|
||||
Messages.SimpleRequest request1 = Messages.SimpleRequest.newBuilder()
|
||||
.setPayload(Messages.Payload.newBuilder().setBody(
|
||||
ByteString.copyFromUtf8(UUID.randomUUID().toString())))
|
||||
.build();
|
||||
SimpleRequest request1 = SimpleRequest.getDefaultInstance();
|
||||
|
||||
Messages.SimpleRequest request2 = Messages.SimpleRequest.newBuilder()
|
||||
.setPayload(Messages.Payload.newBuilder().setBody(
|
||||
ByteString.copyFromUtf8(UUID.randomUUID().toString())))
|
||||
.build();
|
||||
SimpleRequest request2 = SimpleRequest.newBuilder().build();
|
||||
|
||||
stub.unaryCall(request1);
|
||||
stub.unaryCall(request2);
|
||||
stub.unaryRpc(request1);
|
||||
stub.unaryRpc(request2);
|
||||
|
||||
assertThat(testService.unaryCallRequests).containsExactly(request1, request2);
|
||||
}
|
||||
|
|
@ -84,14 +76,12 @@ public class GrpcServerRuleTest {
|
|||
|
||||
grpcServerRule1.getServiceRegistry().addService(testService);
|
||||
|
||||
TestServiceGrpc.TestServiceBlockingStub stub =
|
||||
TestServiceGrpc.newBlockingStub(grpcServerRule1.getChannel());
|
||||
SimpleServiceGrpc.SimpleServiceBlockingStub stub =
|
||||
SimpleServiceGrpc.newBlockingStub(grpcServerRule1.getChannel());
|
||||
|
||||
// Make a garbage request first due to https://github.com/grpc/grpc-java/issues/2444.
|
||||
stub.emptyCall(EmptyProtos.Empty.newBuilder().build());
|
||||
stub.emptyCall(EmptyProtos.Empty.newBuilder().build());
|
||||
stub.serverStreamingRpc(SimpleRequest.getDefaultInstance());
|
||||
|
||||
assertThat(testService.lastEmptyCallRequestThread).isNotEqualTo(Thread.currentThread());
|
||||
assertThat(testService.lastServerStreamingRpcThread).isNotEqualTo(Thread.currentThread());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
|
|
@ -117,21 +107,15 @@ public class GrpcServerRuleTest {
|
|||
|
||||
grpcServerRule2.getServiceRegistry().addService(testService);
|
||||
|
||||
TestServiceGrpc.TestServiceBlockingStub stub =
|
||||
TestServiceGrpc.newBlockingStub(grpcServerRule2.getChannel());
|
||||
SimpleServiceGrpc.SimpleServiceBlockingStub stub =
|
||||
SimpleServiceGrpc.newBlockingStub(grpcServerRule2.getChannel());
|
||||
|
||||
Messages.SimpleRequest request1 = Messages.SimpleRequest.newBuilder()
|
||||
.setPayload(Messages.Payload.newBuilder().setBody(
|
||||
ByteString.copyFromUtf8(UUID.randomUUID().toString())))
|
||||
.build();
|
||||
SimpleRequest request1 = SimpleRequest.getDefaultInstance();
|
||||
|
||||
Messages.SimpleRequest request2 = Messages.SimpleRequest.newBuilder()
|
||||
.setPayload(Messages.Payload.newBuilder().setBody(
|
||||
ByteString.copyFromUtf8(UUID.randomUUID().toString())))
|
||||
.build();
|
||||
SimpleRequest request2 = SimpleRequest.newBuilder().build();
|
||||
|
||||
stub.unaryCall(request1);
|
||||
stub.unaryCall(request2);
|
||||
stub.unaryRpc(request1);
|
||||
stub.unaryRpc(request2);
|
||||
|
||||
assertThat(testService.unaryCallRequests).containsExactly(request1, request2);
|
||||
}
|
||||
|
|
@ -142,14 +126,12 @@ public class GrpcServerRuleTest {
|
|||
|
||||
grpcServerRule2.getServiceRegistry().addService(testService);
|
||||
|
||||
TestServiceGrpc.TestServiceBlockingStub stub =
|
||||
TestServiceGrpc.newBlockingStub(grpcServerRule2.getChannel());
|
||||
SimpleServiceGrpc.SimpleServiceBlockingStub stub =
|
||||
SimpleServiceGrpc.newBlockingStub(grpcServerRule2.getChannel());
|
||||
|
||||
// Make a garbage request first due to https://github.com/grpc/grpc-java/issues/2444.
|
||||
stub.emptyCall(EmptyProtos.Empty.newBuilder().build());
|
||||
stub.emptyCall(EmptyProtos.Empty.newBuilder().build());
|
||||
stub.serverStreamingRpc(SimpleRequest.getDefaultInstance());
|
||||
|
||||
assertThat(testService.lastEmptyCallRequestThread).isEqualTo(Thread.currentThread());
|
||||
assertThat(testService.lastServerStreamingRpcThread).isEqualTo(Thread.currentThread());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -197,31 +179,31 @@ public class GrpcServerRuleTest {
|
|||
}
|
||||
}
|
||||
|
||||
private static class TestServiceImpl extends TestServiceGrpc.TestServiceImplBase {
|
||||
private static class TestServiceImpl extends SimpleServiceGrpc.SimpleServiceImplBase {
|
||||
|
||||
private final Collection<Messages.SimpleRequest> unaryCallRequests =
|
||||
new ConcurrentLinkedQueue<Messages.SimpleRequest>();
|
||||
private final Collection<SimpleRequest> unaryCallRequests =
|
||||
new ConcurrentLinkedQueue<SimpleRequest>();
|
||||
|
||||
private volatile Thread lastEmptyCallRequestThread;
|
||||
private volatile Thread lastServerStreamingRpcThread;
|
||||
|
||||
@Override
|
||||
public void emptyCall(
|
||||
EmptyProtos.Empty request, StreamObserver<EmptyProtos.Empty> responseObserver) {
|
||||
public void serverStreamingRpc(
|
||||
SimpleRequest request, StreamObserver<SimpleResponse> responseObserver) {
|
||||
|
||||
lastEmptyCallRequestThread = Thread.currentThread();
|
||||
lastServerStreamingRpcThread = Thread.currentThread();
|
||||
|
||||
responseObserver.onNext(EmptyProtos.Empty.newBuilder().build());
|
||||
responseObserver.onNext(SimpleResponse.getDefaultInstance());
|
||||
|
||||
responseObserver.onCompleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unaryCall(
|
||||
Messages.SimpleRequest request, StreamObserver<Messages.SimpleResponse> responseObserver) {
|
||||
public void unaryRpc(
|
||||
SimpleRequest request, StreamObserver<SimpleResponse> responseObserver) {
|
||||
|
||||
unaryCallRequests.add(request);
|
||||
|
||||
responseObserver.onNext(Messages.SimpleResponse.newBuilder().build());
|
||||
responseObserver.onNext(SimpleResponse.getDefaultInstance());
|
||||
|
||||
responseObserver.onCompleted();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue