1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Re-activate all ignored unit-tests

Make all unit tests functional again.
This commit is contained in:
Florian Schmaus 2014-03-10 21:48:46 +01:00
parent a6ed3b2514
commit 4fb5b85806
15 changed files with 112 additions and 164 deletions

View file

@ -35,7 +35,6 @@ import org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.junit.Ignore;
import org.junit.Test;
@ -53,14 +52,12 @@ public class EntityCapsManagerTest {
assertEquals("q07IKJEyjvHSyhy//CH0CxmKi8w=", ver);
}
@Ignore // gradle migration
@Test
public void testSimpleDirectoryCacheBase64() throws IOException {
EntityCapsManager.persistentCache = null;
testSimpleDirectoryCache(Base64FileUrlEncoder.getInstance());
}
@Ignore // gradle migration
@Test
public void testSimpleDirectoryCacheBase32() throws IOException {
EntityCapsManager.persistentCache = null;

View file

@ -16,10 +16,10 @@
*/
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.util.Calendar;
import java.util.Date;
@ -27,19 +27,21 @@ import java.util.GregorianCalendar;
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;
import org.jivesoftware.smackx.delay.packet.DelayInfo;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
import org.jivesoftware.smackx.delay.provider.DelayInfoProvider;
import org.jivesoftware.smackx.delay.provider.DelayInformationProvider;
import org.junit.Test;
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import com.jamesmurty.utils.XMLBuilder;
public class DelayInformationTest {
public class DelayInformationTest extends InitExtensions {
private static Properties outputProperties = new Properties();
static {
@ -62,8 +64,8 @@ public class DelayInformationTest {
.a("stamp", "2002-09-10T23:08:25Z")
.t("Offline Storage")
.asString(outputProperties);
parser = getParser(control, "x");
parser = TestUtils.getParser(control, "x");
delayInfo = (DelayInformation) p.parseExtension(parser);
assertEquals("capulet.com", delayInfo.getFrom());
@ -78,8 +80,8 @@ public class DelayInformationTest {
.a("from", "capulet.com")
.a("stamp", "2002-09-10T23:08:25Z")
.asString(outputProperties);
parser = getParser(control, "x");
parser = TestUtils.getParser(control, "x");
delayInfo = (DelayInformation) p.parseExtension(parser);
assertEquals("capulet.com", delayInfo.getFrom());
@ -108,7 +110,7 @@ public class DelayInformationTest {
.t("Offline Storage")
.asString(outputProperties);
parser = getParser(control, "delay");
parser = TestUtils.getParser(control, "delay");
delayInfo = (DelayInfo) p.parseExtension(parser);
assertEquals("capulet.com", delayInfo.getFrom());
@ -124,7 +126,7 @@ public class DelayInformationTest {
.a("stamp", "2002-09-10T23:08:25Z")
.asString(outputProperties);
parser = getParser(control, "delay");
parser = TestUtils.getParser(control, "delay");
delayInfo = (DelayInfo) p.parseExtension(parser);
assertEquals("capulet.com", delayInfo.getFrom());
@ -150,8 +152,8 @@ public class DelayInformationTest {
.a("from", "capulet.com")
.a("stamp", "2002-09-10T23:08:25.12Z")
.asString(outputProperties);
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
GregorianCalendar cal = (GregorianCalendar) calendar.clone();
cal.add(Calendar.MILLISECOND, 12);
@ -163,9 +165,9 @@ public class DelayInformationTest {
.a("from", "capulet.com")
.a("stamp", "2002-09-10T23:08:25Z")
.asString(outputProperties);
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
assertEquals(calendar.getTime(), delayInfo.getStamp());
// XEP-0082 date format without milliseconds and leading 0 in month
@ -175,7 +177,7 @@ public class DelayInformationTest {
.a("stamp", "2002-9-10T23:08:25Z")
.asString(outputProperties);
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
assertEquals(calendar.getTime(), delayInfo.getStamp());
@ -186,7 +188,7 @@ public class DelayInformationTest {
.a("stamp", "20020910T23:08:25")
.asString(outputProperties);
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
assertEquals(calendar.getTime(), delayInfo.getStamp());
@ -205,9 +207,9 @@ public class DelayInformationTest {
.a("from", "capulet.com")
.a("stamp", dateFormat.format(dateInPast.getTime()))
.asString(outputProperties);
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
assertEquals(dateInPast.getTime(), delayInfo.getStamp());
// XEP-0091 date format from SMACK-243
@ -216,9 +218,9 @@ public class DelayInformationTest {
.a("from", "capulet.com")
.a("stamp", "200868T09:16:20")
.asString(outputProperties);
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
Date controlDate = XmppDateTime.parseXEP0082Date("2008-06-08T09:16:20.0Z");
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
Date controlDate = XmppDateTime.parseDate("2008-06-08T09:16:20.0Z");
assertEquals(controlDate, delayInfo.getStamp());
@ -229,25 +231,48 @@ public class DelayInformationTest {
.a("stamp", "yesterday")
.asString(outputProperties);
delayInfo = (DelayInfo) p.parseExtension(getParser(control, "delay"));
delayInfo = (DelayInfo) p.parseExtension(TestUtils.getParser(control, "delay"));
assertNotNull(delayInfo.getStamp());
}
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;
@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 = XmppDateTime.parseDate("2002-09-10T23:41:07Z");
assertEquals(date, delay.getStamp());
}
@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);
}
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2012 Florian Schmaus
* Copyright 2012-2014 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (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.test.util.TestUtils;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.ping.packet.Ping;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
public class PingTest {
public class PingTest extends InitExtensions {
private DummyConnection dummyCon;
private ThreadedDummyConnection threadedCon;
@ -42,7 +42,6 @@ public class PingTest {
threadedCon = new ThreadedDummyConnection();
}
@Ignore // gradle migration
@Test
public void checkProvider() throws Exception {
// @formatter:off
@ -181,7 +180,6 @@ public class PingTest {
assertFalse(pingSuccess);
}
@Ignore // gradle migration
@Test
public void checkSuccessfulDiscoRequest() throws Exception {
ThreadedDummyConnection con = new ThreadedDummyConnection();
@ -204,7 +202,6 @@ public class PingTest {
assertTrue(pingSupported);
}
@Ignore // gradle migration
@Test
public void checkUnuccessfulDiscoRequest() throws Exception {
ThreadedDummyConnection con = new ThreadedDummyConnection();

View file

@ -16,7 +16,7 @@
*/
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.assertTrue;
@ -25,10 +25,10 @@ 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;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.xmlpull.v1.XmlPullParser;
@ -37,8 +37,7 @@ import org.xmlpull.v1.XmlPullParser;
* @author Robin Collier
*
*/
public class ItemValidationTest
{
public class ItemValidationTest extends InitExtensions {
private ThreadedDummyConnection connection;
@Before
@ -93,7 +92,6 @@ public class ItemValidationTest
assertXMLEqual(nodeIdCtrl, itemWithNodeId.toXML());
}
@Ignore // gradle migration
@Test
public void parseBasicItem() throws Exception
{
@ -121,7 +119,6 @@ public class ItemValidationTest
assertEquals("testid1", ((Item)itemExt).getId());
}
@Ignore // gradle migration
@Test
public void parseSimplePayloadItem() throws Exception
{
@ -155,7 +152,6 @@ public class ItemValidationTest
assertXMLEqual(itemContent, payload.toXML());
}
@Ignore // gradle migration
@Test
public void parseComplexItem() throws Exception
{
@ -203,7 +199,6 @@ public class ItemValidationTest
assertXMLEqual(itemContent, payload.toXML());
}
@Ignore // gradle migration
@Test
public void parseEmptyTag() throws Exception
{

View file

@ -21,31 +21,27 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.StringReader;
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;
import org.junit.Ignore;
import org.junit.Test;
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import com.jamesmurty.utils.XMLBuilder;
public class DeliveryReceiptTest {
public class DeliveryReceiptTest extends InitExtensions {
private static Properties outputProperties = new Properties();
static {
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
}
@Ignore // gradle migration
@Test
public void receiptTest() throws Exception {
XmlPullParser parser;
@ -57,7 +53,7 @@ public class DeliveryReceiptTest {
.a("xmlns", "urn:xmpp:receipts")
.asString(outputProperties);
parser = getParser(control, "message");
parser = TestUtils.getMessageParser(control);
Packet p = PacketParserUtils.parseMessage(parser);
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)p.getExtension(
@ -129,18 +125,4 @@ public class DeliveryReceiptTest {
assertEquals("romeo@montague.com", reply.getTo());
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;
}
}