Exemple #1
0
  @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());
    PacketExtension extension = ampProvider.parseExtension(parser);
    assertTrue(extension instanceof AMPExtension);
    AMPExtension amp = (AMPExtension) extension;

    assertEquals(9, amp.getRulesCount());
  }
Exemple #2
0
  @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());

    PacketExtension extension = ampProvider.parseExtension(parser);
    assertTrue(extension instanceof AMPExtension);
    AMPExtension amp = (AMPExtension) extension;

    assertEquals(0, amp.getRulesCount());
    assertEquals(AMPExtension.Status.alert, amp.getStatus());
    assertEquals("[email protected]/elsinore", amp.getFrom());
    assertEquals("*****@*****.**", amp.getTo());
  }