Search in sources :

Example 1 with Subscription

use of org.jivesoftware.smackx.pubsub.Subscription in project Smack by igniterealtime.

the class PubSubProviderTest method subscriptionsOwnerResultTest.

@Test
public void subscriptionsOwnerResultTest() throws Exception {
    // @formatter:off
    final String resultStanza = "<iq from='pubsub.example.org' to='julia@example.org/Smack' id='HaT4m-13' type='result'>" + "<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>" + "<subscriptions node='test'>" + "<subscription jid='foo@example.org/Smack' subscription='subscribed' subid='58C1A6F99F2A7'/>" + "<subscription jid='julia@example.org/Smack' subscription='subscribed' subid='58C18F8917321'/>" + "</subscriptions>" + "</pubsub>" + "</iq>";
    // @formatter:on
    XmlPullParser parser = TestUtils.getIQParser(resultStanza);
    PubSub pubsubResult = (PubSub) PacketParserUtils.parseIQ(parser);
    SubscriptionsExtension subElem = pubsubResult.getExtension(PubSubElementType.SUBSCRIPTIONS);
    List<Subscription> subscriptions = subElem.getSubscriptions();
    assertEquals(2, subscriptions.size());
    Subscription sub1 = subscriptions.get(0);
    assertEquals("foo@example.org/Smack", sub1.getJid());
    assertEquals(Subscription.State.subscribed, sub1.getState());
    assertEquals("58C1A6F99F2A7", sub1.getId());
    Subscription sub2 = subscriptions.get(1);
    assertEquals("julia@example.org/Smack", sub2.getJid());
    assertEquals(Subscription.State.subscribed, sub2.getState());
    assertEquals("58C18F8917321", sub2.getId());
}
Also used : SubscriptionsExtension(org.jivesoftware.smackx.pubsub.SubscriptionsExtension) PubSub(org.jivesoftware.smackx.pubsub.packet.PubSub) XmlPullParser(org.xmlpull.v1.XmlPullParser) Subscription(org.jivesoftware.smackx.pubsub.Subscription) Test(org.junit.Test)

Aggregations

Subscription (org.jivesoftware.smackx.pubsub.Subscription)1 SubscriptionsExtension (org.jivesoftware.smackx.pubsub.SubscriptionsExtension)1 PubSub (org.jivesoftware.smackx.pubsub.packet.PubSub)1 Test (org.junit.Test)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1