File tree Expand file tree Collapse file tree 4 files changed +36
-7
lines changed
src/test/kotlin/org/jacodb/ets/test
src/main/kotlin/org/jacodb/ets/service Expand file tree Collapse file tree 4 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ dependencies {
2020
2121 testImplementation(kotlin(" test" ))
2222 testImplementation(Libs .mockk)
23- testImplementation(Libs .grpc_api)
2423
2524 testFixturesImplementation(Libs .kotlin_logging)
2625 testFixturesImplementation(Libs .junit_jupiter_api)
Original file line number Diff line number Diff line change @@ -18,10 +18,9 @@ package org.jacodb.ets.test
1818
1919import greeter.GreeterClient
2020import greeter.HelloRequest
21- import io.grpc.ServerBuilder
2221import mu.KotlinLogging
23- import org.jacodb.ets.service.GreeterService
2422import org.jacodb.ets.service.createGrpcClient
23+ import org.jacodb.ets.service.grpcServer
2524import kotlin.test.Test
2625
2726private val logger = KotlinLogging .logger {}
@@ -33,10 +32,7 @@ class WireTest {
3332
3433 @Test
3534 fun `test Greeter` () {
36- val server = ServerBuilder
37- .forPort(PORT )
38- .addService(GreeterService ())
39- .build()
35+ val server = grpcServer(PORT )
4036 server.start()
4137 logger.info { " Server listening on port ${server.port} " }
4238
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ buildscript {
1313dependencies {
1414 protoSource(project(" :jacodb-ets:wire-protos" ))
1515 api(Libs .wire_grpc_server)
16+ api(Libs .grpc_api)
1617 implementation(Libs .grpc_protobuf)
1718 implementation(Libs .grpc_services) // for ProtoReflectionService
1819 implementation(Libs .kotlin_logging)
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2022 UnitTestBot contributors (utbot.org)
3+ * <p>
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ * <p>
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ * <p>
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package org.jacodb.ets.service
18+
19+ import io.grpc.Server
20+ import io.grpc.ServerBuilder
21+ import io.grpc.protobuf.services.ProtoReflectionService
22+
23+ fun grpcServer (
24+ port : Int ,
25+ addReflection : Boolean = true,
26+ setup : ServerBuilder <* >.() -> Unit = {},
27+ ): Server = ServerBuilder
28+ .forPort(port)
29+ .apply (setup)
30+ .apply {
31+ if (addReflection) addService(@Suppress(" DEPRECATION" ) ProtoReflectionService .newInstance())
32+ }
33+ .build()
You can’t perform that action at this time.
0 commit comments