Search in sources :

Example 1 with AMPExtensionProvider

use of org.jivesoftware.smackx.amp.provider.AMPExtensionProvider in project Smack by igniterealtime.

the class AMPExtensionTest method isCorrectFromXmlErrorHandling.

@Test
public void isCorrectFromXmlErrorHandling() throws Exception {
    AMPExtensionProvider ampProvider = new AMPExtensionProvider();
    XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    parser.setInput(INCORRECT_RECEIVING_STANZA_STREAM, "UTF-8");
    assertEquals(XmlPullParser.START_TAG, parser.next());
    assertEquals(AMPExtension.ELEMENT, parser.getName());
    ExtensionElement extension = ampProvider.parse(parser);
    assertTrue(extension instanceof AMPExtension);
    AMPExtension amp = (AMPExtension) extension;
    assertEquals(0, amp.getRulesCount());
    assertEquals(AMPExtension.Status.alert, amp.getStatus());
    assertEquals("bernardo@hamlet.lit/elsinore", amp.getFrom());
    assertEquals("francisco@hamlet.lit", amp.getTo());
}
Also used : AMPExtensionProvider(org.jivesoftware.smackx.amp.provider.AMPExtensionProvider) XmlPullParser(org.xmlpull.v1.XmlPullParser) ExtensionElement(org.jivesoftware.smack.packet.ExtensionElement) AMPExtension(org.jivesoftware.smackx.amp.packet.AMPExtension) Test(org.junit.Test)

Example 2 with AMPExtensionProvider

use of org.jivesoftware.smackx.amp.provider.AMPExtensionProvider in project Smack by igniterealtime.

the class AMPExtensionTest method isCorrectFromXmlDeserialization.

@Test
public void isCorrectFromXmlDeserialization() throws Exception {
    AMPExtensionProvider ampProvider = new AMPExtensionProvider();
    XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    parser.setInput(CORRECT_SENDING_STANZA_STREAM, "UTF-8");
    assertEquals(XmlPullParser.START_TAG, parser.next());
    assertEquals(AMPExtension.ELEMENT, parser.getName());
    ExtensionElement extension = ampProvider.parse(parser);
    assertTrue(extension instanceof AMPExtension);
    AMPExtension amp = (AMPExtension) extension;
    assertEquals(9, amp.getRulesCount());
}
Also used : AMPExtensionProvider(org.jivesoftware.smackx.amp.provider.AMPExtensionProvider) XmlPullParser(org.xmlpull.v1.XmlPullParser) ExtensionElement(org.jivesoftware.smack.packet.ExtensionElement) AMPExtension(org.jivesoftware.smackx.amp.packet.AMPExtension) Test(org.junit.Test)

Aggregations

ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)2 AMPExtension (org.jivesoftware.smackx.amp.packet.AMPExtension)2 AMPExtensionProvider (org.jivesoftware.smackx.amp.provider.AMPExtensionProvider)2 Test (org.junit.Test)2 XmlPullParser (org.xmlpull.v1.XmlPullParser)2