1818
1919import static com .google .common .truth .Truth .assertThat ;
2020import static com .google .common .truth .extensions .proto .ProtoTruth .assertThat ;
21- import static java .util .concurrent .TimeUnit .SECONDS ;
2221import static org .junit .Assert .assertThrows ;
23- import static org .mockito .Mockito .mock ;
24- import static org .mockito .Mockito .times ;
25- import static org .mockito .Mockito .verify ;
2622
2723import io .grpc .CallOptions ;
2824import io .grpc .Channel ;
3935import io .grpc .benchmarks .Utils ;
4036import io .grpc .internal .SharedResourceHolder .Resource ;
4137import io .grpc .netty .NettyServerBuilder ;
42- import io .grpc .s2a .channel .S2AHandshakerServiceChannel .EventLoopHoldingChannel ;
38+ import io .grpc .s2a .channel .S2AHandshakerServiceChannel .HandshakerServiceChannel ;
4339import io .grpc .stub .StreamObserver ;
4440import io .grpc .testing .GrpcCleanupRule ;
4541import io .grpc .testing .protobuf .SimpleRequest ;
4642import io .grpc .testing .protobuf .SimpleResponse ;
4743import io .grpc .testing .protobuf .SimpleServiceGrpc ;
48- import io .netty .channel .EventLoopGroup ;
4944import java .io .File ;
50- import java .time .Duration ;
5145import java .util .Optional ;
5246import java .util .concurrent .TimeUnit ;
5347import org .junit .Before ;
6054@ RunWith (JUnit4 .class )
6155public final class S2AHandshakerServiceChannelTest {
6256 @ ClassRule public static final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule ();
63- private static final Duration CHANNEL_SHUTDOWN_TIMEOUT = Duration .ofSeconds (10 );
64- private final EventLoopGroup mockEventLoopGroup = mock (EventLoopGroup .class );
6557 private Server mtlsServer ;
6658 private Server plaintextServer ;
6759
@@ -191,7 +183,7 @@ public void close_mtlsSuccess() throws Exception {
191183 }
192184
193185 /**
194- * Verifies that an {@code EventLoopHoldingChannel }'s {@code newCall} method can be used to
186+ * Verifies that an {@code HandshakerServiceChannel }'s {@code newCall} method can be used to
195187 * perform a simple RPC.
196188 */
197189 @ Test
@@ -201,7 +193,7 @@ public void newCall_performSimpleRpcSuccess() {
201193 "localhost:" + plaintextServer .getPort (),
202194 /* s2aChannelCredentials= */ Optional .empty ());
203195 Channel channel = resource .create ();
204- assertThat (channel ).isInstanceOf (EventLoopHoldingChannel .class );
196+ assertThat (channel ).isInstanceOf (HandshakerServiceChannel .class );
205197 assertThat (
206198 SimpleServiceGrpc .newBlockingStub (channel ).unaryRpc (SimpleRequest .getDefaultInstance ()))
207199 .isEqualToDefaultInstance ();
@@ -214,53 +206,49 @@ public void newCall_mtlsPerformSimpleRpcSuccess() throws Exception {
214206 S2AHandshakerServiceChannel .getChannelResource (
215207 "localhost:" + mtlsServer .getPort (), getTlsChannelCredentials ());
216208 Channel channel = resource .create ();
217- assertThat (channel ).isInstanceOf (EventLoopHoldingChannel .class );
209+ assertThat (channel ).isInstanceOf (HandshakerServiceChannel .class );
218210 assertThat (
219211 SimpleServiceGrpc .newBlockingStub (channel ).unaryRpc (SimpleRequest .getDefaultInstance ()))
220212 .isEqualToDefaultInstance ();
221213 }
222214
223- /** Creates a {@code EventLoopHoldingChannel } instance and verifies its authority. */
215+ /** Creates a {@code HandshakerServiceChannel } instance and verifies its authority. */
224216 @ Test
225217 public void authority_success () throws Exception {
226218 ManagedChannel channel = new FakeManagedChannel (true );
227- EventLoopHoldingChannel eventLoopHoldingChannel =
228- EventLoopHoldingChannel .create (channel , mockEventLoopGroup );
219+ HandshakerServiceChannel eventLoopHoldingChannel =
220+ HandshakerServiceChannel .create (channel );
229221 assertThat (eventLoopHoldingChannel .authority ()).isEqualTo ("FakeManagedChannel" );
230222 }
231223
232224 /**
233- * Creates and closes a {@code EventLoopHoldingChannel } when its {@code ManagedChannel} terminates
234- * successfully.
225+ * Creates and closes a {@code HandshakerServiceChannel } when its {@code ManagedChannel}
226+ * terminates successfully.
235227 */
236228 @ Test
237229 public void close_withDelegateTerminatedSuccess () throws Exception {
238230 ManagedChannel channel = new FakeManagedChannel (true );
239- EventLoopHoldingChannel eventLoopHoldingChannel =
240- EventLoopHoldingChannel .create (channel , mockEventLoopGroup );
231+ HandshakerServiceChannel eventLoopHoldingChannel =
232+ HandshakerServiceChannel .create (channel );
241233 eventLoopHoldingChannel .close ();
242234 assertThat (channel .isShutdown ()).isTrue ();
243- verify (mockEventLoopGroup , times (1 ))
244- .shutdownGracefully (0 , CHANNEL_SHUTDOWN_TIMEOUT .getSeconds (), SECONDS );
245235 }
246236
247237 /**
248- * Creates and closes a {@code EventLoopHoldingChannel } when its {@code ManagedChannel} does not
238+ * Creates and closes a {@code HandshakerServiceChannel } when its {@code ManagedChannel} does not
249239 * terminate successfully.
250240 */
251241 @ Test
252242 public void close_withDelegateTerminatedFailure () throws Exception {
253243 ManagedChannel channel = new FakeManagedChannel (false );
254- EventLoopHoldingChannel eventLoopHoldingChannel =
255- EventLoopHoldingChannel .create (channel , mockEventLoopGroup );
244+ HandshakerServiceChannel eventLoopHoldingChannel =
245+ HandshakerServiceChannel .create (channel );
256246 eventLoopHoldingChannel .close ();
257247 assertThat (channel .isShutdown ()).isTrue ();
258- verify (mockEventLoopGroup , times (1 ))
259- .shutdownGracefully (1 , CHANNEL_SHUTDOWN_TIMEOUT .getSeconds (), SECONDS );
260248 }
261249
262250 /**
263- * Creates and closes a {@code EventLoopHoldingChannel }, creates a new channel from the same
251+ * Creates and closes a {@code HandshakerServiceChannel }, creates a new channel from the same
264252 * resource, and verifies that this second channel is useable.
265253 */
266254 @ Test
@@ -273,7 +261,7 @@ public void create_succeedsAfterCloseIsCalledOnce() throws Exception {
273261 resource .close (channelOne );
274262
275263 Channel channelTwo = resource .create ();
276- assertThat (channelTwo ).isInstanceOf (EventLoopHoldingChannel .class );
264+ assertThat (channelTwo ).isInstanceOf (HandshakerServiceChannel .class );
277265 assertThat (
278266 SimpleServiceGrpc .newBlockingStub (channelTwo )
279267 .unaryRpc (SimpleRequest .getDefaultInstance ()))
@@ -291,7 +279,7 @@ public void create_mtlsSucceedsAfterCloseIsCalledOnce() throws Exception {
291279 resource .close (channelOne );
292280
293281 Channel channelTwo = resource .create ();
294- assertThat (channelTwo ).isInstanceOf (EventLoopHoldingChannel .class );
282+ assertThat (channelTwo ).isInstanceOf (HandshakerServiceChannel .class );
295283 assertThat (
296284 SimpleServiceGrpc .newBlockingStub (channelTwo )
297285 .unaryRpc (SimpleRequest .getDefaultInstance ()))
0 commit comments