use of org.jivesoftware.smack.DummyConnection 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.DummyConnection 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.DummyConnection in project Smack by igniterealtime.
the class PingTest method checkFailedPingOnTimeout.
/**
* DummyConnection will not reply so it will timeout.
* @throws SmackException
* @throws XMPPException
* @throws IOException
* @throws InterruptedException
*/
@Test
public void checkFailedPingOnTimeout() throws SmackException, IOException, XMPPException, InterruptedException {
DummyConnection dummyCon = getAuthenticatedDummyConnectionWithoutIqReplies();
PingManager pinger = PingManager.getInstanceFor(dummyCon);
try {
pinger.ping(DUMMY_AT_EXAMPLE_ORG);
} catch (NoResponseException e) {
return;
}
fail();
}
use of org.jivesoftware.smack.DummyConnection 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.DummyConnection in project Smack by igniterealtime.
the class ChatConnectionTest method validateDefaultSetNormalIncludedTrue.
@Test
public void validateDefaultSetNormalIncludedTrue() {
ChatManager.setDefaultIsNormalIncluded(true);
assertTrue(ChatManager.getInstanceFor(new DummyConnection()).isNormalIncluded());
}
Aggregations