@@ -377,22 +377,30 @@ void testDirectPathDisallowNullCredentials() throws IOException {
377
377
378
378
@ Test
379
379
void testDirectPathWithGDUEndpoint () {
380
+ EndpointContext endpointContext = Mockito .mock (EndpointContext .class );
381
+ Mockito .when (endpointContext .resolvedEndpoint ()).thenReturn (DEFAULT_ENDPOINT );
382
+
380
383
InstantiatingGrpcChannelProvider provider =
381
384
InstantiatingGrpcChannelProvider .newBuilder ()
382
385
.setAttemptDirectPath (true )
383
386
.setAttemptDirectPathXds ()
384
387
.setEndpoint (DEFAULT_ENDPOINT )
388
+ .setEndpointContext (endpointContext )
385
389
.build ();
386
390
assertThat (provider .canUseDirectPathWithUniverseDomain ()).isTrue ();
387
391
}
388
392
389
393
@ Test
390
394
void testDirectPathWithNonGDUEndpoint () {
395
+ EndpointContext endpointContext = Mockito .mock (EndpointContext .class );
396
+ Mockito .when (endpointContext .resolvedEndpoint ()).thenReturn ("test.random.com:443" );
397
+
391
398
InstantiatingGrpcChannelProvider provider =
392
399
InstantiatingGrpcChannelProvider .newBuilder ()
393
400
.setAttemptDirectPath (true )
394
401
.setAttemptDirectPathXds ()
395
402
.setEndpoint ("test.random.com:443" )
403
+ .setEndpointContext (endpointContext )
396
404
.build ();
397
405
assertThat (provider .canUseDirectPathWithUniverseDomain ()).isFalse ();
398
406
}
@@ -830,11 +838,14 @@ public void canUseDirectPath_directPathEnvVarDisabled() throws IOException {
830
838
@ Test
831
839
public void canUseDirectPath_directPathEnvVarNotSet_attemptDirectPathIsTrue () {
832
840
System .setProperty ("os.name" , "Linux" );
841
+ EndpointContext endpointContext = Mockito .mock (EndpointContext .class );
842
+ Mockito .when (endpointContext .resolvedEndpoint ()).thenReturn (DEFAULT_ENDPOINT );
833
843
InstantiatingGrpcChannelProvider .Builder builder =
834
844
InstantiatingGrpcChannelProvider .newBuilder ()
835
845
.setAttemptDirectPath (true )
836
846
.setCredentials (computeEngineCredentials )
837
- .setEndpoint (DEFAULT_ENDPOINT );
847
+ .setEndpoint (DEFAULT_ENDPOINT )
848
+ .setEndpointContext (endpointContext );
838
849
InstantiatingGrpcChannelProvider provider =
839
850
new InstantiatingGrpcChannelProvider (builder , GCE_PRODUCTION_NAME_AFTER_2016 );
840
851
Truth .assertThat (provider .canUseDirectPath ()).isTrue ();
@@ -938,11 +949,14 @@ public void canUseDirectPath_nonGDUUniverseDomain() {
938
949
InstantiatingGrpcChannelProvider .DIRECT_PATH_ENV_DISABLE_DIRECT_PATH ))
939
950
.thenReturn ("false" );
940
951
String nonGDUEndpoint = "test.random.com:443" ;
952
+ EndpointContext endpointContext = Mockito .mock (EndpointContext .class );
953
+ Mockito .when (endpointContext .resolvedEndpoint ()).thenReturn (nonGDUEndpoint );
941
954
InstantiatingGrpcChannelProvider .Builder builder =
942
955
InstantiatingGrpcChannelProvider .newBuilder ()
943
956
.setAttemptDirectPath (true )
944
957
.setCredentials (computeEngineCredentials )
945
958
.setEndpoint (nonGDUEndpoint )
959
+ .setEndpointContext (endpointContext )
946
960
.setEnvProvider (envProvider );
947
961
InstantiatingGrpcChannelProvider provider =
948
962
new InstantiatingGrpcChannelProvider (builder , GCE_PRODUCTION_NAME_AFTER_2016 );
0 commit comments