From 252cea1149c3967f57033f9c28efce5ff6fdcbce Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Thu, 10 Dec 2020 19:02:51 +0100 Subject: [PATCH] SINT: MAM test does not require XEP-0441 The MAM integration test setup attepts to set MAM preferences (XEP-0441). When a server does not support this XEP, the setup phase errors out, preventing the tests from being executed. There is no functional reason why tests shouldn't be run when XEP-0441 is not supported: the tests can run against the default configuration of the MAM service. This commit ignores feature-not-implemented errors when MAM preferences are set. [Ignore only feature-not-implemented errors, log ignored errors) Modified-by: Florian Schmaus --- .../smackx/mam/MamIntegrationTest.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/smack-integration-test/src/main/java/org/jivesoftware/smackx/mam/MamIntegrationTest.java b/smack-integration-test/src/main/java/org/jivesoftware/smackx/mam/MamIntegrationTest.java index cb4751d21..046a33ac6 100644 --- a/smack-integration-test/src/main/java/org/jivesoftware/smackx/mam/MamIntegrationTest.java +++ b/smack-integration-test/src/main/java/org/jivesoftware/smackx/mam/MamIntegrationTest.java @@ -1,6 +1,6 @@ /** * - * Copyright 2016 Fernando Ramirez, 2018-2020 Florian Schmaus + * Copyright 2016 Fernando Ramirez, 2018-2021 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeoutException; +import java.util.logging.Level; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; @@ -33,7 +34,7 @@ import org.jivesoftware.smack.filter.MessageWithBodiesFilter; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.StanzaBuilder; - +import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smackx.mam.MamManager.MamQuery; import org.jivesoftware.smackx.mam.MamManager.MamQueryArgs; @@ -59,7 +60,17 @@ public class MamIntegrationTest extends AbstractSmackIntegrationTest { } // Make sure MAM is archiving messages. - mamManagerConTwo.enableMamForAllMessages(); + try { + mamManagerConTwo.enableMamForAllMessages(); + } catch (XMPPErrorException e) { + // Note that we check for feature-not-implemented (and not service-unavailable), as the server understand + // the MAM namespace, but may not the IQ. + if (e.getStanzaError().getCondition() != StanzaError.Condition.feature_not_implemented) { + throw e; + } + + LOGGER.log(Level.INFO, conTwo.getXMPPServiceDomain() + " doesn't support XEP-0441: Message Archive Management Preferences", e); + } } @SmackIntegrationTest