Search in sources :

Example 41 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MUCLightCreateIQTest method checkCreateMUCLightStanza.

@Test
public void checkCreateMUCLightStanza() throws Exception {
    List<Jid> occupants = new ArrayList<>();
    occupants.add(JidCreate.from("charlie@test.com"));
    occupants.add(JidCreate.from("pep@test.com"));
    MUCLightCreateIQ mucLightCreateIQ = new MUCLightCreateIQ(JidCreate.from("ef498f55-5f79-4238-a5ae-4efe19cbe617@muclight.test.com").asEntityJidIfPossible(), "test", occupants);
    mucLightCreateIQ.setStanzaId("1c72W-50");
    Assert.assertEquals(mucLightCreateIQ.getConfiguration().getRoomName(), "test");
    HashMap<Jid, MUCLightAffiliation> iqOccupants = mucLightCreateIQ.getOccupants();
    Assert.assertEquals(iqOccupants.get(JidCreate.from("charlie@test.com")), MUCLightAffiliation.member);
    Assert.assertEquals(iqOccupants.get(JidCreate.from("pep@test.com")), MUCLightAffiliation.member);
}
Also used : Jid(org.jxmpp.jid.Jid) ArrayList(java.util.ArrayList) MUCLightCreateIQ(org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ) Test(org.junit.Test)

Example 42 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MUCLightGetAffiliationsTest method checkGetAffiliationsResponse.

@Test
public void checkGetAffiliationsResponse() throws Exception {
    IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getAffiliationsResponseExample);
    MUCLightAffiliationsIQ mucLightAffiliationsIQ = (MUCLightAffiliationsIQ) iqInfoResult;
    Assert.assertEquals("123456", mucLightAffiliationsIQ.getVersion());
    HashMap<Jid, MUCLightAffiliation> affiliations = mucLightAffiliationsIQ.getAffiliations();
    Assert.assertEquals(3, affiliations.size());
    Assert.assertEquals(MUCLightAffiliation.owner, affiliations.get(JidCreate.from("user1@shakespeare.lit")));
    Assert.assertEquals(MUCLightAffiliation.member, affiliations.get(JidCreate.from("user2@shakespeare.lit")));
    Assert.assertEquals(MUCLightAffiliation.member, affiliations.get(JidCreate.from("user3@shakespeare.lit")));
}
Also used : MUCLightAffiliationsIQ(org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ) Jid(org.jxmpp.jid.Jid) MUCLightAffiliationsIQ(org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ) MUCLightGetAffiliationsIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetAffiliationsIQ) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 43 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class PreferencesTest method checkUpdatePrefsStanza.

@Test
public void checkUpdatePrefsStanza() throws Exception {
    List<Jid> alwaysJids = new ArrayList<>();
    alwaysJids.add(JidCreate.from("romeo@montague.lit"));
    alwaysJids.add(JidCreate.from("other@montague.lit"));
    List<Jid> neverJids = new ArrayList<>();
    neverJids.add(JidCreate.from("montague@montague.lit"));
    MamPrefsIQ mamPrefIQ = new MamPrefsIQ(alwaysJids, neverJids, DefaultBehavior.roster);
    mamPrefIQ.setStanzaId("sarasa");
    Assert.assertEquals(mamPrefIQ.toXML().toString(), updatePrefsStanzaExample);
}
Also used : MamPrefsIQ(org.jivesoftware.smackx.mam.element.MamPrefsIQ) Jid(org.jxmpp.jid.Jid) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 44 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MUCLightAffiliationsChangeExtensionTest method checkAffiliationsChangeExtensionWithPrevVersion.

@Test
public void checkAffiliationsChangeExtensionWithPrevVersion() throws Exception {
    Message changeAffiliationsMessage = (Message) PacketParserUtils.parseStanza(exampleMessageStanzaWithPrevVersion);
    AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension.from(changeAffiliationsMessage);
    HashMap<Jid, MUCLightAffiliation> affiliations = affiliationsChangeExtension.getAffiliations();
    Assert.assertEquals(affiliations.size(), 2);
    Assert.assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
    Assert.assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
    Assert.assertEquals(affiliationsChangeExtension.getPrevVersion(), "njiokm");
    Assert.assertEquals(affiliationsChangeExtension.getVersion(), "qwerty");
}
Also used : Message(org.jivesoftware.smack.packet.Message) Jid(org.jxmpp.jid.Jid) AffiliationsChangeExtension(org.jivesoftware.smackx.muclight.element.MUCLightElements.AffiliationsChangeExtension) Test(org.junit.Test)

Example 45 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MUCLightAffiliationsChangeExtensionTest method checkAffiliationsChangeExtensionWithVersion.

@Test
public void checkAffiliationsChangeExtensionWithVersion() throws Exception {
    Message changeAffiliationsMessage = (Message) PacketParserUtils.parseStanza(exampleMessageStanzaWithVersion);
    AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension.from(changeAffiliationsMessage);
    HashMap<Jid, MUCLightAffiliation> affiliations = affiliationsChangeExtension.getAffiliations();
    Assert.assertEquals(affiliations.size(), 2);
    Assert.assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
    Assert.assertEquals(affiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
    Assert.assertEquals(affiliationsChangeExtension.getVersion(), "qwerty");
}
Also used : Message(org.jivesoftware.smack.packet.Message) Jid(org.jxmpp.jid.Jid) AffiliationsChangeExtension(org.jivesoftware.smackx.muclight.element.MUCLightElements.AffiliationsChangeExtension) Test(org.junit.Test)

Aggregations

Jid (org.jxmpp.jid.Jid)78 EntityBareJid (org.jxmpp.jid.EntityBareJid)18 ArrayList (java.util.ArrayList)15 HashMap (java.util.HashMap)14 Test (org.junit.Test)14 DomainBareJid (org.jxmpp.jid.DomainBareJid)14 EntityFullJid (org.jxmpp.jid.EntityFullJid)12 BareJid (org.jxmpp.jid.BareJid)11 IQ (org.jivesoftware.smack.packet.IQ)7 Presence (org.jivesoftware.smack.packet.Presence)7 MUCLightBlockingIQ (org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ)7 SmackException (org.jivesoftware.smack.SmackException)6 Message (org.jivesoftware.smack.packet.Message)6 WeakHashMap (java.util.WeakHashMap)4 XMPPConnection (org.jivesoftware.smack.XMPPConnection)4 Map (java.util.Map)3 SimpleResultSyncPoint (org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint)3 FeatureNotSupportedException (org.jivesoftware.smack.SmackException.FeatureNotSupportedException)3 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)3 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)3