Skip to content

Commit

Permalink
Merge pull request #164 from abutch3r/flaky_emitter_overflow_fail_tck
Browse files Browse the repository at this point in the history
Make Fail Overflow Test less flaky
  • Loading branch information
Azquelt authored Mar 22, 2024
2 parents 62b50c8 + 3a5eeb5 commit e025074
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ public Exception exception() {
return callerException;
}

public void emitThree() {
public void emitOne() {
try {
emitter.send("1");
emitter.send("2");
emitter.send("3");
emitter.complete();
emitter.send("1000");
} catch (Exception e) {
callerException = e;
}
Expand All @@ -95,10 +92,14 @@ public void emitALotOfItems() {
@Outgoing("out")
public PublisherBuilder<String> consume(final PublisherBuilder<String> values) {
return values
.via(ReactiveStreams.<String>builder()
.flatMapCompletionStage(s -> CompletableFuture.supplyAsync(() -> s, executor)))
.onError(err -> downstreamFailure = err);

.via(ReactiveStreams.<String>builder().flatMapCompletionStage(s -> CompletableFuture.supplyAsync(() -> {
try {
Thread.sleep(1);
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
return s;
}, executor))).onError(err -> downstreamFailure = err);
}

@Incoming("out")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public static Archive<JavaArchive> deployment() {
public void testOverflow() {
bean.emitALotOfItems();

await().until(() -> bean.exception() != null);
await().until(() -> bean.failure() != null);
assertThat(bean.failure()).isInstanceOf(Exception.class);
assertThat(bean.output()).doesNotContain("999");
assertThat(bean.output()).hasSizeBetween(0, 256);
assertThat(bean.failure()).isNotNull().isInstanceOf(Exception.class);
assertThat(bean.output()).hasSizeLessThan(999);
assertThat(bean.exception()).isInstanceOf(IllegalStateException.class);

}
}

0 comments on commit e025074

Please sign in to comment.