Skip to content

Commit 5efa1ba

Browse files
authored
Fix SignalR transport test (#8424)
1 parent 107e186 commit 5efa1ba

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/SignalR/clients/java/signalr/src/test/java/com/microsoft/signalr/HubConnectionTest.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.concurrent.atomic.AtomicInteger;
1515
import java.util.concurrent.atomic.AtomicReference;
1616

17+
import io.reactivex.subjects.CompletableSubject;
1718
import io.reactivex.subjects.PublishSubject;
1819
import io.reactivex.subjects.ReplaySubject;
1920
import org.junit.jupiter.api.Disabled;
@@ -1495,19 +1496,21 @@ public void afterSuccessfulNegotiateConnectsWithLongPollingTransport() {
14951496
assertEquals("{\"protocol\":\"json\",\"version\":1}" + RECORD_SEPARATOR, sentMessages[0]);
14961497
}
14971498

1498-
@Disabled("https://github.com/aspnet/AspNetCore/issues/8262")
14991499
@Test
15001500
public void TransportAllUsesLongPollingWhenServerOnlySupportLongPolling() {
15011501
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\"]}]}")))
15061508
.on("GET", (req) -> {
1507-
if (requestCount.get() == 0) {
1509+
if (requestCount.get() < 2) {
15081510
requestCount.incrementAndGet();
1509-
return Single.just(new HttpResponse(200, "", ""));
1511+
return Single.just(new HttpResponse(200, "", "{}" + RECORD_SEPARATOR));
15101512
}
1513+
assertTrue(close.blockingAwait(5, TimeUnit.SECONDS));
15111514
return Single.just(new HttpResponse(204, "", ""));
15121515
});
15131516

@@ -1519,6 +1522,7 @@ public void TransportAllUsesLongPollingWhenServerOnlySupportLongPolling() {
15191522

15201523
hubConnection.start().timeout(1, TimeUnit.SECONDS).blockingAwait();
15211524
assertTrue(hubConnection.getTransport() instanceof LongPollingTransport);
1525+
close.onComplete();
15221526
hubConnection.stop().timeout(1, TimeUnit.SECONDS).blockingAwait();
15231527
}
15241528

0 commit comments

Comments
 (0)