Skip to content

Commit

Permalink
[sinttest] Add AbstractSmackIntTest.assertResult()
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowdalic committed Apr 4, 2024
1 parent 7139a43 commit 1584d3d
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -32,6 +32,8 @@
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.opentest4j.AssertionFailedError;
import org.igniterealtime.smack.inttest.util.ResultSyncPoint;

public abstract class AbstractSmackIntTest {

Expand Down Expand Up @@ -90,4 +92,18 @@ protected HttpURLConnection getHttpUrlConnectionFor(URL url) throws IOException
}
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);
}
}
}

0 comments on commit 1584d3d

Please sign in to comment.