1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-06 13:11:08 +01:00

Substitute MXParser with a call to XmlPullParserFactory

This makes Smack more portable, as there are platforms that support the
XmlPullParser interface, but not MXParser (e.g. Android).

Also enable checkstyle check that MXParser is not used.
This commit is contained in:
Florian Schmaus 2014-02-20 13:38:12 +01:00
parent 4db0b101c2
commit 24b637876f
18 changed files with 40 additions and 35 deletions

View file

@ -35,7 +35,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlPullParser;
/**
@ -315,7 +315,7 @@ public class RosterTest {
final String contactJID = "nurse@example.com";
final Roster roster = connection.getRoster();
assertNotNull("Can't get the roster from the provided connection!", roster);
final MXParser parser = new MXParser();
final XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
final StringBuilder sb = new StringBuilder();
sb.append("<iq id=\"rostertest1\" type=\"set\" ")
@ -449,7 +449,7 @@ public class RosterTest {
final String contactJID = "nurse@example.com";
final Roster roster = connection.getRoster();
assertNotNull("Can't get the roster from the provided connection!", roster);
final MXParser parser = new MXParser();
final XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
final StringBuilder sb = new StringBuilder();
sb.append("<iq id=\"rostertest2\" type=\"set\" ")

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smack.test.util;
import java.io.IOException;
import java.io.StringReader;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@ -40,8 +40,9 @@ final public class TestUtils {
}
public static XmlPullParser getParser(String stanza, String startTag) {
XmlPullParser parser = new MXParser();
XmlPullParser parser;
try {
parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(new StringReader(stanza));
boolean found = false;