mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Improve parsing. Add method for de-serializing Strings
Move some duplicate code from XMPP(TCP|BOSH)Connection to PacketParserUtils. Remove TestUtils as the method now part of Smack's public API in PacketParserUtils.
This commit is contained in:
parent
beecb8a675
commit
3647a7fce5
24 changed files with 215 additions and 291 deletions
|
@ -22,20 +22,13 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.Base32Encoder;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.StringEncoder;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.provider.DiscoverInfoProvider;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Simple implementation of an EntityCapsPersistentCache that uses a directory
|
||||
|
@ -106,7 +99,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
try {
|
||||
info = restoreInfoFromFile(nodeFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (Exception e) {
|
||||
LOGGER.log(Level.WARNING, "Coud not restore info from file", e);
|
||||
}
|
||||
return info;
|
||||
|
@ -147,58 +140,21 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
*
|
||||
* @param file
|
||||
* @return the restored DiscoverInfo
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
private static DiscoverInfo restoreInfoFromFile(File file) throws IOException {
|
||||
private static DiscoverInfo restoreInfoFromFile(File file) throws Exception {
|
||||
DataInputStream dis = new DataInputStream(new FileInputStream(file));
|
||||
String fileContent = null;
|
||||
String id;
|
||||
String from;
|
||||
String to;
|
||||
|
||||
try {
|
||||
fileContent = dis.readUTF();
|
||||
} finally {
|
||||
dis.close();
|
||||
}
|
||||
if (fileContent == null)
|
||||
return null;
|
||||
|
||||
Reader reader = new StringReader(fileContent);
|
||||
XmlPullParser parser;
|
||||
try {
|
||||
parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
||||
parser.setInput(reader);
|
||||
} catch (XmlPullParserException xppe) {
|
||||
LOGGER.log(Level.SEVERE, "Exception initializing parser", xppe);
|
||||
if (fileContent == null) {
|
||||
return null;
|
||||
}
|
||||
DiscoverInfo info = (DiscoverInfo) PacketParserUtils.parseStanza(fileContent);
|
||||
|
||||
DiscoverInfo iqPacket;
|
||||
IQProvider provider = new DiscoverInfoProvider();
|
||||
|
||||
// Parse the IQ, we only need the id
|
||||
try {
|
||||
parser.next();
|
||||
id = parser.getAttributeValue("", "id");
|
||||
from = parser.getAttributeValue("", "from");
|
||||
to = parser.getAttributeValue("", "to");
|
||||
parser.next();
|
||||
} catch (XmlPullParserException e1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
iqPacket = (DiscoverInfo) provider.parseIQ(parser);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
iqPacket.setPacketID(id);
|
||||
iqPacket.setFrom(from);
|
||||
iqPacket.setTo(to);
|
||||
iqPacket.setType(IQ.Type.RESULT);
|
||||
return iqPacket;
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
import org.jivesoftware.smack.util.Base32Encoder;
|
||||
import org.jivesoftware.smack.util.Base64FileUrlEncoder;
|
||||
import org.jivesoftware.smack.util.StringEncoder;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.caps.EntityCapsManager;
|
||||
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
|
||||
import org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache;
|
||||
|
@ -38,7 +39,7 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
|||
import org.junit.Test;
|
||||
|
||||
|
||||
public class EntityCapsManagerTest {
|
||||
public class EntityCapsManagerTest extends InitExtensions {
|
||||
|
||||
/**
|
||||
* <a href="http://xmpp.org/extensions/xep-0115.html#ver-gen-complex">XEP-
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.Properties;
|
|||
import java.util.TimeZone;
|
||||
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
|
@ -65,7 +64,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.t("Offline Storage")
|
||||
.asString(outputProperties);
|
||||
|
||||
parser = TestUtils.getParser(control, "x");
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
delayInfo = (DelayInformation) p.parseExtension(parser);
|
||||
|
||||
assertEquals("capulet.com", delayInfo.getFrom());
|
||||
|
@ -81,7 +80,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "2002-09-10T23:08:25Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
parser = TestUtils.getParser(control, "x");
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
delayInfo = (DelayInformation) p.parseExtension(parser);
|
||||
|
||||
assertEquals("capulet.com", delayInfo.getFrom());
|
||||
|
@ -110,7 +109,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.t("Offline Storage")
|
||||
.asString(outputProperties);
|
||||
|
||||
parser = TestUtils.getParser(control, "delay");
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
delayInfo = (DelayInfo) p.parseExtension(parser);
|
||||
|
||||
assertEquals("capulet.com", delayInfo.getFrom());
|
||||
|
@ -126,7 +125,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "2002-09-10T23:08:25Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
parser = TestUtils.getParser(control, "delay");
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
delayInfo = (DelayInfo) p.parseExtension(parser);
|
||||
|
||||
assertEquals("capulet.com", delayInfo.getFrom());
|
||||
|
@ -153,7 +152,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "2002-09-10T23:08:25.12Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||
delayInfo = (DelayInfo) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
|
||||
GregorianCalendar cal = (GregorianCalendar) calendar.clone();
|
||||
cal.add(Calendar.MILLISECOND, 12);
|
||||
|
@ -166,7 +165,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "2002-09-10T23:08:25Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||
delayInfo = (DelayInfo) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||
|
||||
|
@ -177,7 +176,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "2002-9-10T23:08:25Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||
delayInfo = (DelayInfo) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||
|
||||
|
@ -188,7 +187,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "20020910T23:08:25")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||
delayInfo = (DelayInfo) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||
|
||||
|
@ -208,7 +207,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", dateFormat.format(dateInPast.getTime()))
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||
delayInfo = (DelayInfo) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertEquals(dateInPast.getTime(), delayInfo.getStamp());
|
||||
|
||||
|
@ -219,7 +218,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "200868T09:16:20")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||
delayInfo = (DelayInfo) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
Date controlDate = XmppDateTime.parseDate("2008-06-08T09:16:20.0Z");
|
||||
|
||||
assertEquals(controlDate, delayInfo.getStamp());
|
||||
|
@ -231,7 +230,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("stamp", "yesterday")
|
||||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||
delayInfo = (DelayInfo) p.parseExtension(PacketParserUtils.getParserFor(control));
|
||||
|
||||
assertNotNull(delayInfo.getStamp());
|
||||
|
||||
|
@ -242,7 +241,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
String stanza = "<presence from='mercutio@example.com' to='juliet@example.com'>"
|
||||
+ "<delay xmlns='urn:xmpp:delay' stamp='2002-09-10T23:41:07Z'/></presence>";
|
||||
|
||||
Presence presence = PacketParserUtils.parsePresence(TestUtils.getPresenceParser(stanza));
|
||||
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
||||
|
||||
DelayInformation delay = (DelayInformation) presence.getExtension("urn:xmpp:delay");
|
||||
assertNotNull(delay);
|
||||
|
@ -255,7 +254,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
String stanza = "<presence from='mercutio@example.com' to='juliet@example.com'>"
|
||||
+ "<x xmlns='jabber:x:delay' stamp='20020910T23:41:07'/></presence>";
|
||||
|
||||
Presence presence = PacketParserUtils.parsePresence(TestUtils.getPresenceParser(stanza));
|
||||
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
||||
|
||||
DelayInformation delay = (DelayInformation) presence.getExtension("jabber:x:delay");
|
||||
assertNotNull(delay);
|
||||
|
@ -271,7 +270,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
String stanza = "<presence from='mercutio@example.com' to='juliet@example.com'>"
|
||||
+ "<x xmlns='jabber:x:delay'/></presence>";
|
||||
|
||||
Presence presence = PacketParserUtils.parsePresence(TestUtils.getPresenceParser(stanza));
|
||||
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
||||
DelayInformation delay = (DelayInformation) presence.getExtension("urn:xmpp:delay");
|
||||
assertNull((Object)delay);
|
||||
}
|
||||
|
|
|
@ -19,11 +19,13 @@ package org.jivesoftware.smackx.forward;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Properties;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.forward.Forwarded;
|
||||
import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
|
||||
public class ForwardedTest {
|
||||
|
@ -45,7 +47,7 @@ public class ForwardedTest {
|
|||
.a("from", "romeo@montague.com")
|
||||
.asString(outputProperties);
|
||||
|
||||
parser = TestUtils.getParser(control, "forwarded");
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
fwd = (Forwarded) new ForwardedProvider().parseExtension(parser);
|
||||
|
||||
// no delay in packet
|
||||
|
@ -69,7 +71,7 @@ public class ForwardedTest {
|
|||
.a("xmlns", "urn:xmpp:forwarded:0")
|
||||
.asString(outputProperties);
|
||||
|
||||
parser = TestUtils.getParser(control, "forwarded");
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
new ForwardedProvider().parseExtension(parser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
|
|||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.iqlast.packet.LastActivity;
|
||||
|
@ -43,7 +42,7 @@ public class LastActivityTest extends InitExtensions {
|
|||
.namespace(LastActivity.NAMESPACE);
|
||||
|
||||
DummyConnection c = new DummyConnection();
|
||||
IQ lastRequest = PacketParserUtils.parseIQ(TestUtils.getIQParser(xml.asString()), c);
|
||||
IQ lastRequest = (IQ) PacketParserUtils.parseStanza(xml.asString());
|
||||
assertTrue(lastRequest instanceof LastActivity);
|
||||
|
||||
c.processPacket(lastRequest);;
|
||||
|
|
|
@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
|
|||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.iqversion.packet.Version;
|
||||
import org.junit.Test;
|
||||
|
@ -39,7 +38,7 @@ public class VersionTest {
|
|||
|
||||
// Enable version replys for this connection
|
||||
VersionManager.getInstanceFor(con).setVersion(new Version("Test", "0.23", "DummyOS"));
|
||||
IQ versionRequest = PacketParserUtils.parseIQ(TestUtils.getIQParser(control), con);
|
||||
IQ versionRequest = (IQ) PacketParserUtils.parseStanza(control);
|
||||
|
||||
assertTrue(versionRequest instanceof Version);
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension;
|
||||
|
@ -54,7 +53,7 @@ public class JivePropertiesExtensionTest extends InitExtensions {
|
|||
+ "</message>";
|
||||
// @formatter:on
|
||||
|
||||
Message message = PacketParserUtils.parseMessage(TestUtils.getMessageParser(properties));
|
||||
Message message = (Message) PacketParserUtils.parseStanza(properties);
|
||||
JivePropertiesExtension jpe = (JivePropertiesExtension) message.getExtension(JivePropertiesExtension.NAMESPACE);
|
||||
assertNotNull(jpe);
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.ThreadedDummyConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
|
@ -57,7 +56,7 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
// Enable ping for this connection
|
||||
PingManager.getInstanceFor(con);
|
||||
IQ pingRequest = PacketParserUtils.parseIQ(TestUtils.getIQParser(control), con);
|
||||
IQ pingRequest = (IQ) PacketParserUtils.parseStanza(control);
|
||||
|
||||
assertTrue(pingRequest instanceof Ping);
|
||||
|
||||
|
@ -133,7 +132,7 @@ public class PingTest extends InitExtensions {
|
|||
"</error>" +
|
||||
"</iq>";
|
||||
//@formatter:on
|
||||
IQ serviceUnavailable = PacketParserUtils.parseIQ(TestUtils.getIQParser(reply), threadedCon);
|
||||
IQ serviceUnavailable = (IQ) PacketParserUtils.parseStanza(reply);
|
||||
threadedCon.addIQReply(serviceUnavailable);
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(threadedCon);
|
||||
|
@ -169,7 +168,7 @@ public class PingTest extends InitExtensions {
|
|||
"</error>" +
|
||||
"</iq>";
|
||||
//@formatter:on
|
||||
IQ serviceUnavailable = PacketParserUtils.parseIQ(TestUtils.getIQParser(reply), con);
|
||||
IQ serviceUnavailable = (IQ) PacketParserUtils.parseStanza(reply);
|
||||
con.addIQReply(serviceUnavailable);
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
@ -201,7 +200,7 @@ public class PingTest extends InitExtensions {
|
|||
"<feature var='urn:xmpp:ping'/>" +
|
||||
"</query></iq>";
|
||||
//@formatter:on
|
||||
IQ discoReply = PacketParserUtils.parseIQ(TestUtils.getIQParser(reply), con);
|
||||
IQ discoReply = (IQ) PacketParserUtils.parseStanza(reply);
|
||||
con.addIQReply(discoReply);
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
@ -223,7 +222,7 @@ public class PingTest extends InitExtensions {
|
|||
"<feature var='urn:xmpp:noping'/>" +
|
||||
"</query></iq>";
|
||||
//@formatter:on
|
||||
IQ discoReply = PacketParserUtils.parseIQ(TestUtils.getIQParser(reply), con);
|
||||
IQ discoReply = (IQ) PacketParserUtils.parseStanza(reply);
|
||||
con.addIQReply(discoReply);
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
|
|
@ -21,9 +21,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.privacy.packet.Privacy;
|
||||
|
@ -34,8 +32,6 @@ public class PrivacyProviderTest extends InitExtensions {
|
|||
|
||||
@Test
|
||||
public void parsePrivacyList() throws Exception {
|
||||
DummyConnection connection = new DummyConnection();
|
||||
|
||||
// @formatter:off
|
||||
final String xmlPrivacyList =
|
||||
"<iq type='result' id='getlist2' to='romeo@example.net/orchard'>"
|
||||
|
@ -50,7 +46,7 @@ public class PrivacyProviderTest extends InitExtensions {
|
|||
+ "</query>"
|
||||
+ "</iq>";
|
||||
// @formatter:on
|
||||
IQ iqPrivacyList = PacketParserUtils.parseIQ(TestUtils.getIQParser(xmlPrivacyList), connection);
|
||||
IQ iqPrivacyList = (IQ) PacketParserUtils.parseStanza(xmlPrivacyList);
|
||||
assertTrue(iqPrivacyList instanceof Privacy);
|
||||
|
||||
Privacy privacyList = (Privacy) iqPrivacyList;
|
||||
|
|
|
@ -23,7 +23,6 @@ import static org.junit.Assert.assertTrue;
|
|||
import org.jivesoftware.smack.ThreadedDummyConnection;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
|
@ -95,7 +94,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
@Test
|
||||
public void parseBasicItem() throws Exception
|
||||
{
|
||||
XmlPullParser parser = TestUtils.getMessageParser(
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(
|
||||
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
|
||||
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
|
||||
"<items node='testNode'>" +
|
||||
|
@ -124,7 +123,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
{
|
||||
String itemContent = "<foo xmlns='smack:test'>Some text</foo>";
|
||||
|
||||
XmlPullParser parser = TestUtils.getMessageParser(
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(
|
||||
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
|
||||
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
|
||||
"<items node='testNode'>" +
|
||||
|
@ -171,7 +170,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
"<updated>2003-12-13T18:30:02Z</updated>" +
|
||||
"</entry>";
|
||||
|
||||
XmlPullParser parser = TestUtils.getMessageParser(
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(
|
||||
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
|
||||
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
|
||||
"<items node='testNode'>" +
|
||||
|
@ -204,7 +203,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
{
|
||||
String itemContent = "<foo xmlns='smack:test'><bar/></foo>";
|
||||
|
||||
XmlPullParser parser = TestUtils.getMessageParser(
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(
|
||||
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
|
||||
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
|
||||
"<items node='testNode'>" +
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Properties;
|
|||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
@ -53,7 +52,7 @@ public class DeliveryReceiptTest extends InitExtensions {
|
|||
.a("xmlns", "urn:xmpp:receipts")
|
||||
.asString(outputProperties);
|
||||
|
||||
parser = TestUtils.getMessageParser(control);
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
Packet p = PacketParserUtils.parseMessage(parser);
|
||||
|
||||
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)p.getExtension(
|
||||
|
|
|
@ -23,9 +23,7 @@ import java.util.Calendar;
|
|||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.junit.Test;
|
||||
|
@ -63,8 +61,6 @@ public class TimeTest extends InitExtensions {
|
|||
|
||||
@Test
|
||||
public void parseTimeWithIntrospectionTest() throws Exception {
|
||||
DummyConnection connection = new DummyConnection();
|
||||
|
||||
// @formatter:off
|
||||
final String request =
|
||||
"<iq type='get'"
|
||||
|
@ -74,7 +70,7 @@ public class TimeTest extends InitExtensions {
|
|||
+ "<time xmlns='urn:xmpp:time'/>"
|
||||
+ "</iq>";
|
||||
// @formatter:on
|
||||
IQ iqRequest = PacketParserUtils.parseIQ(TestUtils.getIQParser(request), connection);
|
||||
IQ iqRequest = (IQ) PacketParserUtils.parseStanza(request);
|
||||
assertTrue(iqRequest instanceof Time);
|
||||
|
||||
// @formatter:off
|
||||
|
@ -89,7 +85,7 @@ public class TimeTest extends InitExtensions {
|
|||
+ "</time>"
|
||||
+ "</iq>";
|
||||
// @formatter:on
|
||||
IQ iqResponse = PacketParserUtils.parseIQ(TestUtils.getIQParser(response), connection);
|
||||
IQ iqResponse = (IQ) PacketParserUtils.parseStanza(response);
|
||||
assertTrue(iqResponse instanceof Time);
|
||||
Time time = (Time) iqResponse;
|
||||
assertEquals("-06:00", time.getTzo());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue