Skip to content

Commit b01f839

Browse files
committed
Add tests for grpc-core
1 parent ee6b4c9 commit b01f839

File tree

12 files changed

+1667
-0
lines changed

12 files changed

+1667
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gradlew.bat
2+
gradlew
3+
gradle/
4+
build/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
8+
plugins {
9+
id "org.graalvm.internal.tck"
10+
id 'com.google.protobuf' version '0.9.4'
11+
}
12+
13+
String libraryVersion = tck.testedLibraryVersion.get()
14+
15+
dependencies {
16+
testImplementation "io.grpc:grpc-netty:$libraryVersion"
17+
testImplementation "io.grpc:grpc-services:$libraryVersion"
18+
testImplementation "io.grpc:grpc-testing:$libraryVersion"
19+
implementation "io.grpc:grpc-protobuf:$libraryVersion"
20+
implementation "io.grpc:grpc-stub:$libraryVersion"
21+
implementation 'jakarta.annotation:jakarta.annotation-api:1.3.5'
22+
testImplementation 'org.assertj:assertj-core:3.22.0'
23+
}
24+
25+
protobuf {
26+
protoc {
27+
artifact = "com.google.protobuf:protoc:3.25.5"
28+
}
29+
generatedFilesBaseDir = "$projectDir/src/generated"
30+
clean {
31+
delete generatedFilesBaseDir
32+
}
33+
plugins {
34+
grpc {
35+
artifact = "io.grpc:protoc-gen-grpc-java:$libraryVersion"
36+
}
37+
}
38+
generateProtoTasks {
39+
ofSourceSet('main').configureEach {
40+
plugins {
41+
grpc {}
42+
}
43+
}
44+
}
45+
}
46+
47+
checkstyle {
48+
sourceSets = []
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
library.version = 1.69.0
2+
metadata.dir = io.grpc/grpc-core/1.69.0/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pluginManagement {
2+
def tckPath = Objects.requireNonNullElse(
3+
System.getenv("GVM_TCK_TCKDIR"),
4+
"../../../../tck-build-logic"
5+
)
6+
includeBuild(tckPath)
7+
}
8+
9+
plugins {
10+
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT"
11+
}
12+
13+
rootProject.name = 'io.grpc.grpc-netty_tests'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
package grpc;
2+
3+
import static io.grpc.MethodDescriptor.generateFullMethodName;
4+
5+
/**
6+
* <pre>
7+
* The greeting service definition.
8+
* </pre>
9+
*/
10+
@javax.annotation.Generated(
11+
value = "by gRPC proto compiler (version 1.69.0)",
12+
comments = "Source: helloworld.proto")
13+
@io.grpc.stub.annotations.GrpcGenerated
14+
public final class SimpleGrpc {
15+
16+
private SimpleGrpc() {}
17+
18+
public static final java.lang.String SERVICE_NAME = "Simple";
19+
20+
// Static method descriptors that strictly reflect the proto.
21+
private static volatile io.grpc.MethodDescriptor<grpc.HelloRequest,
22+
grpc.HelloReply> getSayHelloMethod;
23+
24+
@io.grpc.stub.annotations.RpcMethod(
25+
fullMethodName = SERVICE_NAME + '/' + "SayHello",
26+
requestType = grpc.HelloRequest.class,
27+
responseType = grpc.HelloReply.class,
28+
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
29+
public static io.grpc.MethodDescriptor<grpc.HelloRequest,
30+
grpc.HelloReply> getSayHelloMethod() {
31+
io.grpc.MethodDescriptor<grpc.HelloRequest, grpc.HelloReply> getSayHelloMethod;
32+
if ((getSayHelloMethod = SimpleGrpc.getSayHelloMethod) == null) {
33+
synchronized (SimpleGrpc.class) {
34+
if ((getSayHelloMethod = SimpleGrpc.getSayHelloMethod) == null) {
35+
SimpleGrpc.getSayHelloMethod = getSayHelloMethod =
36+
io.grpc.MethodDescriptor.<grpc.HelloRequest, grpc.HelloReply>newBuilder()
37+
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
38+
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "SayHello"))
39+
.setSampledToLocalTracing(true)
40+
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
41+
grpc.HelloRequest.getDefaultInstance()))
42+
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
43+
grpc.HelloReply.getDefaultInstance()))
44+
.setSchemaDescriptor(new SimpleMethodDescriptorSupplier("SayHello"))
45+
.build();
46+
}
47+
}
48+
}
49+
return getSayHelloMethod;
50+
}
51+
52+
/**
53+
* Creates a new async stub that supports all call types for the service
54+
*/
55+
public static SimpleStub newStub(io.grpc.Channel channel) {
56+
io.grpc.stub.AbstractStub.StubFactory<SimpleStub> factory =
57+
new io.grpc.stub.AbstractStub.StubFactory<SimpleStub>() {
58+
@java.lang.Override
59+
public SimpleStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
60+
return new SimpleStub(channel, callOptions);
61+
}
62+
};
63+
return SimpleStub.newStub(factory, channel);
64+
}
65+
66+
/**
67+
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
68+
*/
69+
public static SimpleBlockingStub newBlockingStub(
70+
io.grpc.Channel channel) {
71+
io.grpc.stub.AbstractStub.StubFactory<SimpleBlockingStub> factory =
72+
new io.grpc.stub.AbstractStub.StubFactory<SimpleBlockingStub>() {
73+
@java.lang.Override
74+
public SimpleBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
75+
return new SimpleBlockingStub(channel, callOptions);
76+
}
77+
};
78+
return SimpleBlockingStub.newStub(factory, channel);
79+
}
80+
81+
/**
82+
* Creates a new ListenableFuture-style stub that supports unary calls on the service
83+
*/
84+
public static SimpleFutureStub newFutureStub(
85+
io.grpc.Channel channel) {
86+
io.grpc.stub.AbstractStub.StubFactory<SimpleFutureStub> factory =
87+
new io.grpc.stub.AbstractStub.StubFactory<SimpleFutureStub>() {
88+
@java.lang.Override
89+
public SimpleFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
90+
return new SimpleFutureStub(channel, callOptions);
91+
}
92+
};
93+
return SimpleFutureStub.newStub(factory, channel);
94+
}
95+
96+
/**
97+
* <pre>
98+
* The greeting service definition.
99+
* </pre>
100+
*/
101+
public interface AsyncService {
102+
103+
/**
104+
* <pre>
105+
* Sends a greeting
106+
* </pre>
107+
*/
108+
default void sayHello(grpc.HelloRequest request,
109+
io.grpc.stub.StreamObserver<grpc.HelloReply> responseObserver) {
110+
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver);
111+
}
112+
}
113+
114+
/**
115+
* Base class for the server implementation of the service Simple.
116+
* <pre>
117+
* The greeting service definition.
118+
* </pre>
119+
*/
120+
public static abstract class SimpleImplBase
121+
implements io.grpc.BindableService, AsyncService {
122+
123+
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
124+
return SimpleGrpc.bindService(this);
125+
}
126+
}
127+
128+
/**
129+
* A stub to allow clients to do asynchronous rpc calls to service Simple.
130+
* <pre>
131+
* The greeting service definition.
132+
* </pre>
133+
*/
134+
public static final class SimpleStub
135+
extends io.grpc.stub.AbstractAsyncStub<SimpleStub> {
136+
private SimpleStub(
137+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
138+
super(channel, callOptions);
139+
}
140+
141+
@java.lang.Override
142+
protected SimpleStub build(
143+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
144+
return new SimpleStub(channel, callOptions);
145+
}
146+
147+
/**
148+
* <pre>
149+
* Sends a greeting
150+
* </pre>
151+
*/
152+
public void sayHello(grpc.HelloRequest request,
153+
io.grpc.stub.StreamObserver<grpc.HelloReply> responseObserver) {
154+
io.grpc.stub.ClientCalls.asyncUnaryCall(
155+
getChannel().newCall(getSayHelloMethod(), getCallOptions()), request, responseObserver);
156+
}
157+
}
158+
159+
/**
160+
* A stub to allow clients to do synchronous rpc calls to service Simple.
161+
* <pre>
162+
* The greeting service definition.
163+
* </pre>
164+
*/
165+
public static final class SimpleBlockingStub
166+
extends io.grpc.stub.AbstractBlockingStub<SimpleBlockingStub> {
167+
private SimpleBlockingStub(
168+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
169+
super(channel, callOptions);
170+
}
171+
172+
@java.lang.Override
173+
protected SimpleBlockingStub build(
174+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
175+
return new SimpleBlockingStub(channel, callOptions);
176+
}
177+
178+
/**
179+
* <pre>
180+
* Sends a greeting
181+
* </pre>
182+
*/
183+
public grpc.HelloReply sayHello(grpc.HelloRequest request) {
184+
return io.grpc.stub.ClientCalls.blockingUnaryCall(
185+
getChannel(), getSayHelloMethod(), getCallOptions(), request);
186+
}
187+
}
188+
189+
/**
190+
* A stub to allow clients to do ListenableFuture-style rpc calls to service Simple.
191+
* <pre>
192+
* The greeting service definition.
193+
* </pre>
194+
*/
195+
public static final class SimpleFutureStub
196+
extends io.grpc.stub.AbstractFutureStub<SimpleFutureStub> {
197+
private SimpleFutureStub(
198+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
199+
super(channel, callOptions);
200+
}
201+
202+
@java.lang.Override
203+
protected SimpleFutureStub build(
204+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
205+
return new SimpleFutureStub(channel, callOptions);
206+
}
207+
208+
/**
209+
* <pre>
210+
* Sends a greeting
211+
* </pre>
212+
*/
213+
public com.google.common.util.concurrent.ListenableFuture<grpc.HelloReply> sayHello(
214+
grpc.HelloRequest request) {
215+
return io.grpc.stub.ClientCalls.futureUnaryCall(
216+
getChannel().newCall(getSayHelloMethod(), getCallOptions()), request);
217+
}
218+
}
219+
220+
private static final int METHODID_SAY_HELLO = 0;
221+
222+
private static final class MethodHandlers<Req, Resp> implements
223+
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
224+
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
225+
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
226+
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
227+
private final AsyncService serviceImpl;
228+
private final int methodId;
229+
230+
MethodHandlers(AsyncService serviceImpl, int methodId) {
231+
this.serviceImpl = serviceImpl;
232+
this.methodId = methodId;
233+
}
234+
235+
@java.lang.Override
236+
@java.lang.SuppressWarnings("unchecked")
237+
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
238+
switch (methodId) {
239+
case METHODID_SAY_HELLO:
240+
serviceImpl.sayHello((grpc.HelloRequest) request,
241+
(io.grpc.stub.StreamObserver<grpc.HelloReply>) responseObserver);
242+
break;
243+
default:
244+
throw new AssertionError();
245+
}
246+
}
247+
248+
@java.lang.Override
249+
@java.lang.SuppressWarnings("unchecked")
250+
public io.grpc.stub.StreamObserver<Req> invoke(
251+
io.grpc.stub.StreamObserver<Resp> responseObserver) {
252+
switch (methodId) {
253+
default:
254+
throw new AssertionError();
255+
}
256+
}
257+
}
258+
259+
public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) {
260+
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
261+
.addMethod(
262+
getSayHelloMethod(),
263+
io.grpc.stub.ServerCalls.asyncUnaryCall(
264+
new MethodHandlers<
265+
grpc.HelloRequest,
266+
grpc.HelloReply>(
267+
service, METHODID_SAY_HELLO)))
268+
.build();
269+
}
270+
271+
private static abstract class SimpleBaseDescriptorSupplier
272+
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
273+
SimpleBaseDescriptorSupplier() {}
274+
275+
@java.lang.Override
276+
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
277+
return grpc.HelloWorldProto.getDescriptor();
278+
}
279+
280+
@java.lang.Override
281+
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
282+
return getFileDescriptor().findServiceByName("Simple");
283+
}
284+
}
285+
286+
private static final class SimpleFileDescriptorSupplier
287+
extends SimpleBaseDescriptorSupplier {
288+
SimpleFileDescriptorSupplier() {}
289+
}
290+
291+
private static final class SimpleMethodDescriptorSupplier
292+
extends SimpleBaseDescriptorSupplier
293+
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
294+
private final java.lang.String methodName;
295+
296+
SimpleMethodDescriptorSupplier(java.lang.String methodName) {
297+
this.methodName = methodName;
298+
}
299+
300+
@java.lang.Override
301+
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
302+
return getServiceDescriptor().findMethodByName(methodName);
303+
}
304+
}
305+
306+
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
307+
308+
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
309+
io.grpc.ServiceDescriptor result = serviceDescriptor;
310+
if (result == null) {
311+
synchronized (SimpleGrpc.class) {
312+
result = serviceDescriptor;
313+
if (result == null) {
314+
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
315+
.setSchemaDescriptor(new SimpleFileDescriptorSupplier())
316+
.addMethod(getSayHelloMethod())
317+
.build();
318+
}
319+
}
320+
}
321+
return result;
322+
}
323+
}

0 commit comments

Comments
 (0)