|
|
|
@ -13,6 +13,7 @@ |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* limitations under the License. |
|
|
|
* limitations under the License. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.test.web.reactive.server.samples; |
|
|
|
package org.springframework.test.web.reactive.server.samples; |
|
|
|
|
|
|
|
|
|
|
|
import java.net.URI; |
|
|
|
import java.net.URI; |
|
|
|
@ -23,7 +24,6 @@ import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator; |
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator; |
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
|
import org.junit.Before; |
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
import reactor.core.publisher.Flux; |
|
|
|
import reactor.core.publisher.Flux; |
|
|
|
import reactor.core.publisher.Mono; |
|
|
|
import reactor.core.publisher.Mono; |
|
|
|
@ -48,17 +48,11 @@ import static org.springframework.http.MediaType.TEXT_EVENT_STREAM; |
|
|
|
* Annotated controllers accepting and returning typed Objects. |
|
|
|
* Annotated controllers accepting and returning typed Objects. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
|
|
|
|
* @since 5.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unused") |
|
|
|
|
|
|
|
public class ResponseEntityTests { |
|
|
|
public class ResponseEntityTests { |
|
|
|
|
|
|
|
|
|
|
|
private WebTestClient client; |
|
|
|
private final WebTestClient client = WebTestClient.bindToController(new PersonController()).build(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
|
|
|
public void setUp() throws Exception { |
|
|
|
|
|
|
|
this.client = WebTestClient.bindToController(new PersonController()).build(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -152,6 +146,7 @@ public class ResponseEntityTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(produces = "text/event-stream") |
|
|
|
@GetMapping(produces = "text/event-stream") |
|
|
|
|
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
Flux<Person> getPersonStream() { |
|
|
|
Flux<Person> getPersonStream() { |
|
|
|
return Flux.intervalMillis(100).onBackpressureBuffer(10).map(index -> new Person("N" + index)); |
|
|
|
return Flux.intervalMillis(100).onBackpressureBuffer(10).map(index -> new Person("N" + index)); |
|
|
|
} |
|
|
|
} |
|
|
|
|