Search in sources :

Example 1 with XMLBuilder

use of com.jamesmurty.utils.XMLBuilder in project Smack by igniterealtime.

the class LastActivityTest method checkProvider.

@Test
public void checkProvider() throws Exception {
    XMLBuilder xml = XMLBuilder.create("iq");
    xml.a("from", "romeo@montague.net/orchard").a("id", "last2").a("to", "juliet@capulet.com/balcony").a("type", "get").e("query").namespace(LastActivity.NAMESPACE);
    DummyConnection c = new DummyConnection();
    c.connect();
    IQ lastRequest = (IQ) PacketParserUtils.parseStanza(xml.asString());
    assertTrue(lastRequest instanceof LastActivity);
    c.processStanza(lastRequest);
    Stanza reply = c.getSentPacket();
    assertTrue(reply instanceof LastActivity);
    LastActivity l = (LastActivity) reply;
    assertEquals("last2", l.getStanzaId());
    assertEquals(IQ.Type.result, l.getType());
}
Also used : DummyConnection(org.jivesoftware.smack.DummyConnection) Stanza(org.jivesoftware.smack.packet.Stanza) IQ(org.jivesoftware.smack.packet.IQ) XMLBuilder(com.jamesmurty.utils.XMLBuilder) LastActivity(org.jivesoftware.smackx.iqlast.packet.LastActivity) Test(org.junit.Test)

Aggregations

XMLBuilder (com.jamesmurty.utils.XMLBuilder)1 DummyConnection (org.jivesoftware.smack.DummyConnection)1 IQ (org.jivesoftware.smack.packet.IQ)1 Stanza (org.jivesoftware.smack.packet.Stanza)1 LastActivity (org.jivesoftware.smackx.iqlast.packet.LastActivity)1 Test (org.junit.Test)1