-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
250 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
examples/server/src/test/kotlin/io/grpc/examples/animals/AnimalsServerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2020 gRPC authors. | ||
* | ||
* 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.examples.animals | ||
|
||
import io.grpc.testing.GrpcServerRule | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Rule | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class AnimalsServerTest { | ||
|
||
@get:Rule | ||
val grpcServerRule: GrpcServerRule = GrpcServerRule().directExecutor() | ||
|
||
@Test | ||
fun animals() = runBlocking { | ||
val dogService = AnimalsServer.DogService() | ||
val pigService = AnimalsServer.PigService() | ||
val sheepService = AnimalsServer.SheepService() | ||
grpcServerRule.serviceRegistry.addService(dogService) | ||
grpcServerRule.serviceRegistry.addService(pigService) | ||
grpcServerRule.serviceRegistry.addService(sheepService) | ||
|
||
val dogStub = DogGrpcKt.DogCoroutineStub(grpcServerRule.channel) | ||
val dogBark = dogStub.bark(barkRequest { }) | ||
assertEquals("Bark!", dogBark.message) | ||
|
||
val pigStub = PigGrpcKt.PigCoroutineStub(grpcServerRule.channel) | ||
val pigOink = pigStub.oink(oinkRequest { }) | ||
assertEquals("Oink!", pigOink.message) | ||
|
||
val sheepStub = SheepGrpcKt.SheepCoroutineStub(grpcServerRule.channel) | ||
val sheepBaa = sheepStub.baa(baaRequest { }) | ||
assertEquals("Baa!", sheepBaa.message) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
examples/server/src/test/kotlin/io/grpc/examples/helloworld/HelloWorldServerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2020 gRPC authors. | ||
* | ||
* 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.examples.helloworld | ||
|
||
import io.grpc.testing.GrpcServerRule | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Rule | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class HelloWorldServerTest { | ||
|
||
@get:Rule | ||
val grpcServerRule: GrpcServerRule = GrpcServerRule().directExecutor() | ||
|
||
@Test | ||
fun sayHello() = runBlocking { | ||
val service = HelloWorldServer.HelloWorldService() | ||
grpcServerRule.serviceRegistry.addService(service) | ||
|
||
val stub = GreeterGrpcKt.GreeterCoroutineStub(grpcServerRule.channel) | ||
val testName = "test name" | ||
|
||
val reply = stub.sayHello(helloRequest { name = testName }) | ||
|
||
assertEquals("Hello $testName", reply.message) | ||
} | ||
} |
Oops, something went wrong.