Skip to content

Commit

Permalink
fix test after adding interceptor for logging for http.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumin8 committed Dec 5, 2024
1 parent 487614c commit cc3465b
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ void managedChannelUsesDefaultChannelExecutor() throws IOException {
// By default, the channel will be wrapped with ManagedHttpJsonInterceptorChannel
ManagedHttpJsonInterceptorChannel interceptorChannel =
(ManagedHttpJsonInterceptorChannel) httpJsonTransportChannel.getManagedChannel();
ManagedHttpJsonChannel managedHttpJsonChannel = interceptorChannel.getChannel();
assertThat(managedHttpJsonChannel.getExecutor()).isNotNull();
// call getChannel() twice because interceptors are chained in layers by recursive construction
// inside com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider.createChannel
ManagedHttpJsonInterceptorChannel managedHttpJsonChannel = (ManagedHttpJsonInterceptorChannel) interceptorChannel.getChannel();
ManagedHttpJsonChannel channel = managedHttpJsonChannel.getChannel();
assertThat(channel.getExecutor()).isNotNull();

// Clean up the resources (executor, deadlineScheduler, httpTransport)
instantiatingHttpJsonChannelProvider.getTransportChannel().shutdownNow();
Expand All @@ -146,9 +149,13 @@ void managedChannelUsesCustomExecutor() throws IOException {
// By default, the channel will be wrapped with ManagedHttpJsonInterceptorChannel
ManagedHttpJsonInterceptorChannel interceptorChannel =
(ManagedHttpJsonInterceptorChannel) httpJsonTransportChannel.getManagedChannel();
ManagedHttpJsonChannel managedHttpJsonChannel = interceptorChannel.getChannel();
assertThat(managedHttpJsonChannel.getExecutor()).isNotNull();
assertThat(managedHttpJsonChannel.getExecutor()).isEqualTo(executor);
// call getChannel() twice because interceptors are chained in layers by recursive construction
// inside com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider.createChannel
ManagedHttpJsonInterceptorChannel managedHttpJsonChannel = (ManagedHttpJsonInterceptorChannel) interceptorChannel.getChannel();
ManagedHttpJsonChannel channel = managedHttpJsonChannel.getChannel();

assertThat(channel.getExecutor()).isNotNull();
assertThat(channel.getExecutor()).isEqualTo(executor);

// Clean up the resources (executor, deadlineScheduler, httpTransport)
instantiatingHttpJsonChannelProvider.getTransportChannel().shutdownNow();
Expand Down

0 comments on commit cc3465b

Please sign in to comment.