summaryrefslogtreecommitdiffstats
blob: cf7df329697819a9f3da41ad4908aebc34ea6c84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*  Copyright (c) 2016, Isode Limited, London, England.
 *  All rights reserved.
 *
 *  Acquisition and use of this software and related materials for any
 *  purpose requires a written license agreement from Isode Limited,
 *  or a written license from an organisation licensed by Isode Limited
 *  to grant such a license.
 *
 */
package com.isode.stroke.parser.payloadparsers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.isode.stroke.base.DateTime;
import com.isode.stroke.elements.Idle;
import com.isode.stroke.elements.Presence;
import com.isode.stroke.parser.PresenceParser;
import com.isode.stroke.parser.StanzaParserTester;

/**
 * Test for {@link IdleParser}
 */
public class IdleParserTest {

    @Test
    public void testParse_XepWhatever_Example1() {
        PresenceParser testling = new PresenceParser(new FullPayloadParserFactoryCollection());
        StanzaParserTester<PresenceParser> parser = new StanzaParserTester<PresenceParser>(testling);
        assertTrue(parser.parse(
            "<presence from='juliet@capulet.com/balcony'>\n"
                +"<show>away</show>\n"
                +"<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15Z'/>\n"
            +"</presence>\n"
        ));

        Presence presence = testling.getStanzaGeneric();
        assertNotNull(presence);
        
        Idle idle = presence.getPayload(new Idle());
        assertNotNull(idle);
        assertEquals(DateTime.stringToDate("1969-07-21T02:56:15Z"),idle.getSince());
    }

}