Search in sources :

Example 1 with IdleElement

use of org.jivesoftware.smackx.last_interaction.element.IdleElement in project Smack by igniterealtime.

the class IdleTest method helperTest.

@Test
public void helperTest() {
    Presence presence = StanzaBuilder.buildPresence().ofType(Presence.Type.available).build();
    IdleElement.addToPresence(presence);
    IdleElement element = IdleElement.fromPresence(presence);
    assertNotNull(element);
}
Also used : IdleElement(org.jivesoftware.smackx.last_interaction.element.IdleElement) Presence(org.jivesoftware.smack.packet.Presence) Test(org.junit.jupiter.api.Test)

Example 2 with IdleElement

use of org.jivesoftware.smackx.last_interaction.element.IdleElement in project Smack by igniterealtime.

the class IdleTest method providerTest.

@Test
public void providerTest() throws Exception {
    String xml = "<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15Z' />";
    XmlPullParser parser = TestUtils.getParser(xml);
    assertNotNull(parser);
    IdleElement parsed = IdleProvider.TEST_INSTANCE.parse(parser);
    Date date = XmppDateTime.parseXEP0082Date("1969-07-21T02:56:15Z");
    assertEquals(date, parsed.getSince());
    IdleElement element = new IdleElement(date);
    assertXmlSimilar("<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15.000+00:00'/>", element.toXML().toString());
}
Also used : IdleElement(org.jivesoftware.smackx.last_interaction.element.IdleElement) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 3 with IdleElement

use of org.jivesoftware.smackx.last_interaction.element.IdleElement in project Smack by igniterealtime.

the class IdleProvider method parse.

@Override
public IdleElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws ParseException {
    String dateString = parser.getAttributeValue(null, IdleElement.ATTR_SINCE);
    Date since = XmppDateTime.parseXEP0082Date(dateString);
    return new IdleElement(since);
}
Also used : IdleElement(org.jivesoftware.smackx.last_interaction.element.IdleElement) Date(java.util.Date)

Aggregations

IdleElement (org.jivesoftware.smackx.last_interaction.element.IdleElement)3 Date (java.util.Date)2 Test (org.junit.jupiter.api.Test)2 Presence (org.jivesoftware.smack.packet.Presence)1 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1