@@ -503,26 +503,11 @@ public void uncaughtException(Thread t, Throwable e) {
503
503
}
504
504
505
505
@ Test
506
- public void reprocess_authorityOverridePresentInCallOptions_authorityOverrideFromLbIsIgnored () {
507
- DelayedStream delayedStream = (DelayedStream ) delayedTransport .newStream (
508
- method , headers , callOptions , tracers );
509
- delayedStream .start (mock (ClientStreamListener .class ));
510
- SubchannelPicker picker = mock (SubchannelPicker .class );
511
- PickResult pickResult = PickResult .withSubchannel (
512
- mockSubchannel , null , "authority-override-hostname-from-lb" );
513
- when (picker .pickSubchannel (any (PickSubchannelArgs .class ))).thenReturn (pickResult );
514
-
515
- delayedTransport .reprocess (picker );
516
- fakeExecutor .runDueTasks ();
517
-
518
- verify (mockRealStream , never ()).setAuthority ("authority-override-hostname-from-lb" );
519
- }
520
-
521
- @ Test
522
- public void
523
- reprocess_authorityOverrideNotInCallOptions_authorityOverrideFromLbIsSetIntoStream () {
506
+ public void reprocess_authorityOverrideFromLb () {
507
+ InOrder inOrder = inOrder (mockRealStream );
524
508
DelayedStream delayedStream = (DelayedStream ) delayedTransport .newStream (
525
509
method , headers , callOptions .withAuthority (null ), tracers );
510
+ delayedStream .setAuthority ("authority-override-from-calloptions" );
526
511
delayedStream .start (mock (ClientStreamListener .class ));
527
512
SubchannelPicker picker = mock (SubchannelPicker .class );
528
513
PickResult pickResult = PickResult .withSubchannel (
@@ -536,7 +521,10 @@ public void reprocess_authorityOverridePresentInCallOptions_authorityOverrideFro
536
521
delayedTransport .reprocess (picker );
537
522
fakeExecutor .runDueTasks ();
538
523
539
- verify (mockRealStream ).setAuthority ("authority-override-hostname-from-lb" );
524
+ // Must be set before start(), and may be overwritten
525
+ inOrder .verify (mockRealStream ).setAuthority ("authority-override-hostname-from-lb" );
526
+ inOrder .verify (mockRealStream ).setAuthority ("authority-override-from-calloptions" );
527
+ inOrder .verify (mockRealStream ).start (any (ClientStreamListener .class ));
540
528
}
541
529
542
530
@ Test
@@ -563,28 +551,26 @@ public void reprocess_NoPendingStream() {
563
551
}
564
552
565
553
@ Test
566
- public void newStream_assignsTransport_authorityFromCallOptionsSupersedesAuthorityFromLB () {
554
+ public void newStream_authorityOverrideFromLb () {
555
+ InOrder inOrder = inOrder (mockRealStream );
567
556
SubchannelPicker picker = mock (SubchannelPicker .class );
568
- AbstractSubchannel subchannel = mock (AbstractSubchannel .class );
569
- when (subchannel .getInternalSubchannel ()).thenReturn (mockInternalSubchannel );
570
557
PickResult pickResult = PickResult .withSubchannel (
571
- subchannel , null , "authority-override-hostname-from-lb" );
558
+ mockSubchannel , null , "authority-override-hostname-from-lb" );
572
559
when (picker .pickSubchannel (any (PickSubchannelArgs .class ))).thenReturn (pickResult );
573
- ArgumentCaptor <CallOptions > callOptionsArgumentCaptor =
574
- ArgumentCaptor .forClass (CallOptions .class );
575
560
when (mockRealTransport .newStream (
576
- any (MethodDescriptor .class ), any (Metadata .class ), callOptionsArgumentCaptor .capture (),
577
- ArgumentMatchers .<ClientStreamTracer []>any ()))
561
+ any (MethodDescriptor .class ), any (Metadata .class ), any (CallOptions .class ), any ()))
578
562
.thenReturn (mockRealStream );
579
563
delayedTransport .reprocess (picker );
580
- verifyNoMoreInteractions (picker );
581
- verifyNoMoreInteractions (transportListener );
582
564
583
- CallOptions callOptions =
584
- CallOptions .DEFAULT .withAuthority ("authority-override-hosstname-from-calloptions" );
585
- delayedTransport .newStream (method , headers , callOptions , tracers );
586
- assertThat (callOptionsArgumentCaptor .getValue ().getAuthority ()).isEqualTo (
587
- "authority-override-hosstname-from-calloptions" );
565
+ ClientStream stream = delayedTransport .newStream (method , headers , callOptions , tracers );
566
+ assertThat (stream ).isSameInstanceAs (mockRealStream );
567
+ stream .setAuthority ("authority-override-from-calloptions" );
568
+ stream .start (mock (ClientStreamListener .class ));
569
+
570
+ // Must be set before start(), and may be overwritten
571
+ inOrder .verify (mockRealStream ).setAuthority ("authority-override-hostname-from-lb" );
572
+ inOrder .verify (mockRealStream ).setAuthority ("authority-override-from-calloptions" );
573
+ inOrder .verify (mockRealStream ).start (any (ClientStreamListener .class ));
588
574
}
589
575
590
576
@ Test
0 commit comments