use of javax.ws.rs.sse.SseEventSource in project cxf by apache.
the class SseEventSourceImplTest method testNoReconnectWhenRetryAfterIsReturned.
@Test
public void testNoReconnectWhenRetryAfterIsReturned() {
try (SseEventSource eventSource = withNoReconnect(Type.RETRY_AFTER)) {
eventSource.open();
assertThat(eventSource.isOpen(), equalTo(false));
await().atMost(Duration.ofMillis(3000L)).untilAsserted(() -> assertThat(eventSource.isOpen(), equalTo(true)));
assertThat(events.size(), equalTo(1));
}
}
use of javax.ws.rs.sse.SseEventSource in project cxf by apache.
the class SseEventSourceImplTest method testReuseSameEventSourceSeveralTimes.
@Test
public void testReuseSameEventSourceSeveralTimes() {
try (SseEventSource eventSource = withNoReconnect(Type.NO_CONTENT)) {
eventSource.open();
assertThat(eventSource.isOpen(), equalTo(false));
eventSource.open();
assertThat(eventSource.isOpen(), equalTo(false));
assertThat(events.size(), equalTo(0));
}
}
use of javax.ws.rs.sse.SseEventSource in project cxf by apache.
the class SseEventSourceImplTest method testNoReconnectAndMixedEventsAreReceived.
@Test
public void testNoReconnectAndMixedEventsAreReceived() throws InterruptedException, IOException {
try (SseEventSource eventSource = withNoReconnect(Type.EVENT_MIXED)) {
eventSource.open();
assertThat(eventSource.isOpen(), equalTo(true));
// Allow the event processor to pull for events (150ms)
Thread.sleep(150L);
}
await().atMost(Duration.ofMillis(500L)).untilAsserted(() -> assertThat(events.size(), equalTo(2)));
assertThat(events.get(0).getName(), nullValue());
assertThat(events.get(0).readData(), equalTo("just test data"));
assertThat(events.get(1).getId(), equalTo("1"));
assertThat(events.get(1).getReconnectDelay(), equalTo(10000L));
assertThat(events.get(1).getComment(), equalTo("test comment"));
assertThat(events.get(1).readData(), equalTo("test data"));
}
use of javax.ws.rs.sse.SseEventSource in project cxf by apache.
the class SseEventSourceImplTest method testNoReconnectWhenNoContentIsReturned.
@Test
public void testNoReconnectWhenNoContentIsReturned() {
try (SseEventSource eventSource = withNoReconnect(Type.NO_CONTENT)) {
eventSource.open();
assertThat(eventSource.isOpen(), equalTo(false));
assertThat(events.size(), equalTo(0));
}
}
use of javax.ws.rs.sse.SseEventSource in project cxf by apache.
the class SseEventSourceImplTest method testReconnectAndNotAuthorized.
@Test
public void testReconnectAndNotAuthorized() throws InterruptedException, IOException {
try (SseEventSource eventSource = withReconnect(Type.EVENT_NOT_AUTHORIZED)) {
eventSource.open();
assertThat(eventSource.isOpen(), equalTo(false));
assertThat(errors.size(), equalTo(1));
// Allow the event processor to pull for events (150ms)
Thread.sleep(150L);
}
await().atMost(Duration.ofMillis(500L)).untilAsserted(() -> assertThat(errors.size(), equalTo(2)));
assertThat(events.size(), equalTo(0));
}
Aggregations