package Ġcom . as ark ar . grpc . test Ċ Ċ import Ġio . grpc . Managed Channel Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . Before All Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . Test Instance Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġorg . mockito . Mockito Ċ Ċ @ Extend With ( Grpc Cleanup Extension :: class ) Ċ @ Test Instance ( Test Instance . Lifecycle . PER _ CLASS ) Ċ class ĠExample TestCase 9 Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġchannel : ĠManaged Channel ĊĠĠĠ Ġprivate Ġval Ġset Of Resources : ĠMutable Set < Resources > Ġ= Ġmutable Set Of () ĊĠĠĠ Ġprivate Ġval Ġset Ġ= ĠMockito . spy ( set Of Resources ) ĊĊĠĠĠ Ġ@ Before All ĊĠĠĠ Ġfun Ġbefore All ( resources : ĠResources ) Ġ{ ĊĠĠĠĠĠĠĠ Ġchannel Ġ= ĠTestUtils . random Channel () ĊĠĠĠĠĠĠĠ Ġresources . register ( channel ) ĊĠĠĠĠĠĠĠ ĠassertThat ( set Of Resources . add ( resources )). isTrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest 1 ( resources : ĠResources ) Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( channel . is Shutdown ). isFalse ĊĠĠĠĠĠĠĠ ĠassertThat ( channel . is Terminated ). isFalse ĊĠĠĠĠĠĠĠ Ġresources . register ( TestUtils . random Channel ()) ĊĠĠĠĠĠĠĠ ĠassertThat ( set Of Resources . add ( resources )). isTrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest 2 ( resources : ĠResources ) Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( channel . is Shutdown ). isFalse ĊĠĠĠĠĠĠĠ ĠassertThat ( channel . is Terminated ). isFalse ĊĠĠĠĠĠĠĠ Ġresources . register ( TestUtils . random Channel ()) ĊĠĠĠĠĠĠĠ ĠassertThat ( set Of Resources . add ( resources )). isTrue ĊĠĠĠ Ġ} Ċ } Ċ