mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Use PacketParserUtils in OpenIQProviderTest
This commit is contained in:
parent
ae208d6a2f
commit
b3801b984a
1 changed files with 6 additions and 20 deletions
|
@ -18,10 +18,10 @@ package org.jivesoftware.smackx.bytestreams.ibb.provider;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
|
@ -29,8 +29,6 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
|||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
/**
|
||||
* Test for the OpenIQProvider class.
|
||||
|
@ -54,7 +52,8 @@ public class OpenIQProviderTest extends InitExtensions {
|
|||
.asString(outputProperties);
|
||||
|
||||
OpenIQProvider oip = new OpenIQProvider();
|
||||
Open open = oip.parse(getParser(control));
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(control);
|
||||
Open open = oip.parse(parser);
|
||||
|
||||
assertEquals(StanzaType.IQ, open.getStanza());
|
||||
}
|
||||
|
@ -69,22 +68,9 @@ public class OpenIQProviderTest extends InitExtensions {
|
|||
.asString(outputProperties);
|
||||
|
||||
OpenIQProvider oip = new OpenIQProvider();
|
||||
Open open = oip.parse(getParser(control));
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(control);
|
||||
Open open = oip.parse(parser);
|
||||
|
||||
assertEquals(StanzaType.MESSAGE, open.getStanza());
|
||||
}
|
||||
|
||||
private static XmlPullParser getParser(String control) throws XmlPullParserException,
|
||||
IOException {
|
||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
parser.setInput(new StringReader(control));
|
||||
while (true) {
|
||||
if (parser.next() == XmlPullParser.START_TAG
|
||||
&& parser.getName().equals("open")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parser;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue