Search in sources :

Example 1 with SseClient

use of io.micronaut.http.client.sse.SseClient in project micronaut-core by micronaut-projects.

the class HeadlineControllerSpec method testConsumeEventStreamObject.

@Test
public void testConsumeEventStreamObject() {
    SseClient client = embeddedServer.getApplicationContext().createBean(SseClient.class, embeddedServer.getURL());
    List<Event<Headline>> events = new ArrayList<>();
    Flux.from(client.eventStream(HttpRequest.GET("/headlines"), Headline.class)).subscribe(events::add);
    await().until(() -> events.size() == 2);
    assertEquals("Micronaut 1.0 Released", events.get(0).getData().getTitle());
    assertEquals("Come and get it", events.get(0).getData().getDescription());
}
Also used : SseClient(io.micronaut.http.client.sse.SseClient) ArrayList(java.util.ArrayList) Event(io.micronaut.http.sse.Event) Test(org.junit.Test)

Aggregations

SseClient (io.micronaut.http.client.sse.SseClient)1 Event (io.micronaut.http.sse.Event)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1