Stabilize Flux.interval emissions in integration tests
After this commit the use of interval in tests is combined with take(n).onBackpressureBuffer(n) to ensure emissions don't fail if the fixed rate is exceeded (e.g. on slow CI server). Tests that verify N number of items followed by verifyOnComplete() should set the number of emissions to N. Tests that verify N number of items followed by thenCancel() should set the number of buffered to an arbitrary number greater than N.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,7 +59,7 @@ public class ResponseEntityTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void entity() throws Exception {
|
||||
public void entity() {
|
||||
this.client.get().uri("/John")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
@@ -68,7 +68,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityWithConsumer() throws Exception {
|
||||
public void entityWithConsumer() {
|
||||
this.client.get().uri("/John")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
@@ -78,7 +78,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityList() throws Exception {
|
||||
public void entityList() {
|
||||
|
||||
List<Person> expected = Arrays.asList(
|
||||
new Person("Jane"), new Person("Jason"), new Person("John"));
|
||||
@@ -91,7 +91,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityMap() throws Exception {
|
||||
public void entityMap() {
|
||||
|
||||
Map<String, Person> map = new LinkedHashMap<>();
|
||||
map.put("Jane", new Person("Jane"));
|
||||
@@ -105,7 +105,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityStream() throws Exception {
|
||||
public void entityStream() {
|
||||
|
||||
FluxExchangeResult<Person> result = this.client.get()
|
||||
.accept(TEXT_EVENT_STREAM)
|
||||
@@ -123,7 +123,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postEntity() throws Exception {
|
||||
public void postEntity() {
|
||||
this.client.post()
|
||||
.syncBody(new Person("John"))
|
||||
.exchange()
|
||||
@@ -158,7 +158,8 @@ public class ResponseEntityTests {
|
||||
|
||||
@GetMapping(produces = "text/event-stream")
|
||||
Flux<Person> getPersonStream() {
|
||||
return Flux.interval(ofMillis(100)).onBackpressureBuffer(10).map(index -> new Person("N" + index));
|
||||
return Flux.interval(ofMillis(100)).take(50).onBackpressureBuffer(50)
|
||||
.map(index -> new Person("N" + index));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
|
||||
Reference in New Issue
Block a user