1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

Merge pull request #589 from guusdk/sint_syncpoint_timeoutmessage

[sinttest] Carry over assertion message when sync point times out
This commit is contained in:
Florian Schmaus 2024-04-17 10:43:35 +00:00 committed by GitHub
commit 37f4f35675
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -101,7 +101,7 @@ public abstract class AbstractSmackIntTest {
public static <R> R assertResult(ResultSyncPoint<R, ?> syncPoint, long timeout, String message) throws InterruptedException, TimeoutException, AssertionFailedError {
try {
return syncPoint.waitForResult(timeout);
return syncPoint.waitForResult(timeout, message);
} catch (InterruptedException | TimeoutException e) {
throw e;
} catch (Exception e) {

View file

@ -26,6 +26,10 @@ public class ResultSyncPoint<R, E extends Exception> {
private E exception;
public R waitForResult(long timeout) throws E, InterruptedException, TimeoutException {
return waitForResult(timeout, null);
}
public R waitForResult(long timeout, String timeoutMessage) throws E, InterruptedException, TimeoutException {
synchronized (this) {
if (result != null) {
return result;
@ -46,7 +50,7 @@ public class ResultSyncPoint<R, E extends Exception> {
if (exception != null) {
throw exception;
}
throw new TimeoutException("Timeout expired");
throw new TimeoutException(timeoutMessage == null ? "Timeout expired" : timeoutMessage);
}