Skip to content

Commit

Permalink
Merge in 'release/6.0' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Jan 8, 2022
2 parents 6cb75ef + 0d741f1 commit ef1b49b
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void StatusCode204StopsLongPollingTriggersOnClosed() {

assertFalse(onClosedRan.get());
transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
assertTrue(block.blockingAwait(1, TimeUnit.SECONDS));
assertTrue(block.blockingAwait(30, TimeUnit.SECONDS));
assertTrue(onClosedRan.get());
assertFalse(transport.isActive());
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public void LongPollingFailsWhenReceivingUnexpectedErrorCode() {
});

transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
assertTrue(blocker.blockingAwait(1, TimeUnit.SECONDS));
assertTrue(blocker.blockingAwait(30, TimeUnit.SECONDS));
assertFalse(transport.isActive());
assertTrue(onClosedRan.get());
}
Expand All @@ -126,7 +126,6 @@ public void CanSetAndTriggerOnReceive() {
assertTrue(onReceivedRan.get());
}

@Disabled("https://github.com/dotnet/aspnetcore/issues/34563")
@Test
public void LongPollingTransportOnReceiveGetsCalled() {
AtomicInteger requestCount = new AtomicInteger();
Expand Down Expand Up @@ -158,7 +157,7 @@ public void LongPollingTransportOnReceiveGetsCalled() {
transport.setOnClose((error) -> {});

transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
assertTrue(block.blockingAwait(1,TimeUnit.SECONDS));
assertTrue(block.blockingAwait(30,TimeUnit.SECONDS));
assertTrue(onReceiveCalled.get());
assertEquals("TEST", message.get());
}
Expand Down Expand Up @@ -203,7 +202,7 @@ public void LongPollingTransportOnReceiveGetsCalledMultipleTimes() {
transport.setOnClose((error) -> {});

transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
assertTrue(blocker.blockingAwait(1, TimeUnit.SECONDS));
assertTrue(blocker.blockingAwait(30, TimeUnit.SECONDS));
assertTrue(onReceiveCalled.get());
assertEquals("FIRSTSECONDTHIRD", message.get());
}
Expand All @@ -219,7 +218,7 @@ public void LongPollingTransportSendsHeaders() {
requestCount.incrementAndGet();
return Single.just(new HttpResponse(200, "", TestUtils.emptyByteBuffer));
}
assertTrue(close.blockingAwait(1, TimeUnit.SECONDS));
assertTrue(close.blockingAwait(30, TimeUnit.SECONDS));
return Single.just(new HttpResponse(204, "", TestUtils.emptyByteBuffer));
}).on("POST", (req) -> {
assertFalse(req.getHeaders().isEmpty());
Expand All @@ -234,7 +233,7 @@ public void LongPollingTransportSendsHeaders() {

transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
ByteBuffer sendBuffer = TestUtils.stringToByteBuffer("TEST");
assertTrue(transport.send(sendBuffer).blockingAwait(1, TimeUnit.SECONDS));
assertTrue(transport.send(sendBuffer).blockingAwait(30, TimeUnit.SECONDS));
close.onComplete();
assertEquals(headerValue.get(), "VALUE");
}
Expand All @@ -250,7 +249,7 @@ public void LongPollingTransportSetsAuthorizationHeader() {
requestCount.incrementAndGet();
return Single.just(new HttpResponse(200, "", TestUtils.emptyByteBuffer));
}
assertTrue(close.blockingAwait(1, TimeUnit.SECONDS));
assertTrue(close.blockingAwait(30, TimeUnit.SECONDS));
return Single.just(new HttpResponse(204, "", TestUtils.emptyByteBuffer));
})
.on("POST", (req) -> {
Expand All @@ -266,7 +265,7 @@ public void LongPollingTransportSetsAuthorizationHeader() {

transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
ByteBuffer sendBuffer = TestUtils.stringToByteBuffer("TEST");
assertTrue(transport.send(sendBuffer).blockingAwait(1, TimeUnit.SECONDS));
assertTrue(transport.send(sendBuffer).blockingAwait(30, TimeUnit.SECONDS));
assertEquals(headerValue.get(), "Bearer TOKEN");
close.onComplete();
}
Expand All @@ -285,7 +284,7 @@ public void LongPollingTransportRunsAccessTokenProviderEveryRequest() {
}
assertEquals("Bearer TOKEN1", req.getHeaders().get("Authorization"));
secondGet.onComplete();
assertTrue(close.blockingAwait(1, TimeUnit.SECONDS));
assertTrue(close.blockingAwait(30, TimeUnit.SECONDS));
return Single.just(new HttpResponse(204, "", TestUtils.emptyByteBuffer));
})
.on("POST", (req) -> {
Expand All @@ -301,9 +300,9 @@ public void LongPollingTransportRunsAccessTokenProviderEveryRequest() {
transport.setOnClose((error) -> {});

transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
secondGet.blockingAwait(1, TimeUnit.SECONDS);
secondGet.blockingAwait(30, TimeUnit.SECONDS);
ByteBuffer sendBuffer = TestUtils.stringToByteBuffer("TEST");
assertTrue(transport.send(sendBuffer).blockingAwait(1, TimeUnit.SECONDS));
assertTrue(transport.send(sendBuffer).blockingAwait(30, TimeUnit.SECONDS));
assertEquals("Bearer TOKEN2", headerValue.get());
close.onComplete();
}
Expand Down Expand Up @@ -336,12 +335,12 @@ public void After204StopDoesNotTriggerOnCloseAgain() {

assertFalse(onClosedRan.get());
transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
assertTrue(block.blockingAwait(1, TimeUnit.SECONDS));
assertTrue(block.blockingAwait(30, TimeUnit.SECONDS));
assertEquals(1, onCloseCount.get());
assertTrue(onClosedRan.get());
assertFalse(transport.isActive());

assertTrue(transport.stop().blockingAwait(1, TimeUnit.SECONDS));
assertTrue(transport.stop().blockingAwait(30, TimeUnit.SECONDS));
assertEquals(1, onCloseCount.get());
}

Expand All @@ -355,7 +354,7 @@ public void StoppingTransportRunsCloseHandlersOnce() {
firstPoll.set(false);
return Single.just(new HttpResponse(200, "", TestUtils.emptyByteBuffer));
} else {
assertTrue(block.blockingAwait(1, TimeUnit.SECONDS));
assertTrue(block.blockingAwait(30, TimeUnit.SECONDS));
return Single.just(new HttpResponse(204, "", TestUtils.emptyByteBuffer));
}
})
Expand All @@ -374,7 +373,7 @@ public void StoppingTransportRunsCloseHandlersOnce() {

assertEquals(0, onCloseCount.get());
transport.start("http://example.com").timeout(30, TimeUnit.SECONDS).blockingAwait();
assertTrue(transport.stop().blockingAwait(1, TimeUnit.SECONDS));
assertTrue(transport.stop().blockingAwait(30, TimeUnit.SECONDS));
assertEquals(1, onCloseCount.get());
assertFalse(transport.isActive());
}
Expand Down

0 comments on commit ef1b49b

Please sign in to comment.