Skip to content

Commit 56d96bd

Browse files
test via public methods/results, remove hasTransport() test only method
1 parent ba7054a commit 56d96bd

2 files changed

Lines changed: 13 additions & 26 deletions

File tree

xds/src/main/java/io/grpc/xds/GrpcXdsTransportFactory.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ public XdsTransport createForTest(ManagedChannel channel) {
7777
return new GrpcXdsTransport(channel, callCredentials, null);
7878
}
7979

80-
@VisibleForTesting
81-
static boolean hasTransport(Bootstrapper.ServerInfo serverInfo) {
82-
return xdsServerInfoToTransportMap.containsKey(serverInfo);
83-
}
84-
8580
@VisibleForTesting
8681
static class GrpcXdsTransport implements XdsTransport {
8782

xds/src/test/java/io/grpc/xds/GrpcXdsTransportFactoryTest.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,19 @@ public void refCountedXdsTransport_sameXdsServerAddress_returnsExistingTransport
124124
Bootstrapper.ServerInfo.create(
125125
"localhost:" + server.getPort(), InsecureChannelCredentials.create());
126126
GrpcXdsTransportFactory xdsTransportFactory = new GrpcXdsTransportFactory(null);
127-
// Verify calling create() for the first time creates a new GrpcXdsTransport instance.
127+
// Calling create() for the first time creates a new GrpcXdsTransport instance.
128128
// The ref count was previously 0 and now is 1.
129129
XdsTransportFactory.XdsTransport transport1 = xdsTransportFactory.create(xdsServerInfo);
130-
assertThat(GrpcXdsTransportFactory.hasTransport(xdsServerInfo)).isTrue();
131-
// Verify calling create() for the second time to the same xDS server address returns the same
130+
// Calling create() for the second time to the same xDS server address returns the same
132131
// GrpcXdsTransport instance. The ref count was previously 1 and now is 2.
133132
XdsTransportFactory.XdsTransport transport2 = xdsTransportFactory.create(xdsServerInfo);
134133
assertThat(transport1).isSameInstanceAs(transport2);
135-
assertThat(GrpcXdsTransportFactory.hasTransport(xdsServerInfo)).isTrue();
136-
// Verify calling shutdown() for the first time does not shut down the GrpcXdsTransport
137-
// instance. The ref count was previously 2 and now is 1.
134+
// Calling shutdown() for the first time does not shut down the GrpcXdsTransport instance.
135+
// The ref count was previously 2 and now is 1.
138136
transport1.shutdown();
139-
assertThat(GrpcXdsTransportFactory.hasTransport(xdsServerInfo)).isTrue();
140-
// Verify calling shutdown() for the second time shuts down and cleans up the
141-
// GrpcXdsTransport instance. The ref count was previously 1 and now is 0.
137+
// Calling shutdown() for the second time shuts down the GrpcXdsTransport instance.
138+
// The ref count was previously 1 and now is 0.
142139
transport2.shutdown();
143-
assertThat(GrpcXdsTransportFactory.hasTransport(xdsServerInfo)).isFalse();
144140
}
145141

146142
@Test
@@ -159,23 +155,19 @@ public void refCountedXdsTransport_differentXdsServerAddress_returnsDifferentTra
159155
Bootstrapper.ServerInfo.create(
160156
"localhost:" + server2.getPort(), InsecureChannelCredentials.create());
161157
GrpcXdsTransportFactory xdsTransportFactory = new GrpcXdsTransportFactory(null);
162-
// Verify calling create() to the first xDS server creates a new GrpcXdsTransport instance.
158+
// Calling create() to the first xDS server creates a new GrpcXdsTransport instance.
163159
// The ref count was previously 0 and now is 1.
164160
XdsTransportFactory.XdsTransport transport1 = xdsTransportFactory.create(xdsServerInfo1);
165-
assertThat(GrpcXdsTransportFactory.hasTransport(xdsServerInfo1)).isTrue();
166-
// Verify calling create() to the second xDS server creates a different GrpcXdsTransport
167-
// instance. The ref count was previously 0 and now is 1.
161+
// Calling create() to the second xDS server creates a different GrpcXdsTransport instance.
162+
// The ref count was previously 0 and now is 1.
168163
XdsTransportFactory.XdsTransport transport2 = xdsTransportFactory.create(xdsServerInfo2);
169164
assertThat(transport1).isNotSameInstanceAs(transport2);
170-
assertThat(GrpcXdsTransportFactory.hasTransport(xdsServerInfo2)).isTrue();
171-
// Verify calling shutdown() shuts down and cleans up the GrpcXdsTransport instance for
172-
// the first xDS server. The ref count was previously 1 and now is 0.
165+
// Calling shutdown() shuts down the GrpcXdsTransport instance for the first xDS server.
166+
// The ref count was previously 1 and now is 0.
173167
transport1.shutdown();
174-
assertThat(GrpcXdsTransportFactory.hasTransport(xdsServerInfo1)).isFalse();
175-
// Verify calling shutdown() shuts down and cleans up the GrpcXdsTransport instance for
176-
// the second xDS server. The ref count was previously 1 and now is 0.
168+
// Calling shutdown() shuts down the GrpcXdsTransport instance for the second xDS server.
169+
// The ref count was previously 1 and now is 0.
177170
transport2.shutdown();
178-
assertThat(GrpcXdsTransportFactory.hasTransport(xdsServerInfo2)).isFalse();
179171
// Clean up the second xDS server.
180172
server2.shutdown();
181173
}

0 commit comments

Comments
 (0)