From 1584d3df29c28dacc595990bfae1f35054100ee1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 4 Apr 2024 20:29:32 +0200 Subject: [PATCH] [sinttest] Add AbstractSmackIntTest.assertResult() --- .../smack/inttest/AbstractSmackIntTest.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/AbstractSmackIntTest.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/AbstractSmackIntTest.java index 2b94b21903..e5b49692f6 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/AbstractSmackIntTest.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/AbstractSmackIntTest.java @@ -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. @@ -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 { @@ -90,4 +92,18 @@ protected HttpURLConnection getHttpUrlConnectionFor(URL url) throws IOException } return urlConnection; } + + public R assertResult(ResultSyncPoint syncPoint, String message) throws InterruptedException, TimeoutException, AssertionFailedError { + return assertResult(syncPoint, timeout, message); + } + + public static R assertResult(ResultSyncPoint 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); + } + } }