Search in sources :

Example 81 with IQ

use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.

the class ThreadedDummyConnection method sendStanza.

@Override
public void sendStanza(Stanza packet) throws NotConnectedException, InterruptedException {
    super.sendStanza(packet);
    if (packet instanceof IQ && !timeout) {
        timeout = false;
        // Set reply packet to match one being sent. We haven't started the
        // other thread yet so this is still safe.
        IQ replyPacket = replyQ.peek();
        // If no reply has been set via addIQReply, then we create a simple reply
        if (replyPacket == null) {
            replyPacket = IQ.createResultIQ((IQ) packet);
            replyQ.add(replyPacket);
        }
        replyPacket.setStanzaId(packet.getStanzaId());
        replyPacket.setFrom(packet.getTo());
        replyPacket.setTo(packet.getFrom());
        replyPacket.setType(Type.result);
        new ProcessQueue(replyQ).start();
    }
}
Also used : IQ(org.jivesoftware.smack.packet.IQ)

Example 82 with IQ

use of org.jivesoftware.smack.packet.IQ 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 83 with IQ

use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.

the class MUCLightGetConfigsTest method checkGetConfigsResponse.

@Test
public void checkGetConfigsResponse() throws Exception {
    IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getConfigsResponseExample);
    MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) iqInfoResult;
    Assert.assertEquals("123456", mucLightConfigurationIQ.getVersion());
    Assert.assertEquals("A Dark Cave", mucLightConfigurationIQ.getConfiguration().getRoomName());
    Assert.assertEquals("A subject", mucLightConfigurationIQ.getConfiguration().getSubject());
    Assert.assertNull(mucLightConfigurationIQ.getConfiguration().getCustomConfigs());
}
Also used : MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightGetConfigsIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 84 with IQ

use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.

the class MUCLightGetConfigsTest method checkGetConfigsResponseWithCustomConfigs.

@Test
public void checkGetConfigsResponseWithCustomConfigs() throws Exception {
    IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getConfigsResponseExampleWithCustomConfigs);
    MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) iqInfoResult;
    Assert.assertEquals("123456", mucLightConfigurationIQ.getVersion());
    Assert.assertEquals("A Dark Cave", mucLightConfigurationIQ.getConfiguration().getRoomName());
    Assert.assertNull(mucLightConfigurationIQ.getConfiguration().getSubject());
    HashMap<String, String> customConfigs = mucLightConfigurationIQ.getConfiguration().getCustomConfigs();
    Assert.assertEquals("blue", customConfigs.get("color"));
    Assert.assertEquals("20", customConfigs.get("size"));
}
Also used : MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightGetConfigsIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 85 with IQ

use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.

the class MUCLightInfoTest method checkMUCLightInfoResult.

@Test
public void checkMUCLightInfoResult() throws Exception {
    IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(exampleInfoResult);
    MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) iqInfoResult;
    Assert.assertEquals(mucLightInfoResponseIQ.getVersion(), "123456");
    Assert.assertEquals(mucLightInfoResponseIQ.getConfiguration().getRoomName(), "test");
    Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().size(), 3);
    Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("john@test.com")), MUCLightAffiliation.owner);
    Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("charlie@test.com")), MUCLightAffiliation.member);
    Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("pep@test.com")), MUCLightAffiliation.member);
}
Also used : MUCLightInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ) MUCLightGetInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ) IQ(org.jivesoftware.smack.packet.IQ) MUCLightInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ) Test(org.junit.Test)

Aggregations

IQ (org.jivesoftware.smack.packet.IQ)138 Test (org.junit.Test)57 ErrorIQ (org.jivesoftware.smack.packet.ErrorIQ)12 Stanza (org.jivesoftware.smack.packet.Stanza)12 InputStream (java.io.InputStream)11 StanzaListener (org.jivesoftware.smack.StanzaListener)10 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)10 Data (org.jivesoftware.smackx.bytestreams.ibb.packet.Data)10 DataPacketExtension (org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension)10 OutputStream (java.io.OutputStream)9 ArrayList (java.util.ArrayList)9 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)8 XMPPError (org.jivesoftware.smack.packet.XMPPError)7 Jid (org.jxmpp.jid.Jid)7 NetworkException (com.xabber.android.data.NetworkException)6 OnResponseListener (com.xabber.android.data.connection.OnResponseListener)6 IOException (java.io.IOException)6 XMPPConnection (org.jivesoftware.smack.XMPPConnection)6 EmptyResultIQ (org.jivesoftware.smack.packet.EmptyResultIQ)6 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)6