1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

Merge pull request #583 from Flowdalic/sinttest-assert-result

[sinttest] Add AbstractSmackIntTest.assertResult()
This commit is contained in:
Florian Schmaus 2024-04-09 14:16:44 +00:00 committed by GitHub
commit d204d24223
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015-2020 Florian Schmaus
* Copyright 2015-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,6 +33,10 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.igniterealtime.smack.inttest.util.ResultSyncPoint;
import org.opentest4j.AssertionFailedError;
public abstract class AbstractSmackIntTest {
protected static final Logger LOGGER = Logger.getLogger(AbstractSmackIntTest.class.getName());
@ -90,4 +94,18 @@ public abstract class AbstractSmackIntTest {
}
return urlConnection;
}
public <R> R assertResult(ResultSyncPoint<R, ?> syncPoint, String message) throws InterruptedException, TimeoutException, AssertionFailedError {
return assertResult(syncPoint, timeout, message);
}
public static <R> R assertResult(ResultSyncPoint<R, ?> syncPoint, long timeout, String message) throws InterruptedException, TimeoutException, AssertionFailedError {
try {
return syncPoint.waitForResult(timeout);
} catch (InterruptedException | TimeoutException e) {
throw e;
} catch (Exception e) {
throw new AssertionFailedError(message, e);
}
}
}