mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
[sinttest] Try to find MUC service where MUC creation is possible
This commit is contained in:
parent
050acc4c53
commit
17d9b742fc
6 changed files with 64 additions and 10 deletions
|
@ -18,10 +18,16 @@
|
|||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MissingMucCreationAcknowledgeException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MucAlreadyJoinedException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.NotAMucServiceException;
|
||||
import org.jivesoftware.smackx.xdata.form.FillableForm;
|
||||
import org.jivesoftware.smackx.xdata.form.Form;
|
||||
|
||||
|
@ -47,7 +53,7 @@ public abstract class AbstractMultiUserChatIntegrationTest extends AbstractSmack
|
|||
|
||||
public AbstractMultiUserChatIntegrationTest(SmackIntegrationTestEnvironment environment)
|
||||
throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
|
||||
InterruptedException, TestNotPossibleException {
|
||||
InterruptedException, TestNotPossibleException, MucAlreadyJoinedException, MissingMucCreationAcknowledgeException, NotAMucServiceException, XmppStringprepException {
|
||||
super(environment);
|
||||
mucManagerOne = MultiUserChatManager.getInstanceFor(conOne);
|
||||
mucManagerTwo = MultiUserChatManager.getInstanceFor(conTwo);
|
||||
|
@ -55,10 +61,40 @@ public abstract class AbstractMultiUserChatIntegrationTest extends AbstractSmack
|
|||
|
||||
List<DomainBareJid> services = mucManagerOne.getMucServiceDomains();
|
||||
if (services.isEmpty()) {
|
||||
throw new TestNotPossibleException("No MUC (XEP-45) service found");
|
||||
throw new TestNotPossibleException("No MUC (XEP-0045) service found");
|
||||
}
|
||||
|
||||
mucService = services.get(0);
|
||||
DomainBareJid needle = null;
|
||||
for (final DomainBareJid service : services) {
|
||||
MultiUserChat multiUserChat = null;
|
||||
try {
|
||||
String roomNameLocal = String.join("-", "smack-inttest-abstract", testRunId, StringUtils.insecureRandomString(6));
|
||||
EntityBareJid mucAddress = JidCreate.entityBareFrom(Localpart.from(roomNameLocal), service.getDomain());
|
||||
multiUserChat = mucManagerOne.getMultiUserChat(mucAddress);
|
||||
|
||||
createMuc(multiUserChat, "test");
|
||||
|
||||
needle = service;
|
||||
break;
|
||||
} catch (XMPPException.XMPPErrorException e) {
|
||||
mucCreationDisallowedOrThrow(e);
|
||||
LOGGER.log(Level.FINER, "MUC service " + service + " does not allow MUC creation", e);
|
||||
} finally {
|
||||
tryDestroy(multiUserChat);
|
||||
}
|
||||
}
|
||||
|
||||
if (needle == null) {
|
||||
throw new TestNotPossibleException("No MUC (XEP-0045) service found that allows test users to createa new room. Considered MUC services: " + services);
|
||||
}
|
||||
mucService = needle;
|
||||
}
|
||||
|
||||
static void mucCreationDisallowedOrThrow(XMPPException.XMPPErrorException e) throws XMPPErrorException {
|
||||
StanzaError.Condition condition = e.getStanzaError().getCondition();
|
||||
if (condition == StanzaError.Condition.not_allowed)
|
||||
return;
|
||||
throw e;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,9 @@ import org.jivesoftware.smack.packet.StanzaError;
|
|||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MissingMucCreationAcknowledgeException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MucAlreadyJoinedException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.NotAMucServiceException;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCInitialPresence;
|
||||
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
|
@ -42,13 +45,14 @@ import org.jxmpp.jid.DomainBareJid;
|
|||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
@SpecificationReference(document = "XEP-0045", version = "1.34.6")
|
||||
public class MultiUserChatEntityIntegrationTest extends AbstractMultiUserChatIntegrationTest {
|
||||
|
||||
public MultiUserChatEntityIntegrationTest(SmackIntegrationTestEnvironment environment)
|
||||
throws SmackException.NoResponseException, XMPPException.XMPPErrorException,
|
||||
SmackException.NotConnectedException, InterruptedException, TestNotPossibleException {
|
||||
SmackException.NotConnectedException, InterruptedException, TestNotPossibleException, MucAlreadyJoinedException, MissingMucCreationAcknowledgeException, NotAMucServiceException, XmppStringprepException {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class MultiUserChatIntegrationTest extends AbstractMultiUserChatIntegrati
|
|||
|
||||
public MultiUserChatIntegrationTest(SmackIntegrationTestEnvironment environment)
|
||||
throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
|
||||
InterruptedException, TestNotPossibleException {
|
||||
InterruptedException, TestNotPossibleException, MucAlreadyJoinedException, MissingMucCreationAcknowledgeException, NotAMucServiceException, XmppStringprepException {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -68,7 +68,13 @@ public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelI
|
|||
final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom(
|
||||
Localpart.from(randomMucName), mucComponent));
|
||||
|
||||
MucCreateConfigFormHandle handle = muc.createOrJoin(mucNickname);
|
||||
MucCreateConfigFormHandle handle;
|
||||
try {
|
||||
handle = muc.createOrJoin(mucNickname);
|
||||
} catch (XMPPException.XMPPErrorException e) {
|
||||
AbstractMultiUserChatIntegrationTest.mucCreationDisallowedOrThrow(e);
|
||||
throw new TestNotPossibleException("MUC service " + mucComponent + " does not allow MUC creation", e);
|
||||
}
|
||||
if (handle != null) {
|
||||
handle.makeInstant();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,10 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.sm.predicates.ForEveryMessage;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MissingMucCreationAcknowledgeException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MucAlreadyJoinedException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MucConfigurationNotSupportedException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.NotAMucServiceException;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCItem;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
|
||||
|
@ -56,13 +59,14 @@ import org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint;
|
|||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
@SpecificationReference(document = "XEP-0045", version = "1.34.6")
|
||||
public class MultiUserChatOccupantIntegrationTest extends AbstractMultiUserChatIntegrationTest {
|
||||
|
||||
public MultiUserChatOccupantIntegrationTest(SmackIntegrationTestEnvironment environment)
|
||||
throws SmackException.NoResponseException, XMPPException.XMPPErrorException,
|
||||
SmackException.NotConnectedException, InterruptedException, TestNotPossibleException {
|
||||
SmackException.NotConnectedException, InterruptedException, TestNotPossibleException, MucAlreadyJoinedException, MissingMucCreationAcknowledgeException, NotAMucServiceException, XmppStringprepException {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2021 Florian Schmaus, Dan Caseley
|
||||
* Copyright 2021-2024 Florian Schmaus, Dan Caseley
|
||||
*
|
||||
* 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,9 @@ import java.util.stream.Collectors;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MissingMucCreationAcknowledgeException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MucAlreadyJoinedException;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatException.NotAMucServiceException;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
|
@ -45,6 +48,7 @@ import org.jxmpp.jid.EntityFullJid;
|
|||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
|
||||
@SpecificationReference(document = "XEP-0045", version = "1.34.6")
|
||||
|
@ -52,7 +56,7 @@ public class MultiUserChatRolesAffiliationsPrivilegesIntegrationTest extends Abs
|
|||
|
||||
public MultiUserChatRolesAffiliationsPrivilegesIntegrationTest(SmackIntegrationTestEnvironment environment)
|
||||
throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
|
||||
InterruptedException, TestNotPossibleException {
|
||||
InterruptedException, TestNotPossibleException, MucAlreadyJoinedException, MissingMucCreationAcknowledgeException, NotAMucServiceException, XmppStringprepException {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue