Search in sources :

Example 1 with MamQueryResult

use of org.jivesoftware.smackx.mam.MamManager.MamQueryResult in project Smack by igniterealtime.

the class MamIntegrationTest method mamTest.

@SmackIntegrationTest
public void mamTest() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException, NotLoggedInException {
    EntityBareJid userOne = conOne.getUser().asEntityBareJid();
    EntityBareJid userTwo = conTwo.getUser().asEntityBareJid();
    Message message = new Message(userTwo);
    String messageId = message.setStanzaId();
    String messageBody = "test message";
    message.setBody(messageBody);
    conOne.sendStanza(message);
    int pageSize = 20;
    MamQueryResult mamQueryResult = mamManagerConTwo.queryArchive(pageSize, null, null, userOne, null);
    while (!mamQueryResult.mamFin.isComplete()) {
        mamQueryResult = mamManagerConTwo.pageNext(mamQueryResult, pageSize);
    }
    List<Forwarded> forwardedMessages = mamQueryResult.forwardedMessages;
    Message mamMessage = (Message) forwardedMessages.get(forwardedMessages.size() - 1).getForwardedStanza();
    assertEquals(messageId, mamMessage.getStanzaId());
    assertEquals(messageBody, mamMessage.getBody());
    assertEquals(conOne.getUser(), mamMessage.getFrom());
    assertEquals(userTwo, mamMessage.getTo());
}
Also used : Message(org.jivesoftware.smack.packet.Message) Forwarded(org.jivesoftware.smackx.forward.packet.Forwarded) MamQueryResult(org.jivesoftware.smackx.mam.MamManager.MamQueryResult) EntityBareJid(org.jxmpp.jid.EntityBareJid) AbstractSmackIntegrationTest(org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest) SmackIntegrationTest(org.igniterealtime.smack.inttest.SmackIntegrationTest)

Aggregations

AbstractSmackIntegrationTest (org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest)1 SmackIntegrationTest (org.igniterealtime.smack.inttest.SmackIntegrationTest)1 Message (org.jivesoftware.smack.packet.Message)1 Forwarded (org.jivesoftware.smackx.forward.packet.Forwarded)1 MamQueryResult (org.jivesoftware.smackx.mam.MamManager.MamQueryResult)1 EntityBareJid (org.jxmpp.jid.EntityBareJid)1