14
14
import java .util .concurrent .atomic .AtomicInteger ;
15
15
import java .util .concurrent .atomic .AtomicReference ;
16
16
17
+ import io .reactivex .subjects .CompletableSubject ;
17
18
import io .reactivex .subjects .PublishSubject ;
18
19
import io .reactivex .subjects .ReplaySubject ;
19
20
import org .junit .jupiter .api .Disabled ;
@@ -1495,19 +1496,21 @@ public void afterSuccessfulNegotiateConnectsWithLongPollingTransport() {
1495
1496
assertEquals ("{\" protocol\" :\" json\" ,\" version\" :1}" + RECORD_SEPARATOR , sentMessages [0 ]);
1496
1497
}
1497
1498
1498
- @ Disabled ("https://github.com/aspnet/AspNetCore/issues/8262" )
1499
1499
@ Test
1500
1500
public void TransportAllUsesLongPollingWhenServerOnlySupportLongPolling () {
1501
1501
AtomicInteger requestCount = new AtomicInteger (0 );
1502
- TestHttpClient client = new TestHttpClient ().on ("POST" ,
1503
- (req ) -> Single .just (new HttpResponse (200 , "" ,
1504
- "{\" connectionId\" :\" bVOiRPG8-6YiJ6d7ZcTOVQ\" ,\" "
1505
- + "availableTransports\" :[{\" transport\" :\" LongPolling\" ,\" transferFormats\" :[\" Text\" ,\" Binary\" ]}]}" )))
1502
+ CompletableSubject close = CompletableSubject .create ();
1503
+ TestHttpClient client = new TestHttpClient ()
1504
+ .on ("POST" ,
1505
+ (req ) -> Single .just (new HttpResponse (200 , "" ,
1506
+ "{\" connectionId\" :\" bVOiRPG8-6YiJ6d7ZcTOVQ\" ,\" "
1507
+ + "availableTransports\" :[{\" transport\" :\" LongPolling\" ,\" transferFormats\" :[\" Text\" ,\" Binary\" ]}]}" )))
1506
1508
.on ("GET" , (req ) -> {
1507
- if (requestCount .get () == 0 ) {
1509
+ if (requestCount .get () < 2 ) {
1508
1510
requestCount .incrementAndGet ();
1509
- return Single .just (new HttpResponse (200 , "" , "" ));
1511
+ return Single .just (new HttpResponse (200 , "" , "{}" + RECORD_SEPARATOR ));
1510
1512
}
1513
+ assertTrue (close .blockingAwait (5 , TimeUnit .SECONDS ));
1511
1514
return Single .just (new HttpResponse (204 , "" , "" ));
1512
1515
});
1513
1516
@@ -1519,6 +1522,7 @@ public void TransportAllUsesLongPollingWhenServerOnlySupportLongPolling() {
1519
1522
1520
1523
hubConnection .start ().timeout (1 , TimeUnit .SECONDS ).blockingAwait ();
1521
1524
assertTrue (hubConnection .getTransport () instanceof LongPollingTransport );
1525
+ close .onComplete ();
1522
1526
hubConnection .stop ().timeout (1 , TimeUnit .SECONDS ).blockingAwait ();
1523
1527
}
1524
1528
0 commit comments