use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class VersionTest method checkProvider.
@Test
public void checkProvider() throws Exception {
// @formatter:off
String control = "<iq from='capulet.lit' to='juliet@capulet.lit/balcony' id='s2c1' type='get'>" + "<query xmlns='jabber:iq:version'/>" + "</iq>";
// @formatter:on
DummyConnection con = new DummyConnection();
con.connect();
// Enable version replys for this connection
VersionManager.setAutoAppendSmackVersion(false);
VersionManager.getInstanceFor(con).setVersion("Test", "0.23", "DummyOS");
IQ versionRequest = (IQ) PacketParserUtils.parseStanza(control);
assertTrue(versionRequest instanceof Version);
con.processStanza(versionRequest);
Stanza replyPacket = con.getSentPacket();
assertTrue(replyPacket instanceof Version);
Version reply = (Version) replyPacket;
//getFrom check is pending for SMACK-547
//assertEquals("juliet@capulet.lit/balcony", reply.getFrom());
assertThat("capulet.lit", equalsCharSequence(reply.getTo()));
assertEquals("s2c1", reply.getStanzaId());
assertEquals(IQ.Type.result, reply.getType());
assertEquals("Test", reply.getName());
assertEquals("0.23", reply.getVersion());
assertEquals("DummyOS", reply.getOs());
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class PingTest method checkProvider.
@Test
public void checkProvider() throws Exception {
// @formatter:off
String control = "<iq from='capulet.lit' to='juliet@capulet.lit/balcony' id='s2c1' type='get'>" + "<ping xmlns='urn:xmpp:ping'/>" + "</iq>";
// @formatter:on
DummyConnection con = new DummyConnection();
con.connect();
// Enable ping for this connection
PingManager.getInstanceFor(con);
IQ pingRequest = (IQ) PacketParserUtils.parseStanza(control);
assertTrue(pingRequest instanceof Ping);
con.processStanza(pingRequest);
Stanza pongPacket = con.getSentPacket();
assertTrue(pongPacket instanceof IQ);
IQ pong = (IQ) pongPacket;
assertThat("capulet.lit", equalsCharSequence(pong.getTo()));
assertEquals("s2c1", pong.getStanzaId());
assertEquals(IQ.Type.result, pong.getType());
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class PingTest method checkSuccessfulDiscoRequest.
@Test
public void checkSuccessfulDiscoRequest() throws Exception {
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
DiscoverInfo info = new DiscoverInfo();
info.addFeature(Ping.NAMESPACE);
//@formatter:off
String reply = "<iq type='result' id='qrzSp-16' to='test@myserver.com'>" + "<query xmlns='http://jabber.org/protocol/disco#info'><identity category='client' type='pc' name='Pidgin'/>" + "<feature var='urn:xmpp:ping'/>" + "</query></iq>";
//@formatter:on
IQ discoReply = (IQ) PacketParserUtils.parseStanza(reply);
con.addIQReply(discoReply);
PingManager pinger = PingManager.getInstanceFor(con);
boolean pingSupported = pinger.isPingSupported(DUMMY_AT_EXAMPLE_ORG);
assertTrue(pingSupported);
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class RosterVersioningTest method answerWithEmptyRosterResult.
private void answerWithEmptyRosterResult() {
// We expect that the roster request is the only packet sent. This is not part of the specification,
// but a shortcut in the test implementation.
Stanza sentPacket = connection.getSentPacket();
if (sentPacket instanceof RosterPacket) {
final IQ emptyIQ = IQ.createResultIQ((RosterPacket) sentPacket);
connection.processStanza(emptyIQ);
} else {
assertTrue("Expected to get a RosterPacket ", false);
}
}
use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class PrivacyProviderTest method parsePrivacyList.
@Test
public void parsePrivacyList() throws Exception {
// @formatter:off
final String xmlPrivacyList = "<iq type='result' id='getlist2' to='romeo@example.net/orchard'>" + "<query xmlns='jabber:iq:privacy'>" + "<list name='public'>" + "<item type='jid'" + "value='tybalt@example.com'" + "action='deny'" + "order='1'/>" + "<item action='allow' order='2'/>" + "</list>" + "</query>" + "</iq>";
// @formatter:on
IQ iqPrivacyList = (IQ) PacketParserUtils.parseStanza(xmlPrivacyList);
assertTrue(iqPrivacyList instanceof Privacy);
Privacy privacyList = (Privacy) iqPrivacyList;
List<PrivacyItem> pl = privacyList.getPrivacyList("public");
PrivacyItem first = pl.get(0);
assertEquals(PrivacyItem.Type.jid, first.getType());
assertEquals("tybalt@example.com", first.getValue());
assertEquals(false, first.isAllow());
assertEquals(1, first.getOrder());
PrivacyItem second = pl.get(1);
assertEquals(true, second.isAllow());
assertEquals(2, second.getOrder());
}
Aggregations