Search in sources :

Example 11 with Forwarded

use of org.jivesoftware.smackx.forward.packet.Forwarded 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

Forwarded (org.jivesoftware.smackx.forward.packet.Forwarded)11 Test (org.junit.Test)6 Message (org.jivesoftware.smack.packet.Message)5 MamResultExtension (org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension)4 XmlPullParser (org.xmlpull.v1.XmlPullParser)4 Date (java.util.Date)3 GregorianCalendar (java.util.GregorianCalendar)3 DelayInformation (org.jivesoftware.smackx.delay.packet.DelayInformation)3 SmackException (org.jivesoftware.smack.SmackException)2 CarbonExtension (org.jivesoftware.smackx.carbons.packet.CarbonExtension)2 ForwardedProvider (org.jivesoftware.smackx.forward.provider.ForwardedProvider)2 ArrayList (java.util.ArrayList)1 AbstractSmackIntegrationTest (org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest)1 SmackIntegrationTest (org.igniterealtime.smack.inttest.SmackIntegrationTest)1 StanzaCollector (org.jivesoftware.smack.StanzaCollector)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1 IQReplyFilter (org.jivesoftware.smack.filter.IQReplyFilter)1 Stanza (org.jivesoftware.smack.packet.Stanza)1 ExperimentalInitializerTest (org.jivesoftware.smackx.ExperimentalInitializerTest)1 Direction (org.jivesoftware.smackx.carbons.packet.CarbonExtension.Direction)1