use of org.jivesoftware.smack.packet.IQ in project Smack by igniterealtime.
the class LastActivityTest method checkProvider.
@Test
public void checkProvider() throws Exception {
XMLBuilder xml = XMLBuilder.create("iq");
xml.a("from", "romeo@montague.net/orchard").a("id", "last2").a("to", "juliet@capulet.com/balcony").a("type", "get").e("query").namespace(LastActivity.NAMESPACE);
DummyConnection c = new DummyConnection();
c.connect();
IQ lastRequest = (IQ) PacketParserUtils.parseStanza(xml.asString());
assertTrue(lastRequest instanceof LastActivity);
c.processStanza(lastRequest);
Stanza reply = c.getSentPacket();
assertTrue(reply instanceof LastActivity);
LastActivity l = (LastActivity) reply;
assertEquals("last2", l.getStanzaId());
assertEquals(IQ.Type.result, l.getType());
}
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);
}
}
Aggregations