Skip to content

Commit e64df5d

Browse files
committed
fix unit tests
1 parent a845f3d commit e64df5d

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ public void testClientInterceptor_success() throws IOException, ResourceInvalidE
151151
CallOptions callOptionsWithXds = CallOptions.DEFAULT
152152
.withOption(CLUSTER_SELECTION_KEY, "cluster:cluster0")
153153
.withOption(XDS_CONFIG_CALL_OPTION_KEY, defaultXdsConfig);
154-
155154
GcpAuthenticationConfig config = new GcpAuthenticationConfig(10);
156155
GcpAuthenticationFilter filter = new GcpAuthenticationFilter("FILTER_INSTANCE_NAME");
157156
ClientInterceptor interceptor = filter.buildClientInterceptor(config, null, null);
158157
MethodDescriptor<Void, Void> methodDescriptor = TestMethodDescriptors.voidMethod();
159158
Channel mockChannel = Mockito.mock(Channel.class);
160159
ArgumentCaptor<CallOptions> callOptionsCaptor = ArgumentCaptor.forClass(CallOptions.class);
160+
161161
interceptor.interceptCall(methodDescriptor, callOptionsWithXds, mockChannel);
162162

163163
verify(mockChannel).newCall(eq(methodDescriptor), callOptionsCaptor.capture());
@@ -180,13 +180,13 @@ public void testClientInterceptor_createsAndReusesCachedCredentials()
180180
CallOptions callOptionsWithXds = CallOptions.DEFAULT
181181
.withOption(CLUSTER_SELECTION_KEY, "cluster:cluster0")
182182
.withOption(XDS_CONFIG_CALL_OPTION_KEY, defaultXdsConfig);
183-
184183
GcpAuthenticationConfig config = new GcpAuthenticationConfig(10);
185184
GcpAuthenticationFilter filter = new GcpAuthenticationFilter("FILTER_INSTANCE_NAME");
186185
ClientInterceptor interceptor = filter.buildClientInterceptor(config, null, null);
187186
MethodDescriptor<Void, Void> methodDescriptor = TestMethodDescriptors.voidMethod();
188187
Channel mockChannel = Mockito.mock(Channel.class);
189188
ArgumentCaptor<CallOptions> callOptionsCaptor = ArgumentCaptor.forClass(CallOptions.class);
189+
190190
interceptor.interceptCall(methodDescriptor, callOptionsWithXds, mockChannel);
191191
interceptor.interceptCall(methodDescriptor, callOptionsWithXds, mockChannel);
192192

@@ -207,6 +207,7 @@ public void testClientInterceptor_withoutClusterSelectionKey() throws Exception
207207
MethodDescriptor<Void, Void> methodDescriptor = TestMethodDescriptors.voidMethod();
208208
Channel mockChannel = mock(Channel.class);
209209
CallOptions callOptionsWithXds = CallOptions.DEFAULT;
210+
210211
ClientCall<Void, Void> call = interceptor.interceptCall(
211212
methodDescriptor, callOptionsWithXds, mockChannel);
212213

@@ -229,12 +230,12 @@ public void testClientInterceptor_clusterSelectionKeyWithoutPrefix() throws Exce
229230
CallOptions callOptionsWithXds = CallOptions.DEFAULT
230231
.withOption(CLUSTER_SELECTION_KEY, "cluster0")
231232
.withOption(XDS_CONFIG_CALL_OPTION_KEY, defaultXdsConfig);
233+
Channel mockChannel = mock(Channel.class);
232234

233235
GcpAuthenticationConfig config = new GcpAuthenticationConfig(10);
234236
GcpAuthenticationFilter filter = new GcpAuthenticationFilter("FILTER_INSTANCE_NAME");
235237
ClientInterceptor interceptor = filter.buildClientInterceptor(config, null, null);
236238
MethodDescriptor<Void, Void> methodDescriptor = TestMethodDescriptors.voidMethod();
237-
Channel mockChannel = mock(Channel.class);
238239
interceptor.interceptCall(methodDescriptor, callOptionsWithXds, mockChannel);
239240

240241
verify(mockChannel).newCall(methodDescriptor, callOptionsWithXds);
@@ -249,6 +250,7 @@ public void testClientInterceptor_xdsConfigDoesNotExist() throws Exception {
249250
Channel mockChannel = mock(Channel.class);
250251
CallOptions callOptionsWithXds = CallOptions.DEFAULT
251252
.withOption(CLUSTER_SELECTION_KEY, "cluster:cluster0");
253+
252254
ClientCall<Void, Void> call =
253255
interceptor.interceptCall(methodDescriptor, callOptionsWithXds, mockChannel);
254256

@@ -271,12 +273,12 @@ public void testClientInterceptor_incorrectClusterName() throws Exception {
271273
CallOptions callOptionsWithXds = CallOptions.DEFAULT
272274
.withOption(CLUSTER_SELECTION_KEY, "cluster:cluster")
273275
.withOption(XDS_CONFIG_CALL_OPTION_KEY, defaultXdsConfig);
274-
275276
GcpAuthenticationConfig config = new GcpAuthenticationConfig(10);
276277
GcpAuthenticationFilter filter = new GcpAuthenticationFilter("FILTER_INSTANCE_NAME");
277278
ClientInterceptor interceptor = filter.buildClientInterceptor(config, null, null);
278279
MethodDescriptor<Void, Void> methodDescriptor = TestMethodDescriptors.voidMethod();
279280
Channel mockChannel = mock(Channel.class);
281+
280282
ClientCall<Void, Void> call =
281283
interceptor.interceptCall(methodDescriptor, callOptionsWithXds, mockChannel);
282284

@@ -297,12 +299,12 @@ public void testClientInterceptor_statusOrError() throws Exception {
297299
CallOptions callOptionsWithXds = CallOptions.DEFAULT
298300
.withOption(CLUSTER_SELECTION_KEY, "cluster:cluster0")
299301
.withOption(XDS_CONFIG_CALL_OPTION_KEY, defaultXdsConfig);
300-
301302
GcpAuthenticationConfig config = new GcpAuthenticationConfig(10);
302303
GcpAuthenticationFilter filter = new GcpAuthenticationFilter("FILTER_INSTANCE_NAME");
303304
ClientInterceptor interceptor = filter.buildClientInterceptor(config, null, null);
304305
MethodDescriptor<Void, Void> methodDescriptor = TestMethodDescriptors.voidMethod();
305306
Channel mockChannel = mock(Channel.class);
307+
306308
ClientCall<Void, Void> call =
307309
interceptor.interceptCall(methodDescriptor, callOptionsWithXds, mockChannel);
308310

@@ -326,12 +328,12 @@ public void testClientInterceptor_notAudienceWrapper()
326328
CallOptions callOptionsWithXds = CallOptions.DEFAULT
327329
.withOption(CLUSTER_SELECTION_KEY, "cluster:cluster0")
328330
.withOption(XDS_CONFIG_CALL_OPTION_KEY, defaultXdsConfig);
329-
330331
GcpAuthenticationConfig config = new GcpAuthenticationConfig(10);
331332
GcpAuthenticationFilter filter = new GcpAuthenticationFilter("FILTER_INSTANCE_NAME");
332333
ClientInterceptor interceptor = filter.buildClientInterceptor(config, null, null);
333334
MethodDescriptor<Void, Void> methodDescriptor = TestMethodDescriptors.voidMethod();
334335
Channel mockChannel = Mockito.mock(Channel.class);
336+
335337
ClientCall<Void, Void> call =
336338
interceptor.interceptCall(methodDescriptor, callOptionsWithXds, mockChannel);
337339

0 commit comments

Comments
 (0)