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();
}
}
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")));
}
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());
}
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"));
}
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);
}
Aggregations