use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class DeliveryReceiptTest method receiptManagerAutoReplyTest.
@Test
public void receiptManagerAutoReplyTest() throws Exception {
DummyConnection c = new DummyConnection();
c.connect();
DeliveryReceiptManager drm = DeliveryReceiptManager.getInstanceFor(c);
drm.setAutoReceiptMode(AutoReceiptMode.always);
assertEquals(AutoReceiptMode.always, drm.getAutoReceiptMode());
// test auto-receipts
MessageBuilder messageBuilder = StanzaBuilder.buildMessage("test-receipt-request").to("julia@capulet.com").from("romeo@montague.com").ofType(Message.Type.normal);
DeliveryReceiptRequest.addTo(messageBuilder);
// the DRM will send a reply-packet
c.processStanza(messageBuilder.build());
Stanza reply = c.getSentPacket();
DeliveryReceipt r = DeliveryReceipt.from((Message) reply);
assertThat("romeo@montague.com", equalsCharSequence(reply.getTo()));
assertEquals("test-receipt-request", r.getId());
}
use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class PingTest method checkSendingPing.
@Test
public void checkSendingPing() throws InterruptedException, SmackException, IOException, XMPPException {
DummyConnection dummyCon = getAuthenticatedDummyConnection();
PingManager pinger = PingManager.getInstanceFor(dummyCon);
try {
pinger.ping(DUMMY_AT_EXAMPLE_ORG);
} catch (SmackException e) {
// Ignore the fact the server won't answer for this unit test.
}
Stanza sentPacket = dummyCon.getSentPacket();
assertTrue(sentPacket instanceof Ping);
}
use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class ChatConnectionTest method chatNotFoundWithDiffThreadBaseJid.
/**
* Confirm that an existing chat created with a base jid is not matched to an incoming chat message that has a
* different id and the same user as a base jid.
*/
@Test
public void chatNotFoundWithDiffThreadBaseJid() {
Chat outgoing = cm.createChat(JidTestUtil.DUMMY_AT_EXAMPLE_ORG, null);
Stanza incomingChat = createChatMessage(outgoing.getThreadID() + "ff", false);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
assertNotNull(newChat);
assertFalse(newChat == outgoing);
}
use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class ChatConnectionTest method chatFoundWhenNoThreadEntityFullJid.
/**
* Confirm that an existing chat created with a base jid is matched to an incoming chat message that has no thread
* id and the user is a full jid.
*/
@Test
public void chatFoundWhenNoThreadEntityFullJid() {
Chat outgoing = cm.createChat(JidTestUtil.DUMMY_AT_EXAMPLE_ORG, null);
Stanza incomingChat = createChatMessage(null, true);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
assertNotNull(newChat);
assertTrue(newChat == outgoing);
}
use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class ChatConnectionTest method chatFoundWhenNoThreadBaseJid.
/**
* Confirm that an existing chat created with a base jid is matched to an incoming chat message that has no thread
* id and the user is a base jid.
*/
@Test
public void chatFoundWhenNoThreadBaseJid() {
Chat outgoing = cm.createChat(JidTestUtil.DUMMY_AT_EXAMPLE_ORG, null);
Stanza incomingChat = createChatMessage(null, false);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
assertNotNull(newChat);
assertTrue(newChat == outgoing);
}
Aggregations