mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 04:22:05 +01:00
Re-activate all ignored unit-tests
Make all unit tests functional again.
This commit is contained in:
parent
a6ed3b2514
commit
4fb5b85806
15 changed files with 112 additions and 164 deletions
|
@ -43,13 +43,13 @@ import org.jivesoftware.smack.util.collections.ReferenceMap;
|
||||||
* @author Alexander Wenckus
|
* @author Alexander Wenckus
|
||||||
*/
|
*/
|
||||||
public class ChatManager {
|
public class ChatManager {
|
||||||
/*
|
/**
|
||||||
* Sets the default behaviour for allowing 'normal' messages to be used in chats. As some clients don't set
|
* Sets the default behaviour for allowing 'normal' messages to be used in chats. As some clients don't set
|
||||||
* the message type to chat, the type normal has to be accepted to allow chats with these clients.
|
* the message type to chat, the type normal has to be accepted to allow chats with these clients.
|
||||||
*/
|
*/
|
||||||
private static boolean defaultIsNormalInclude = true;
|
private static boolean defaultIsNormalInclude = true;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Sets the default behaviour for how to match chats when there is NO thread id in the incoming message.
|
* Sets the default behaviour for how to match chats when there is NO thread id in the incoming message.
|
||||||
*/
|
*/
|
||||||
private static MatchMode defaultMatchMode = MatchMode.BARE_JID;
|
private static MatchMode defaultMatchMode = MatchMode.BARE_JID;
|
||||||
|
@ -74,12 +74,12 @@ public class ChatManager {
|
||||||
BARE_JID;
|
BARE_JID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Determines whether incoming messages of type normal can create chats.
|
* Determines whether incoming messages of type normal can create chats.
|
||||||
*/
|
*/
|
||||||
private boolean normalIncluded = defaultIsNormalInclude;
|
private boolean normalIncluded = defaultIsNormalInclude;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Determines how incoming message with no thread will be matched to existing chats.
|
* Determines how incoming message with no thread will be matched to existing chats.
|
||||||
*/
|
*/
|
||||||
private MatchMode matchMode = defaultMatchMode;
|
private MatchMode matchMode = defaultMatchMode;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.io.IOException;
|
||||||
*
|
*
|
||||||
* @author Florian Schmaus
|
* @author Florian Schmaus
|
||||||
* Based on code by Brian Wellington (bwelling@xbill.org)
|
* Based on code by Brian Wellington (bwelling@xbill.org)
|
||||||
* @see <a href="http://en.wikipedia.org/wiki/Base32">Base32 Wikipedia entry<a>
|
* @see <a href="http://en.wikipedia.org/wiki/Base32">Base32 Wikipedia entry</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Base32Encoder implements StringEncoder {
|
public class Base32Encoder implements StringEncoder {
|
||||||
|
|
|
@ -525,7 +525,7 @@ public class PacketParserUtils {
|
||||||
*
|
*
|
||||||
* @param parser the XML parser, positioned at the start of the compression stanza.
|
* @param parser the XML parser, positioned at the start of the compression stanza.
|
||||||
* @return a collection of Stings with the methods included in the compression stanza.
|
* @return a collection of Stings with the methods included in the compression stanza.
|
||||||
* @throws Exception if an exception occurs while parsing the stanza.
|
* @throws XmlPullParserException if an exception occurs while parsing the stanza.
|
||||||
*/
|
*/
|
||||||
public static Collection<String> parseCompressionMethods(XmlPullParser parser)
|
public static Collection<String> parseCompressionMethods(XmlPullParser parser)
|
||||||
throws IOException, XmlPullParserException {
|
throws IOException, XmlPullParserException {
|
||||||
|
@ -662,7 +662,7 @@ public class PacketParserUtils {
|
||||||
*
|
*
|
||||||
* @param parser the XML parser.
|
* @param parser the XML parser.
|
||||||
* @return an stream error packet.
|
* @return an stream error packet.
|
||||||
* @throws Exception if an exception occurs while parsing the packet.
|
* @throws XmlPullParserException if an exception occurs while parsing the packet.
|
||||||
*/
|
*/
|
||||||
public static StreamError parseStreamError(XmlPullParser parser) throws IOException,
|
public static StreamError parseStreamError(XmlPullParser parser) throws IOException,
|
||||||
XmlPullParserException {
|
XmlPullParserException {
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -30,7 +29,6 @@ import org.jivesoftware.smack.packet.Message.Type;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ChatConnectionTest {
|
public class ChatConnectionTest {
|
||||||
|
@ -66,7 +64,6 @@ public class ChatConnectionTest {
|
||||||
assertEquals(MatchMode.BARE_JID, getConnection().getChatManager().getMatchMode());
|
assertEquals(MatchMode.BARE_JID, getConnection().getChatManager().getMatchMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void validateMessageTypeWithDefaults() {
|
public void validateMessageTypeWithDefaults() {
|
||||||
DummyConnection dc = getConnection();
|
DummyConnection dc = getConnection();
|
||||||
|
@ -108,9 +105,9 @@ public class ChatConnectionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateMessageTypeWithNoNormal() {
|
public void validateMessageTypeWithNoNormal() {
|
||||||
ChatManager.setDefaultIsNormalIncluded(false);
|
|
||||||
DummyConnection dc = getConnection();
|
DummyConnection dc = getConnection();
|
||||||
ChatManager cm = dc.getChatManager();
|
ChatManager cm = dc.getChatManager();
|
||||||
|
cm.setNormalIncluded(false);
|
||||||
TestChatManagerListener listener = new TestChatManagerListener();
|
TestChatManagerListener listener = new TestChatManagerListener();
|
||||||
cm.addChatListener(listener);
|
cm.addChatListener(listener);
|
||||||
Message incomingChat = createChatPacket("134", true);
|
Message incomingChat = createChatPacket("134", true);
|
||||||
|
@ -120,6 +117,7 @@ public class ChatConnectionTest {
|
||||||
|
|
||||||
dc = getConnection();
|
dc = getConnection();
|
||||||
cm = dc.getChatManager();
|
cm = dc.getChatManager();
|
||||||
|
cm.setNormalIncluded(false);
|
||||||
listener = new TestChatManagerListener();
|
listener = new TestChatManagerListener();
|
||||||
cm.addChatListener(listener);
|
cm.addChatListener(listener);
|
||||||
incomingChat = createChatPacket("134", true);
|
incomingChat = createChatPacket("134", true);
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.jivesoftware.smack.packet.Presence;
|
||||||
* can be delivered using the {@linkplain #processPacket(Packet)} method.
|
* can be delivered using the {@linkplain #processPacket(Packet)} method.
|
||||||
* It invokes the registered packet interceptors and listeners.
|
* It invokes the registered packet interceptors and listeners.
|
||||||
*
|
*
|
||||||
* @see Connection
|
* @see XMPPConnection
|
||||||
* @author Guenther Niess
|
* @author Guenther Niess
|
||||||
*/
|
*/
|
||||||
public class DummyConnection extends XMPPConnection {
|
public class DummyConnection extends XMPPConnection {
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that verifies the correct behavior of the {@see Roster} implementation.
|
* Tests that verifies the correct behavior of the {@link Roster} implementation.
|
||||||
*
|
*
|
||||||
* @see Roster
|
* @see Roster
|
||||||
* @see <a href="http://xmpp.org/rfcs/rfc3921.html#roster">Roster Management</a>
|
* @see <a href="http://xmpp.org/rfcs/rfc3921.html#roster">Roster Management</a>
|
||||||
|
@ -489,7 +489,7 @@ public class RosterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all roster entries by iterating trough {@see Roster#getEntries()}
|
* Remove all roster entries by iterating trough {@link Roster#getEntries()}
|
||||||
* and simulating receiving roster pushes from the server.
|
* and simulating receiving roster pushes from the server.
|
||||||
*
|
*
|
||||||
* @param connection the dummy connection of which the provided roster belongs to.
|
* @param connection the dummy connection of which the provided roster belongs to.
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that verify the correct behavior of the {@see Roster} implementation
|
* Tests that verify the correct behavior of the {@link Roster} implementation
|
||||||
* with regard to roster versioning
|
* with regard to roster versioning
|
||||||
*
|
*
|
||||||
* @see Roster
|
* @see Roster
|
||||||
|
|
|
@ -16,9 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
import static org.custommonkey.xmlunit.XMLAssert.*;
|
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.custommonkey.xmlunit.Diff;
|
||||||
|
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
@ -116,7 +120,6 @@ public class MessageTest {
|
||||||
assertXMLEqual(control, message.toXML());
|
assertXMLEqual(control, message.toXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void multipleMessageBodiesTest() throws IOException, SAXException, ParserConfigurationException {
|
public void multipleMessageBodiesTest() throws IOException, SAXException, ParserConfigurationException {
|
||||||
final String messageBody1 = "This is a test of the emergency broadcast system, 1.";
|
final String messageBody1 = "This is a test of the emergency broadcast system, 1.";
|
||||||
|
@ -147,7 +150,9 @@ public class MessageTest {
|
||||||
message.addBody(null, messageBody1);
|
message.addBody(null, messageBody1);
|
||||||
message.addBody(lang2, messageBody2);
|
message.addBody(lang2, messageBody2);
|
||||||
message.addBody(lang3, messageBody3);
|
message.addBody(lang3, messageBody3);
|
||||||
assertXMLEqual(control, message.toXML());
|
Diff xmlDiff = new Diff(control, message.toXML());
|
||||||
|
xmlDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
|
||||||
|
assertTrue(xmlDiff.similar());
|
||||||
|
|
||||||
Collection<String> languages = message.getBodyLanguages();
|
Collection<String> languages = message.getBodyLanguages();
|
||||||
List<String> controlLanguages = new ArrayList<String>();
|
List<String> controlLanguages = new ArrayList<String>();
|
||||||
|
|
|
@ -17,10 +17,13 @@
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import static junit.framework.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
|
@ -19,22 +19,21 @@ package org.jivesoftware.smack.util;
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
import static junit.framework.Assert.assertFalse;
|
import static junit.framework.Assert.assertFalse;
|
||||||
import static junit.framework.Assert.assertNull;
|
import static junit.framework.Assert.assertNull;
|
||||||
import static junit.framework.Assert.assertTrue;
|
|
||||||
import static junit.framework.Assert.fail;
|
import static junit.framework.Assert.fail;
|
||||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLNotEqual;
|
import static org.custommonkey.xmlunit.XMLAssert.assertXMLNotEqual;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.custommonkey.xmlunit.DetailedDiff;
|
import org.custommonkey.xmlunit.DetailedDiff;
|
||||||
import org.custommonkey.xmlunit.Diff;
|
import org.custommonkey.xmlunit.Diff;
|
||||||
|
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.Presence;
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
import org.jivesoftware.smack.test.util.TestUtils;
|
import org.jivesoftware.smack.test.util.TestUtils;
|
||||||
//import org.jivesoftware.smackx.packet.DelayInformation;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -659,7 +658,6 @@ public class PacketParserUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void invalidMessageBodyContainingTagTest() throws Exception {
|
public void invalidMessageBodyContainingTagTest() throws Exception {
|
||||||
String control = XMLBuilder.create("message")
|
String control = XMLBuilder.create("message")
|
||||||
|
@ -686,7 +684,7 @@ public class PacketParserUtilsTest {
|
||||||
DetailedDiff diffs = new DetailedDiff(new Diff(control, message.toXML()));
|
DetailedDiff diffs = new DetailedDiff(new Diff(control, message.toXML()));
|
||||||
|
|
||||||
// body has no namespace URI, span is escaped
|
// body has no namespace URI, span is escaped
|
||||||
assertEquals(4, diffs.getAllDifferences().size());
|
assertEquals(6, diffs.getAllDifferences().size());
|
||||||
} catch(XmlPullParserException e) {
|
} catch(XmlPullParserException e) {
|
||||||
fail("No parser exception should be thrown" + e.getMessage());
|
fail("No parser exception should be thrown" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -735,7 +733,6 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void multipleMessageBodiesParsingTest() throws Exception {
|
public void multipleMessageBodiesParsingTest() throws Exception {
|
||||||
String control = XMLBuilder.create("message")
|
String control = XMLBuilder.create("message")
|
||||||
|
@ -757,7 +754,9 @@ public class PacketParserUtilsTest {
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
Packet message = PacketParserUtils.parseMessage(TestUtils.getMessageParser(control));
|
Packet message = PacketParserUtils.parseMessage(TestUtils.getMessageParser(control));
|
||||||
assertXMLEqual(control, message.toXML());
|
Diff xmlDiff = new Diff(control, message.toXML());
|
||||||
|
xmlDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
|
||||||
|
assertTrue(xmlDiff.similar());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -798,59 +797,6 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(1, presence.getPriority());
|
assertEquals(1, presence.getPriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Ignore // gradle migration
|
|
||||||
// @Test
|
|
||||||
// public void validatePresenceWithDelayedDelivery() throws Exception {
|
|
||||||
// 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));
|
|
||||||
//
|
|
||||||
// DelayInformation delay = (DelayInformation) presence.getExtension("urn:xmpp:delay");
|
|
||||||
// assertNotNull(delay);
|
|
||||||
// Date date = StringUtils.parseDate("2002-09-10T23:41:07Z");
|
|
||||||
// assertEquals(date, delay.getStamp());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Ignore // gradle migration
|
|
||||||
// @Test
|
|
||||||
// public void validatePresenceWithLegacyDelayed() throws Exception {
|
|
||||||
// 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));
|
|
||||||
//
|
|
||||||
// DelayInformation delay = (DelayInformation) presence.getExtension("jabber:x:delay");
|
|
||||||
// assertNotNull(delay);
|
|
||||||
// Date date = StringUtils.parseDate("20020910T23:41:07");
|
|
||||||
// Calendar cal = Calendar.getInstance();
|
|
||||||
// cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
||||||
// cal.setTime(date);
|
|
||||||
// assertEquals(cal.getTime(), delay.getStamp());
|
|
||||||
// }
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
|
||||||
public void parsePresenceWithInvalidDelayedDelivery() throws Exception {
|
|
||||||
String stanza = "<presence from='mercutio@example.com' to='juliet@example.com'>"
|
|
||||||
+ "<delay xmlns='urn:xmpp:delay'/></presence>";
|
|
||||||
|
|
||||||
Presence presence = PacketParserUtils.parsePresence(TestUtils.getPresenceParser(stanza));
|
|
||||||
assertNull(presence.getExtension("urn:xmpp:delay"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Ignore // gradle migration
|
|
||||||
// @Test
|
|
||||||
// public void parsePresenceWithInvalidLegacyDelayed() throws Exception {
|
|
||||||
// String stanza = "<presence from='mercutio@example.com' to='juliet@example.com'>"
|
|
||||||
// + "<x xmlns='jabber:x:delay'/></presence>";
|
|
||||||
//
|
|
||||||
// Presence presence = PacketParserUtils.parsePresence(TestUtils.getPresenceParser(stanza));
|
|
||||||
// DelayInformation delay = (DelayInformation) presence.getExtension("urn:xmpp:delay");
|
|
||||||
// assertNull(delay);
|
|
||||||
// }
|
|
||||||
|
|
||||||
private String determineNonDefaultLanguage() {
|
private String determineNonDefaultLanguage() {
|
||||||
String otherLanguage = "jp";
|
String otherLanguage = "jp";
|
||||||
Locale[] availableLocales = Locale.getAvailableLocales();
|
Locale[] availableLocales = Locale.getAvailableLocales();
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||||
import org.jivesoftware.smackx.xdata.FormField;
|
import org.jivesoftware.smackx.xdata.FormField;
|
||||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,14 +52,12 @@ public class EntityCapsManagerTest {
|
||||||
assertEquals("q07IKJEyjvHSyhy//CH0CxmKi8w=", ver);
|
assertEquals("q07IKJEyjvHSyhy//CH0CxmKi8w=", ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleDirectoryCacheBase64() throws IOException {
|
public void testSimpleDirectoryCacheBase64() throws IOException {
|
||||||
EntityCapsManager.persistentCache = null;
|
EntityCapsManager.persistentCache = null;
|
||||||
testSimpleDirectoryCache(Base64FileUrlEncoder.getInstance());
|
testSimpleDirectoryCache(Base64FileUrlEncoder.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleDirectoryCacheBase32() throws IOException {
|
public void testSimpleDirectoryCacheBase32() throws IOException {
|
||||||
EntityCapsManager.persistentCache = null;
|
EntityCapsManager.persistentCache = null;
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.delay.provider;
|
package org.jivesoftware.smackx.delay.provider;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -27,19 +27,21 @@ import java.util.GregorianCalendar;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.TimeZone;
|
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.smack.util.XmppDateTime;
|
||||||
|
import org.jivesoftware.smackx.InitExtensions;
|
||||||
import org.jivesoftware.smackx.delay.packet.DelayInfo;
|
import org.jivesoftware.smackx.delay.packet.DelayInfo;
|
||||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||||
import org.jivesoftware.smackx.delay.provider.DelayInfoProvider;
|
import org.jivesoftware.smackx.delay.provider.DelayInfoProvider;
|
||||||
import org.jivesoftware.smackx.delay.provider.DelayInformationProvider;
|
import org.jivesoftware.smackx.delay.provider.DelayInformationProvider;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
import com.jamesmurty.utils.XMLBuilder;
|
import com.jamesmurty.utils.XMLBuilder;
|
||||||
|
|
||||||
public class DelayInformationTest {
|
public class DelayInformationTest extends InitExtensions {
|
||||||
|
|
||||||
private static Properties outputProperties = new Properties();
|
private static Properties outputProperties = new Properties();
|
||||||
static {
|
static {
|
||||||
|
@ -63,7 +65,7 @@ public class DelayInformationTest {
|
||||||
.t("Offline Storage")
|
.t("Offline Storage")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
parser = getParser(control, "x");
|
parser = TestUtils.getParser(control, "x");
|
||||||
delayInfo = (DelayInformation) p.parseExtension(parser);
|
delayInfo = (DelayInformation) p.parseExtension(parser);
|
||||||
|
|
||||||
assertEquals("capulet.com", delayInfo.getFrom());
|
assertEquals("capulet.com", delayInfo.getFrom());
|
||||||
|
@ -79,7 +81,7 @@ public class DelayInformationTest {
|
||||||
.a("stamp", "2002-09-10T23:08:25Z")
|
.a("stamp", "2002-09-10T23:08:25Z")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
parser = getParser(control, "x");
|
parser = TestUtils.getParser(control, "x");
|
||||||
delayInfo = (DelayInformation) p.parseExtension(parser);
|
delayInfo = (DelayInformation) p.parseExtension(parser);
|
||||||
|
|
||||||
assertEquals("capulet.com", delayInfo.getFrom());
|
assertEquals("capulet.com", delayInfo.getFrom());
|
||||||
|
@ -108,7 +110,7 @@ public class DelayInformationTest {
|
||||||
.t("Offline Storage")
|
.t("Offline Storage")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
parser = getParser(control, "delay");
|
parser = TestUtils.getParser(control, "delay");
|
||||||
delayInfo = (DelayInfo) p.parseExtension(parser);
|
delayInfo = (DelayInfo) p.parseExtension(parser);
|
||||||
|
|
||||||
assertEquals("capulet.com", delayInfo.getFrom());
|
assertEquals("capulet.com", delayInfo.getFrom());
|
||||||
|
@ -124,7 +126,7 @@ public class DelayInformationTest {
|
||||||
.a("stamp", "2002-09-10T23:08:25Z")
|
.a("stamp", "2002-09-10T23:08:25Z")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
parser = getParser(control, "delay");
|
parser = TestUtils.getParser(control, "delay");
|
||||||
delayInfo = (DelayInfo) p.parseExtension(parser);
|
delayInfo = (DelayInfo) p.parseExtension(parser);
|
||||||
|
|
||||||
assertEquals("capulet.com", delayInfo.getFrom());
|
assertEquals("capulet.com", delayInfo.getFrom());
|
||||||
|
@ -151,7 +153,7 @@ public class DelayInformationTest {
|
||||||
.a("stamp", "2002-09-10T23:08:25.12Z")
|
.a("stamp", "2002-09-10T23:08:25.12Z")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
|
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||||
|
|
||||||
GregorianCalendar cal = (GregorianCalendar) calendar.clone();
|
GregorianCalendar cal = (GregorianCalendar) calendar.clone();
|
||||||
cal.add(Calendar.MILLISECOND, 12);
|
cal.add(Calendar.MILLISECOND, 12);
|
||||||
|
@ -164,7 +166,7 @@ public class DelayInformationTest {
|
||||||
.a("stamp", "2002-09-10T23:08:25Z")
|
.a("stamp", "2002-09-10T23:08:25Z")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
|
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||||
|
|
||||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||||
|
|
||||||
|
@ -175,7 +177,7 @@ public class DelayInformationTest {
|
||||||
.a("stamp", "2002-9-10T23:08:25Z")
|
.a("stamp", "2002-9-10T23:08:25Z")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
|
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||||
|
|
||||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||||
|
|
||||||
|
@ -186,7 +188,7 @@ public class DelayInformationTest {
|
||||||
.a("stamp", "20020910T23:08:25")
|
.a("stamp", "20020910T23:08:25")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
|
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||||
|
|
||||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||||
|
|
||||||
|
@ -206,7 +208,7 @@ public class DelayInformationTest {
|
||||||
.a("stamp", dateFormat.format(dateInPast.getTime()))
|
.a("stamp", dateFormat.format(dateInPast.getTime()))
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
|
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||||
|
|
||||||
assertEquals(dateInPast.getTime(), delayInfo.getStamp());
|
assertEquals(dateInPast.getTime(), delayInfo.getStamp());
|
||||||
|
|
||||||
|
@ -217,8 +219,8 @@ public class DelayInformationTest {
|
||||||
.a("stamp", "200868T09:16:20")
|
.a("stamp", "200868T09:16:20")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
|
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||||
Date controlDate = XmppDateTime.parseXEP0082Date("2008-06-08T09:16:20.0Z");
|
Date controlDate = XmppDateTime.parseDate("2008-06-08T09:16:20.0Z");
|
||||||
|
|
||||||
assertEquals(controlDate, delayInfo.getStamp());
|
assertEquals(controlDate, delayInfo.getStamp());
|
||||||
|
|
||||||
|
@ -229,25 +231,48 @@ public class DelayInformationTest {
|
||||||
.a("stamp", "yesterday")
|
.a("stamp", "yesterday")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
|
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
|
||||||
|
|
||||||
assertNotNull(delayInfo.getStamp());
|
assertNotNull(delayInfo.getStamp());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private XmlPullParser getParser(String control, String startTag)
|
@Test
|
||||||
throws XmlPullParserException, IOException {
|
public void validatePresenceWithDelayedDelivery() throws Exception {
|
||||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
String stanza = "<presence from='mercutio@example.com' to='juliet@example.com'>"
|
||||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
+ "<delay xmlns='urn:xmpp:delay' stamp='2002-09-10T23:41:07Z'/></presence>";
|
||||||
parser.setInput(new StringReader(control));
|
|
||||||
|
|
||||||
while (true) {
|
Presence presence = PacketParserUtils.parsePresence(TestUtils.getPresenceParser(stanza));
|
||||||
if (parser.next() == XmlPullParser.START_TAG
|
|
||||||
&& parser.getName().equals(startTag)) {
|
DelayInformation delay = (DelayInformation) presence.getExtension("urn:xmpp:delay");
|
||||||
break;
|
assertNotNull(delay);
|
||||||
}
|
Date date = XmppDateTime.parseDate("2002-09-10T23:41:07Z");
|
||||||
}
|
assertEquals(date, delay.getStamp());
|
||||||
return parser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validatePresenceWithLegacyDelayed() throws Exception {
|
||||||
|
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));
|
||||||
|
|
||||||
|
DelayInformation delay = (DelayInformation) presence.getExtension("jabber:x:delay");
|
||||||
|
assertNotNull(delay);
|
||||||
|
Date date = XmppDateTime.parseDate("20020910T23:41:07");
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
cal.setTime(date);
|
||||||
|
assertEquals(cal.getTime(), delay.getStamp());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parsePresenceWithInvalidLegacyDelayed() throws Exception {
|
||||||
|
String stanza = "<presence from='mercutio@example.com' to='juliet@example.com'>"
|
||||||
|
+ "<x xmlns='jabber:x:delay'/></presence>";
|
||||||
|
|
||||||
|
Presence presence = PacketParserUtils.parsePresence(TestUtils.getPresenceParser(stanza));
|
||||||
|
DelayInformation delay = (DelayInformation) presence.getExtension("urn:xmpp:delay");
|
||||||
|
assertNull((Object)delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2012 Florian Schmaus
|
* Copyright 2012-2014 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -26,13 +26,13 @@ import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.test.util.TestUtils;
|
import org.jivesoftware.smack.test.util.TestUtils;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
import org.jivesoftware.smackx.InitExtensions;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||||
import org.jivesoftware.smackx.ping.packet.Ping;
|
import org.jivesoftware.smackx.ping.packet.Ping;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class PingTest {
|
public class PingTest extends InitExtensions {
|
||||||
private DummyConnection dummyCon;
|
private DummyConnection dummyCon;
|
||||||
private ThreadedDummyConnection threadedCon;
|
private ThreadedDummyConnection threadedCon;
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ public class PingTest {
|
||||||
threadedCon = new ThreadedDummyConnection();
|
threadedCon = new ThreadedDummyConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void checkProvider() throws Exception {
|
public void checkProvider() throws Exception {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
@ -181,7 +180,6 @@ public class PingTest {
|
||||||
assertFalse(pingSuccess);
|
assertFalse(pingSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void checkSuccessfulDiscoRequest() throws Exception {
|
public void checkSuccessfulDiscoRequest() throws Exception {
|
||||||
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
||||||
|
@ -204,7 +202,6 @@ public class PingTest {
|
||||||
assertTrue(pingSupported);
|
assertTrue(pingSupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void checkUnuccessfulDiscoRequest() throws Exception {
|
public void checkUnuccessfulDiscoRequest() throws Exception {
|
||||||
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.pubsub;
|
package org.jivesoftware.smackx.pubsub;
|
||||||
|
|
||||||
import static org.custommonkey.xmlunit.XMLAssert.*;
|
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.test.util.TestUtils;
|
import org.jivesoftware.smack.test.util.TestUtils;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
import org.jivesoftware.smackx.InitExtensions;
|
||||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
|
@ -37,8 +37,7 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
* @author Robin Collier
|
* @author Robin Collier
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ItemValidationTest
|
public class ItemValidationTest extends InitExtensions {
|
||||||
{
|
|
||||||
private ThreadedDummyConnection connection;
|
private ThreadedDummyConnection connection;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -93,7 +92,6 @@ public class ItemValidationTest
|
||||||
assertXMLEqual(nodeIdCtrl, itemWithNodeId.toXML());
|
assertXMLEqual(nodeIdCtrl, itemWithNodeId.toXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void parseBasicItem() throws Exception
|
public void parseBasicItem() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -121,7 +119,6 @@ public class ItemValidationTest
|
||||||
assertEquals("testid1", ((Item)itemExt).getId());
|
assertEquals("testid1", ((Item)itemExt).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void parseSimplePayloadItem() throws Exception
|
public void parseSimplePayloadItem() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -155,7 +152,6 @@ public class ItemValidationTest
|
||||||
assertXMLEqual(itemContent, payload.toXML());
|
assertXMLEqual(itemContent, payload.toXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void parseComplexItem() throws Exception
|
public void parseComplexItem() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -203,7 +199,6 @@ public class ItemValidationTest
|
||||||
assertXMLEqual(itemContent, payload.toXML());
|
assertXMLEqual(itemContent, payload.toXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void parseEmptyTag() throws Exception
|
public void parseEmptyTag() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,31 +21,27 @@ import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jivesoftware.smack.DummyConnection;
|
import org.jivesoftware.smack.DummyConnection;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
|
import org.jivesoftware.smack.test.util.TestUtils;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
import org.jivesoftware.smackx.InitExtensions;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
import com.jamesmurty.utils.XMLBuilder;
|
import com.jamesmurty.utils.XMLBuilder;
|
||||||
|
|
||||||
public class DeliveryReceiptTest {
|
public class DeliveryReceiptTest extends InitExtensions {
|
||||||
|
|
||||||
private static Properties outputProperties = new Properties();
|
private static Properties outputProperties = new Properties();
|
||||||
static {
|
static {
|
||||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // gradle migration
|
|
||||||
@Test
|
@Test
|
||||||
public void receiptTest() throws Exception {
|
public void receiptTest() throws Exception {
|
||||||
XmlPullParser parser;
|
XmlPullParser parser;
|
||||||
|
@ -57,7 +53,7 @@ public class DeliveryReceiptTest {
|
||||||
.a("xmlns", "urn:xmpp:receipts")
|
.a("xmlns", "urn:xmpp:receipts")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
parser = getParser(control, "message");
|
parser = TestUtils.getMessageParser(control);
|
||||||
Packet p = PacketParserUtils.parseMessage(parser);
|
Packet p = PacketParserUtils.parseMessage(parser);
|
||||||
|
|
||||||
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)p.getExtension(
|
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)p.getExtension(
|
||||||
|
@ -129,18 +125,4 @@ public class DeliveryReceiptTest {
|
||||||
assertEquals("romeo@montague.com", reply.getTo());
|
assertEquals("romeo@montague.com", reply.getTo());
|
||||||
assertEquals("test-receipt-request", r.getId());
|
assertEquals("test-receipt-request", r.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private XmlPullParser getParser(String control, String startTag)
|
|
||||||
throws XmlPullParserException, IOException {
|
|
||||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
|
||||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
|
||||||
parser.setInput(new StringReader(control));
|
|
||||||
while (true) {
|
|
||||||
if (parser.next() == XmlPullParser.START_TAG
|
|
||||||
&& parser.getName().equals(startTag)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return parser;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue