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());
}
Aggregations