/* Ċ Ġ* ĠCopyright Ġ 2 0 2 0 Ġ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 . kotlin Ċ Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . google . common . truth . extensions . proto . Proto Truth . assertThat Ċ import Ġio . grpc . Status Ċ import Ġio . grpc . Status Exception Ċ import Ġio . grpc . examples . helloworld . G reet er Grpc Ċ import Ġio . grpc . examples . helloworld . G reet er Grpc Kt Ċ import Ġio . grpc . examples . helloworld . G reet er Grpc Kt . G reet er Coroutine Impl Base Ċ import Ġio . grpc . examples . helloworld . G reet er Grpc Kt . G reet er Coroutine Stub Ċ import Ġio . grpc . examples . helloworld . Hello Reply Ċ import Ġio . grpc . examples . helloworld . Hello Request Ċ import Ġio . grpc . examples . helloworld . Multi Hello Request Ċ import Ġkotlinx . coroutines . Cancellation Exception Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . Flow Preview Ċ import Ġkotlinx . coroutines . Job Ċ import Ġkotlinx . coroutines . async Ċ import Ġkotlinx . coroutines . channels . Channel Ċ import Ġkotlinx . coroutines . channels . toList Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġkotlinx . coroutines . flow . as Flow Ċ import Ġkotlinx . coroutines . flow . collect Ċ import Ġkotlinx . coroutines . flow . consume As Flow Ċ import Ġkotlinx . coroutines . flow . flow Ċ import Ġkotlinx . coroutines . flow . flow Of Ċ import Ġkotlinx . coroutines . flow . map Ċ import Ġkotlinx . coroutines . flow . produce In Ċ import Ġkotlinx . coroutines . flow . take Ċ import Ġkotlinx . coroutines . flow . toList Ċ import Ġkotlinx . coroutines . launch Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠGenerated Code Test Ġ: ĠAbstract Calls Test () Ġ{ ĊĠ Ġ@ Test ĊĠ Ġfun Ġsimple Unary () Ġ{ ĊĠĠĠ Ġval Ġserver Ġ= Ġobject Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġsay Hello ( request : ĠHello Request ): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠHello Reply . newBuilder () ĊĠĠĠĠĠĠĠĠĠ Ġ. setMessage (" Hello , Ġ${ request . name } !" Ġ) ĊĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( server ) ĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ) ĊĊĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠ ĠassertThat ( stub . say Hello ( hello Request (" St even "))) ĊĠĠĠĠĠĠĠ Ġ. isEqualTo ( hello Reply (" Hello , ĠSte ven ! ")) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġunary Server DoesNot Respond Grpc Timeout () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġserver Cancelled Ġ= ĠJob () ĊĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġsay Hello ( request : ĠHello Request ): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠ Ġsuspend Until Cancelled Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġserver Cancelled . complete () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ). with Deadline After ( 1 0 0 , ĠTimeUnit . MILLISECONDS ) ĊĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows < Status Exception > Ġ{ ĊĠĠĠĠĠ Ġstub . say Hello ( hello Request (" Top az ")) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertThat ( ex . status . code ). isEqualTo ( Status . Code . DEAD LINE _ EX CE EDED ) ĊĠĠĠ Ġserver Cancelled . join () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġunary Client Cancellation () Ġ{ ĊĠĠĠ Ġval Ġhello Received Ġ= ĠJob () ĊĠĠĠ Ġval Ġhello Cancelled Ġ= ĠJob () ĊĠĠĠ Ġval Ġhello Channel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġsay Hello ( request : ĠHello Request ): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠ Ġhello Received . complete () ĊĠĠĠĠĠĠĠ Ġsuspend Until Cancelled Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġhello Cancelled . complete () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĠĠĠ Ġval Ġhello Stub Ġ= ĠG reet er Coroutine Stub ( hello Channel ) ĊĊĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠ Ġval Ġresult Ġ= Ġasync Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= Ġhello Request (" St even ") ĊĠĠĠĠĠĠĠ Ġhello Stub . say Hello ( request ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġhello Received . join () ĊĠĠĠĠĠ Ġresult . cancel () ĊĠĠĠĠĠ Ġhello Cancelled . join () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġunary Method Throws Status Exception () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( ĊĠĠĠĠĠ Ġobject Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġsay Hello ( request : ĠHello Request ): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġthrow ĠStatus Exception ( Status . PERMISSION _ DEN IED ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ) ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows < Status Exception > Ġ{ ĊĠĠĠĠĠ Ġstub . say Hello ( hello Request (" Per id ot ")) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertThat ( ex . status . code ). isEqualTo ( Status . Code . PERMISSION _ DEN IED ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġunary Method Throws Exception () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( ĊĠĠĠĠĠ Ġobject Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġsay Hello ( request : ĠHello Request ): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġthrow ĠIllegalArgumentException () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ) ĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows < Status Exception > Ġ{ ĊĠĠĠĠĠ Ġstub . say Hello ( hello Request (" Per id ot ")) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertThat ( ex . status . code ). isEqualTo ( Status . Code . UNKNOWN ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġsimple Client Streaming Rpc () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġclient Stream Say Hello ( requests : ĠFlow < Hello Request >): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠHello Reply . newBuilder () ĊĠĠĠĠĠĠĠĠĠ Ġ. setMessage ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrequests . toList () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. join ToString ( prefix Ġ= Ġ" Hello , Ġ", Ġseparator Ġ= Ġ", Ġ") Ġ{ Ġit . name Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ). build () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ) ĊĠĠĠ Ġval Ġrequests Ġ= Ġflow Of ( ĊĠĠĠĠĠ Ġhello Request (" Per id ot "), ĊĠĠĠĠĠ Ġhello Request (" L apis ") ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġresponse Ġ= Ġasync Ġ{ Ġstub . client Stream Say Hello ( requests ) Ġ} ĊĠĠĠ ĠassertThat ( response . await ()). isEqualTo ( hello Reply (" Hello , ĠPer id ot , ĠL apis ")) ĊĠ Ġ} ĊĊĠ Ġ@ Flow Preview ĊĠ Ġ@ Test ĊĠ Ġfun Ġclient Streaming Rpc Cancellation () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġserver Received Ġ= ĠJob () ĊĠĠĠ Ġval Ġserver Cancelled Ġ= ĠJob () ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġclient Stream Say Hello ( requests : ĠFlow < Hello Request >): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠ Ġrequests . collect Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġserver Received . complete () ĊĠĠĠĠĠĠĠĠĠ Ġsuspend Until Cancelled Ġ{ Ġserver Cancelled . complete () Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġthrow ĠAssertionError (" unreachable ") ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ) ĊĠĠĠ Ġval Ġrequests Ġ= ĠChannel < Hello Request >() ĊĠĠĠ Ġval Ġresponse Ġ= Ġasync Ġ{ ĊĠĠĠĠĠ Ġstub . client Stream Say Hello ( requests . consume As Flow ()) ĊĠĠĠ Ġ} ĊĠĠĠ Ġrequests . send ( hello Request (" A qu amar ine ")) ĊĠĠĠ Ġserver Received . join () ĊĠĠĠ Ġresponse . cancel () ĊĠĠĠ Ġserver Cancelled . join () ĊĠĠĠ ĠassertThrows < Cancellation Exception > Ġ{ ĊĠĠĠĠĠ Ġrequests . send ( hello Request (" John ")) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġclient Streaming Rpc Throws Status Exception () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġclient Stream Say Hello ( requests : ĠFlow < Hello Request >): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠ Ġthrow ĠStatus Exception ( Status . PERMISSION _ DEN IED ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ) ĊĊĠĠĠ Ġval Ġex Ġ= ĠassertThrows < Status Exception > Ġ{ ĊĠĠĠĠĠ Ġstub . client Stream Say Hello ( flow Of < Hello Request >()) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertThat ( ex . status . code ). isEqualTo ( Status . Code . PERMISSION _ DEN IED ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġsimple Server Streaming Rpc () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġserver Stream Say Hello ( request : ĠMulti Hello Request ): ĠFlow < Hello Reply > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġrequest . name List . as Flow (). map Ġ{ Ġhello Reply (" Hello , Ġ$ it ") Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġval Ġresponses Ġ= ĠG reet er Coroutine Stub ( channel ). server Stream Say Hello ( ĊĠĠĠĠĠ Ġmulti Hello Request (" Gar net ", Ġ" A meth yst ", Ġ" P ear l ") ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertThat ( responses . toList ()) ĊĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠ Ġhello Reply (" Hello , ĠGar net "), ĊĠĠĠĠĠĠĠ Ġhello Reply (" Hello , ĠA meth yst "), ĊĠĠĠĠĠĠĠ Ġhello Reply (" Hello , ĠP ear l ") ĊĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ. in Order () ĊĠ Ġ} ĊĊĠ Ġ@ Flow Preview ĊĠ Ġ@ Test ĊĠ Ġfun Ġserver Streaming Rpc Cancellation () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġserver Cancelled Ġ= ĠJob () ĊĠĠĠ Ġval Ġserver Received Ġ= ĠJob () ĊĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġserver Stream Say Hello ( request : ĠMulti Hello Request ): ĠFlow < Hello Reply > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġflow Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġserver Received . complete () ĊĠĠĠĠĠĠĠĠĠ Ġsuspend Until Cancelled Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġserver Cancelled . complete () ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġval Ġresponse Ġ= ĠG reet er Coroutine Stub ( channel ). server Stream Say Hello ( ĊĠĠĠĠĠ Ġmulti Hello Request (" Top az ", Ġ" A qu amar ine ") ĊĠĠĠ Ġ). produce In ( this ) ĊĠĠĠ Ġserver Received . join () ĊĠĠĠ Ġresponse . cancel () ĊĠĠĠ Ġserver Cancelled . join () ĊĠ Ġ} ĊĊĠ Ġ@ Flow Preview ĊĠ Ġ@ Test ĊĠ Ġfun Ġbidi Ping P ong () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġbidi Stream Say Hello ( requests : ĠFlow < Hello Request >): ĠFlow < Hello Reply > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġrequests . map Ġ{ Ġhello Reply (" Hello , Ġ${ it . name }") Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġval Ġrequests Ġ= ĠChannel < Hello Request >() ĊĠĠĠ Ġval Ġresponses Ġ= ĠG reet er Coroutine Stub ( channel ). b idi Stream Say Hello ( requests . consume As Flow ()). produce In ( this ) ĊĊĠĠĠ Ġrequests . send ( hello Request (" St even ")) ĊĠĠĠ ĠassertThat ( responses . receive ()). isEqualTo ( hello Reply (" Hello , ĠSte ven ")) ĊĠĠĠ Ġrequests . send ( hello Request (" Gar net ")) ĊĠĠĠ ĠassertThat ( responses . receive ()). isEqualTo ( hello Reply (" Hello , ĠGar net ")) ĊĠĠĠ Ġrequests . close () ĊĠĠĠ ĠassertThat ( responses . toList ()). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Experimental Cor outines Api ĊĠ Ġ@ Flow Preview ĊĠ Ġ@ Test ĊĠ Ġfun Ġbidi Streaming Rpc Returns Early () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( object Ġ: ĠG reet er Coroutine Impl Base () Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġbidi Stream Say Hello ( requests : ĠFlow < Hello Request >): ĠFlow < Hello Reply > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġrequests . take ( 2 ). map Ġ{ Ġhello Reply (" Hello , Ġ${ it . name }") Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ}) ĊĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ) ĊĠĠĠ Ġval Ġrequests Ġ= ĠChannel < Hello Request >() ĊĠĠĠ Ġval Ġresponses Ġ= Ġstub . b idi Stream Say Hello ( requests . consume As Flow ()). produce In ( this ) ĊĠĠĠ Ġrequests . send ( hello Request (" Per id ot ")) ĊĠĠĠ ĠassertThat ( responses . receive ()). isEqualTo ( hello Reply (" Hello , ĠPer id ot ")) ĊĠĠĠ Ġrequests . send ( hello Request (" L apis ")) ĊĠĠĠ ĠassertThat ( responses . receive ()). isEqualTo ( hello Reply (" Hello , ĠL apis ")) ĊĠĠĠ ĠassertThat ( responses . toList ()). isEmpty () ĊĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠ Ġrequests . send ( hello Request (" J asper ")) ĊĠĠĠ Ġ} Ġcatch Ġ( allowed : ĠC ancellation Exception ) Ġ{} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġserver Scope Cancelled During Rpc () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠ Ġval Ġserver Job Ġ= ĠJob () ĊĠĠĠ Ġval Ġserver Received Ġ= ĠJob () ĊĠĠĠ Ġval Ġchannel Ġ= Ġmake Channel ( ĊĠĠĠĠĠ Ġobject Ġ: ĠG reet er Coroutine Impl Base ( server Job ) Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġsuspend Ġfun Ġsay Hello ( request : ĠHello Request ): ĠHello Reply Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġserver Received . complete () ĊĠĠĠĠĠĠĠĠĠ Ġsuspend Until Cancelled Ġ{ Ġ/* Ġdo Ġnothing Ġ*/ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġstub Ġ= ĠG reet er Coroutine Stub ( channel ) ĊĠĠĠ Ġval Ġtest Ġ= Ġlaunch Ġ{ ĊĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows < Status Exception > Ġ{ ĊĠĠĠĠĠĠĠ Ġstub . say Hello ( hello Request (" G reg ")) ĊĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ ĠassertThat ( ex . status . code ). isEqualTo ( Status . Code . CANCEL LED ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġserver Received . join () ĊĠĠĠ Ġserver Job . cancel () ĊĠĠĠ Ġtest . join () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġservice Descriptor () Ġ{ ĊĠĠĠ ĠassertThat ( G reet er Grpc Kt . service Descriptor ). isEqualTo ( G reet er Grpc . getService Descriptor ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġmethod Descriptor () Ġ{ ĊĠĠĠ ĠassertThat ( G reet er Grpc Kt . say Hello Method ). isEqualTo ( G reet er Grpc . getS ay Hello Method ()) ĊĠ Ġ} Ċ } Ċ