Skip to content

Commit

Permalink
sint: add assertion implementation to SimpleResultSyncPoint
Browse files Browse the repository at this point in the history
By using an assertion, a test that uses a SimpleResultSyncPoint can now fail in a way equal to other test failures. This allows for failure messages to be defined.
  • Loading branch information
guusdk committed Apr 4, 2024
1 parent 92c45e0 commit 8e0a393
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.igniterealtime.smack.inttest.util;

import org.junit.jupiter.api.Assertions;

public class SimpleResultSyncPoint extends ResultSyncPoint<Boolean, Exception> {

public void signal() {
Expand All @@ -29,4 +31,14 @@ public void signalFailure() {
public void signalFailure(String failureMessage) {
signal(new Exception(failureMessage));
}

public static void assertSuccess(SimpleResultSyncPoint ResultSyncPoint, long timeout, String message) throws InterruptedException {
try {
ResultSyncPoint.waitForResult(timeout);
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
Assertions.fail(message, e);
}
}
}

0 comments on commit 8e0a393

Please sign in to comment.