|
17 | 17 | import org.reactivestreams.tck.support.SubscriberBufferOverflowException;
|
18 | 18 | import org.reactivestreams.tck.support.Optional;
|
19 | 19 |
|
| 20 | +import java.util.Collections; |
20 | 21 | import java.util.LinkedList;
|
21 | 22 | import java.util.List;
|
22 | 23 | import java.util.concurrent.ArrayBlockingQueue;
|
@@ -513,14 +514,24 @@ public void expectCompletion(long timeoutMillis, String errorMsg) throws Interru
|
513 | 514 | public <E extends Throwable> void expectErrorWithMessage(Class<E> expected, String requiredMessagePart) throws Exception {
|
514 | 515 | expectErrorWithMessage(expected, requiredMessagePart, env.defaultTimeoutMillis());
|
515 | 516 | }
|
| 517 | + public <E extends Throwable> void expectErrorWithMessage(Class<E> expected, List<String> requiredMessagePartAlternatives) throws Exception { |
| 518 | + expectErrorWithMessage(expected, requiredMessagePartAlternatives, env.defaultTimeoutMillis()); |
| 519 | + } |
516 | 520 |
|
517 | 521 | @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
|
518 | 522 | public <E extends Throwable> void expectErrorWithMessage(Class<E> expected, String requiredMessagePart, long timeoutMillis) throws Exception {
|
| 523 | + expectErrorWithMessage(expected, Collections.singletonList(requiredMessagePart), timeoutMillis); |
| 524 | + } |
| 525 | + public <E extends Throwable> void expectErrorWithMessage(Class<E> expected, List<String> requiredMessagePartAlternatives, long timeoutMillis) throws Exception { |
519 | 526 | final E err = expectError(expected, timeoutMillis);
|
520 | 527 | final String message = err.getMessage();
|
521 |
| - assertTrue(message.contains(requiredMessagePart), |
| 528 | + |
| 529 | + boolean contains = false; |
| 530 | + for (String requiredMessagePart : requiredMessagePartAlternatives) |
| 531 | + if (message.contains(requiredMessagePart)) contains = true; // not short-circuting loop, it is expected to |
| 532 | + assertTrue(contains, |
522 | 533 | String.format("Got expected exception [%s] but missing message part [%s], was: %s",
|
523 |
| - err.getClass(), requiredMessagePart, err.getMessage())); |
| 534 | + err.getClass(), "anyOf: " + requiredMessagePartAlternatives, err.getMessage())); |
524 | 535 | }
|
525 | 536 |
|
526 | 537 | public <E extends Throwable> E expectError(Class<E> expected) throws Exception {
|
|
0 commit comments