Search in sources :

Example 1 with MamResultProvider

use of org.jivesoftware.smackx.mam.provider.MamResultProvider in project Smack by igniterealtime.

the class MamResultProviderTest method checkMamResultProvider.

@Test
public void checkMamResultProvider() throws Exception {
    XmlPullParser parser = PacketParserUtils.getParserFor(exampleMamResultXml);
    MamResultExtension mamResultExtension = new MamResultProvider().parse(parser);
    Assert.assertEquals(mamResultExtension.getQueryId(), "f27");
    Assert.assertEquals(mamResultExtension.getId(), "28482-98726-73623");
    GregorianCalendar calendar = new GregorianCalendar(2010, 7 - 1, 10, 23, 8, 25);
    calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date = calendar.getTime();
    Forwarded forwarded = mamResultExtension.getForwarded();
    Assert.assertEquals(forwarded.getDelayInformation().getStamp(), date);
    Message message = (Message) forwarded.getForwardedStanza();
    Assert.assertEquals(message.getFrom(), "romeo@montague.lit/orchard");
    Assert.assertEquals(message.getTo(), "juliet@capulet.lit/balcony");
    Assert.assertEquals(message.getBody(), "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
}
Also used : MamResultProvider(org.jivesoftware.smackx.mam.provider.MamResultProvider) Message(org.jivesoftware.smack.packet.Message) XmlPullParser(org.xmlpull.v1.XmlPullParser) GregorianCalendar(java.util.GregorianCalendar) Forwarded(org.jivesoftware.smackx.forward.packet.Forwarded) MamResultExtension(org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 Message (org.jivesoftware.smack.packet.Message)1 Forwarded (org.jivesoftware.smackx.forward.packet.Forwarded)1 MamResultExtension (org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension)1 MamResultProvider (org.jivesoftware.smackx.mam.provider.MamResultProvider)1 Test (org.junit.Test)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1