mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-15 03:59:38 +02:00
Improve privacy parsing and API. Add NumberUtil
Make 'order' an long Parse fall-through case's child elements (message, iq, presence-in, presence-out) Remove privacy.addExtension(new DefaultPacketExtension(parser.getName(), parser.getNamespace())); at the beginning of PrivacyProvider. Was there since day one for an unknown reason.
This commit is contained in:
parent
142f78c135
commit
c5db012fc8
6 changed files with 145 additions and 51 deletions
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.privacy.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -62,4 +63,44 @@ public class PrivacyProviderTest extends InitExtensions {
|
|||
assertEquals(true, second.isAllow());
|
||||
assertEquals(2, second.getOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsePrivacyListWithFallThroughInclChildElements() throws Exception {
|
||||
// @formatter:off
|
||||
final String xmlPrivacyList =
|
||||
"<iq type='result' id='getlist2' to='romeo@example.net/orchard'>"
|
||||
+ "<query xmlns='jabber:iq:privacy'>"
|
||||
+ "<list name='public'>"
|
||||
+ "<item type='jid'"
|
||||
+ "value='tybalt@example.com'"
|
||||
+ "action='deny'"
|
||||
+ "order='1'/>"
|
||||
+ "<item action='allow' order='2'>"
|
||||
+ "<message/>"
|
||||
+ "<presence-in/>"
|
||||
+ "</item>"
|
||||
+ "</list>"
|
||||
+ "</query>"
|
||||
+ "</iq>";
|
||||
// @formatter:on
|
||||
IQ iqPrivacyList = (IQ) PacketParserUtils.parseStanza(xmlPrivacyList);
|
||||
assertTrue(iqPrivacyList instanceof Privacy);
|
||||
|
||||
Privacy privacyList = (Privacy) iqPrivacyList;
|
||||
List<PrivacyItem> pl = privacyList.getPrivacyList("public");
|
||||
|
||||
PrivacyItem first = pl.get(0);
|
||||
assertEquals(PrivacyItem.Type.jid, first.getType());
|
||||
assertEquals("tybalt@example.com", first.getValue());
|
||||
assertEquals(false, first.isAllow());
|
||||
assertEquals(1, first.getOrder());
|
||||
|
||||
PrivacyItem second = pl.get(1);
|
||||
assertTrue(second.isAllow());
|
||||
assertEquals(2, second.getOrder());
|
||||
assertTrue(second.isFilterMessage());
|
||||
assertTrue(second.isFilterPresenceIn());
|
||||
assertFalse(second.isFilterPresenceOut());
|
||||
assertFalse(second.isFilterIQ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class DataValidationHelperTest {
|
|||
fail("No correct check on consistency");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("min must not be negative", e.getMessage());
|
||||
assertEquals("unsigned 32-bit integers can't be negative", e.getMessage());
|
||||
}
|
||||
|
||||
element.setListRange(new ListRange(10L, 100L));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue