xmpp-compliance-tester

XMPP Compliance Tester, forked from github.com/iNPUTmice/ComplianceTester
git clone https://git.in0rdr.ch/xmpp-compliance-tester.git
Log | Files | Refs | Pull requests |Archive | README | LICENSE

MamMuc.java (2144B)


      1 package eu.siacs.compliance.tests;
      2 
      3 import eu.siacs.compliance.Result;
      4 import eu.siacs.utils.TestUtils;
      5 import rocks.xmpp.core.XmppException;
      6 import rocks.xmpp.core.session.XmppClient;
      7 import rocks.xmpp.extensions.data.model.DataForm;
      8 import rocks.xmpp.extensions.disco.ServiceDiscoveryManager;
      9 import rocks.xmpp.extensions.muc.ChatRoom;
     10 import rocks.xmpp.extensions.muc.ChatService;
     11 import rocks.xmpp.extensions.muc.MultiUserChatManager;
     12 
     13 import java.util.List;
     14 import java.util.Set;
     15 import java.util.UUID;
     16 import java.util.concurrent.ExecutionException;
     17 
     18 public class MamMuc extends AbstractTest {
     19     public MamMuc(XmppClient client) {
     20         super(client);
     21     }
     22 
     23     @Override
     24     public Result run() {
     25         final ServiceDiscoveryManager serviceDiscoveryManager = client.getManager(ServiceDiscoveryManager.class);
     26         final MultiUserChatManager multiUserChatManager = client.getManager(MultiUserChatManager.class);
     27         try {
     28             List<ChatService> chatServices = multiUserChatManager.discoverChatServices().getResult();
     29             if (chatServices.size() < 1) {
     30                 return Result.FAILED;
     31             }
     32             final ChatService chatService = chatServices.get(0);
     33             final ChatRoom room = chatService.createRoom(UUID.randomUUID().toString());
     34             room.enter("test");
     35             try {
     36                 final DataForm.Field mam = room.getConfigurationForm().get().findField("mam");
     37                 if (mam != null) {
     38                     return Result.PASSED;
     39                 }
     40             } catch (ExecutionException | InterruptedException e) {
     41                 //ignore
     42             }
     43             final Set<String> features = serviceDiscoveryManager.discoverInformation(room.getAddress()).getResult().getFeatures();
     44             final boolean mam = TestUtils.hasAnyone(MAM.NAMESPACES,features);
     45             room.destroy().getResult();
     46             return mam ? Result.PASSED : Result.FAILED;
     47         } catch (XmppException e) {
     48             return Result.FAILED;
     49         }
     50     }
     51 
     52     @Override
     53     public String getName() {
     54         return "XEP-0313: Message Archive Management (MUC)";
     55     }
     56 }