Skip to content

Commit 997c65d

Browse files
committed
Fixup #12690: Improve coverage for CachedChannelManager
1 parent 4530bdd commit 997c65d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

xds/src/test/java/io/grpc/xds/internal/grpcservice/CachedChannelManagerTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,29 @@ public void getChannel_afterClose_throwsException() {
135135
assertThat(e).hasMessageThat().contains("CachedChannelManager is closed");
136136
}
137137
}
138+
139+
@Test
140+
public void constructor_defaultCreatesChannel() {
141+
CachedChannelManager defaultManager = new CachedChannelManager();
142+
io.grpc.ChannelCredentials creds = io.grpc.InsecureChannelCredentials.create();
143+
ChannelCredsConfig credsConfig = mock(ChannelCredsConfig.class);
144+
when(credsConfig.type()).thenReturn("insecure");
145+
ConfiguredChannelCredentials configuredCreds =
146+
ConfiguredChannelCredentials.create(creds, credsConfig);
147+
GoogleGrpcConfig googleGrpc = GoogleGrpcConfig.builder()
148+
.target("localhost:8080")
149+
.configuredChannelCredentials(configuredCreds)
150+
.build();
151+
GrpcServiceConfig config = GrpcServiceConfig.builder()
152+
.googleGrpc(googleGrpc)
153+
.initialMetadata(ImmutableList.of())
154+
.build();
155+
156+
ManagedChannel channel = defaultManager.getChannel(config);
157+
assertThat(channel).isNotNull();
158+
159+
channel.shutdownNow();
160+
defaultManager.close();
161+
}
162+
138163
}

0 commit comments

Comments
 (0)