org.jivesoftware.smack.provider.PrivacyProvider Java Examples
The following examples show how to use
org.jivesoftware.smack.provider.PrivacyProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrivacyProviderTest.java From Smack with Apache License 2.0 | 5 votes |
/** * Check the parser with an xml with empty lists. It includes the active, * default and special list. * To create the xml string based from an xml file, replace:\n with: "\n + " */ public void testEmptyLists() { // Make the XML to test String xml = "" + " <iq type='result' id='getlist1' to='[email protected]/orchard'> " + " <query xmlns='jabber:iq:privacy'> " + " <active/> " + " <default name='public'/> " + " <list name='public'/> " + " <list name='private'/> " + " <list name='special'/> " + " </query> " + " </iq> "; try { // Create the xml parser XmlPullParser parser = getParserFromXML(xml); // Create a packet from the xml Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser); assertNotNull(packet); assertNotNull(packet.getChildElementXML()); assertEquals("public", packet.getDefaultName()); assertEquals(null, packet.getActiveName()); assertEquals(0, packet.getPrivacyList("public").size()); assertEquals(0, packet.getPrivacyList("private").size()); assertEquals(0, packet.getPrivacyList("special").size()); assertEquals(true, packet.isDeclineActiveList()); assertEquals(false, packet.isDeclineDefaultList()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #2
Source File: PrivacyProviderTest.java From Smack with Apache License 2.0 | 5 votes |
/** * Check the parser with an xml with empty lists. It includes the active, * default and special list. * To create the xml string based from an xml file, replace:\n with: "\n + " */ public void testDeclineLists() { // Make the XML to test String xml = "" + " <iq type='result' id='getlist1' to='[email protected]/orchard'> " + " <query xmlns='jabber:iq:privacy'> " + " <active/> " + " <default/> " + " </query> " + " </iq> "; try { // Create the xml parser XmlPullParser parser = getParserFromXML(xml); // Create a packet from the xml Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser); assertNotNull(packet); assertEquals(null, packet.getDefaultName()); assertEquals(null, packet.getActiveName()); assertEquals(true, packet.isDeclineActiveList()); assertEquals(true, packet.isDeclineDefaultList()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }