mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-08 06:01:07 +01:00
Replace XPP3 by XmlPullParser interface wrapping StAX and XPP3
Introducing Smack's own XmlPullParser interface which tries to stay as compatible as possible to XPP3. The interface is used to either wrap StAX's XMLStreamReader if Smack is used on Java SE, and XPP3's XmlPullParser if Smack is used on on Android. Fixes SMACK-591. Also introduce JUnit 5 and non-strict javadoc projects.
This commit is contained in:
parent
b3646abecd
commit
4133eb175c
414 changed files with 3855 additions and 2041 deletions
|
|
@ -24,14 +24,14 @@ import java.io.InputStream;
|
|||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.amp.packet.AMPExtension;
|
||||
import org.jivesoftware.smackx.amp.provider.AMPExtensionProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
public class AMPExtensionTest {
|
||||
|
||||
|
|
@ -65,11 +65,9 @@ public class AMPExtensionTest {
|
|||
@Test
|
||||
public void isCorrectFromXmlErrorHandling() throws Exception {
|
||||
AMPExtensionProvider ampProvider = new AMPExtensionProvider();
|
||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
||||
parser.setInput(INCORRECT_RECEIVING_STANZA_STREAM, "UTF-8");
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(INCORRECT_RECEIVING_STANZA_STREAM);
|
||||
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals(XmlPullParser.Event.START_ELEMENT, parser.next());
|
||||
assertEquals(AMPExtension.ELEMENT, parser.getName());
|
||||
|
||||
ExtensionElement extension = ampProvider.parse(parser);
|
||||
|
|
@ -85,11 +83,9 @@ public class AMPExtensionTest {
|
|||
@Test
|
||||
public void isCorrectFromXmlDeserialization() throws Exception {
|
||||
AMPExtensionProvider ampProvider = new AMPExtensionProvider();
|
||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
||||
parser.setInput(CORRECT_SENDING_STANZA_STREAM, "UTF-8");
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(CORRECT_SENDING_STANZA_STREAM);
|
||||
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals(XmlPullParser.Event.START_ELEMENT, parser.next());
|
||||
assertEquals(AMPExtension.ELEMENT, parser.getName());
|
||||
ExtensionElement extension = ampProvider.parse(parser);
|
||||
assertTrue(extension instanceof AMPExtension);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.blocking;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -24,7 +26,6 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.blocking.element.BlockContactsIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
|
@ -47,15 +48,15 @@ public class BlockContactsIQTest {
|
|||
BlockContactsIQ blockContactIQ = new BlockContactsIQ(jids);
|
||||
blockContactIQ.setStanzaId("block1");
|
||||
|
||||
Assert.assertEquals(blockContactIQExample, blockContactIQ.toXML().toString());
|
||||
assertEquals(blockContactIQExample, blockContactIQ.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkBlockContactPushIQ() throws Exception {
|
||||
IQ iq = PacketParserUtils.parseStanza(blockContactPushIQExample);
|
||||
BlockContactsIQ blockContactIQ = (BlockContactsIQ) iq;
|
||||
Assert.assertEquals(JidCreate.from("romeo@montague.net"), blockContactIQ.getJids().get(0));
|
||||
Assert.assertEquals(JidCreate.from("pepe@montague.net"), blockContactIQ.getJids().get(1));
|
||||
assertEquals(JidCreate.from("romeo@montague.net"), blockContactIQ.getJids().get(0));
|
||||
assertEquals(JidCreate.from("pepe@montague.net"), blockContactIQ.getJids().get(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.blocking;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.blocking.element.BlockedErrorExtension;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BlockedErrorExtensionTest {
|
||||
|
|
@ -44,13 +46,13 @@ public class BlockedErrorExtensionTest {
|
|||
@Test
|
||||
public void checkErrorHasBlockedExtension() throws Exception {
|
||||
Message message1 = PacketParserUtils.parseStanza(messageWithoutError);
|
||||
Assert.assertFalse(BlockedErrorExtension.isInside(message1));
|
||||
assertFalse(BlockedErrorExtension.isInside(message1));
|
||||
|
||||
Message message2 = PacketParserUtils.parseStanza(messageWithError);
|
||||
Assert.assertFalse(BlockedErrorExtension.isInside(message2));
|
||||
assertFalse(BlockedErrorExtension.isInside(message2));
|
||||
|
||||
Message message3 = PacketParserUtils.parseStanza(messageWithBlockedError);
|
||||
Assert.assertTrue(BlockedErrorExtension.isInside(message3));
|
||||
assertTrue(BlockedErrorExtension.isInside(message3));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.blocking;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
|
@ -23,7 +25,6 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.blocking.element.BlockListIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
@ -43,20 +44,20 @@ public class GetBlockingListTest {
|
|||
BlockListIQ getBlockListIQ = new BlockListIQ(null);
|
||||
getBlockListIQ.setType(Type.get);
|
||||
getBlockListIQ.setStanzaId("blocklist1");
|
||||
Assert.assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkBlockListIQ() throws Exception {
|
||||
IQ iq = PacketParserUtils.parseStanza(blockListIQExample);
|
||||
BlockListIQ blockListIQ = (BlockListIQ) iq;
|
||||
Assert.assertEquals(2, blockListIQ.getBlockedJids().size());
|
||||
Assert.assertEquals(JidCreate.from("romeo@montague.net"), blockListIQ.getBlockedJids().get(0));
|
||||
Assert.assertEquals(JidCreate.from("iago@shakespeare.lit"), blockListIQ.getBlockedJids().get(1));
|
||||
assertEquals(2, blockListIQ.getBlockedJids().size());
|
||||
assertEquals(JidCreate.from("romeo@montague.net"), blockListIQ.getBlockedJids().get(0));
|
||||
assertEquals(JidCreate.from("iago@shakespeare.lit"), blockListIQ.getBlockedJids().get(1));
|
||||
|
||||
IQ iq2 = PacketParserUtils.parseStanza(emptyBlockListIQExample);
|
||||
BlockListIQ emptyBlockListIQ = (BlockListIQ) iq2;
|
||||
Assert.assertEquals(0, emptyBlockListIQ.getBlockedJids().size());
|
||||
assertEquals(0, emptyBlockListIQ.getBlockedJids().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.blocking;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -25,7 +28,6 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.blocking.element.UnblockContactsIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
|
@ -54,29 +56,29 @@ public class UnblockContactsIQTest {
|
|||
UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(jids);
|
||||
unblockContactIQ.setStanzaId("unblock1");
|
||||
|
||||
Assert.assertEquals(unblockContactIQExample, unblockContactIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(unblockContactIQExample, unblockContactIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkUnblockContactPushIQ() throws Exception {
|
||||
IQ iq = PacketParserUtils.parseStanza(unblockContactPushIQExample);
|
||||
UnblockContactsIQ unblockContactIQ = (UnblockContactsIQ) iq;
|
||||
Assert.assertEquals(JidCreate.from("romeo@montague.net"), unblockContactIQ.getJids().get(0));
|
||||
Assert.assertEquals(JidCreate.from("pepe@montague.net"), unblockContactIQ.getJids().get(1));
|
||||
assertEquals(JidCreate.from("romeo@montague.net"), unblockContactIQ.getJids().get(0));
|
||||
assertEquals(JidCreate.from("pepe@montague.net"), unblockContactIQ.getJids().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkUnblockAllIQStanza() throws Exception {
|
||||
UnblockContactsIQ unblockAllIQ = new UnblockContactsIQ(null);
|
||||
unblockAllIQ.setStanzaId("unblock2");
|
||||
Assert.assertEquals(unblockAllIQExample, unblockAllIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(unblockAllIQExample, unblockAllIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkUnblockAllPushIQ() throws Exception {
|
||||
IQ iq = PacketParserUtils.parseStanza(unblockAllPushIQExample);
|
||||
UnblockContactsIQ unblockAllIQ = (UnblockContactsIQ) iq;
|
||||
Assert.assertNull(unblockAllIQ.getJids());
|
||||
assertNull(unblockAllIQ.getJids());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bob;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
|
@ -24,7 +26,6 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
|
||||
import org.jivesoftware.smackx.bob.element.BoBIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ public class BoBIQTest extends SmackTestSuite {
|
|||
createdBoBIQ.setTo(JidCreate.from("ladymacbeth@shakespeare.lit/castle"));
|
||||
createdBoBIQ.setType(Type.get);
|
||||
|
||||
Assert.assertEquals(sampleBoBIQRequest, createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(sampleBoBIQRequest, createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -61,12 +62,12 @@ public class BoBIQTest extends SmackTestSuite {
|
|||
createdBoBIQ.setTo(JidCreate.from("doctor@shakespeare.lit/pda"));
|
||||
createdBoBIQ.setType(Type.result);
|
||||
|
||||
Assert.assertEquals(bobIQ.getBoBHash().getHash(), createdBoBIQ.getBoBHash().getHash());
|
||||
Assert.assertEquals(bobIQ.getBoBHash().getHashType(), createdBoBIQ.getBoBHash().getHashType());
|
||||
Assert.assertEquals(bobIQ.getBoBData().getMaxAge(), createdBoBIQ.getBoBData().getMaxAge());
|
||||
Assert.assertEquals(bobIQ.getBoBData().getType(), createdBoBIQ.getBoBData().getType());
|
||||
Assert.assertEquals(bobIQ.getBoBData().getContentBase64Encoded(), createdBoBIQ.getBoBData().getContentBase64Encoded());
|
||||
Assert.assertEquals(bobIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(bobIQ.getBoBHash().getHash(), createdBoBIQ.getBoBHash().getHash());
|
||||
assertEquals(bobIQ.getBoBHash().getHashType(), createdBoBIQ.getBoBHash().getHashType());
|
||||
assertEquals(bobIQ.getBoBData().getMaxAge(), createdBoBIQ.getBoBData().getMaxAge());
|
||||
assertEquals(bobIQ.getBoBData().getType(), createdBoBIQ.getBoBData().getType());
|
||||
assertEquals(bobIQ.getBoBData().getContentBase64Encoded(), createdBoBIQ.getBoBData().getContentBase64Encoded());
|
||||
assertEquals(bobIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
|
|
@ -28,7 +29,6 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
|||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* Test for the OpenIQProvider class.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015 Florian Schmaus
|
||||
* Copyright 2015-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -18,17 +18,19 @@ package org.jivesoftware.smackx.caps.provider;
|
|||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.caps.packet.CapsExtension;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
public class CapsExtensionProviderTest extends InitExtensions {
|
||||
|
||||
@Test
|
||||
public void parseTest() throws Exception {
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void parseTest(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
|
||||
// @formatter:off
|
||||
final String capsExtensionString =
|
||||
"<c xmlns='http://jabber.org/protocol/caps'"
|
||||
|
|
@ -36,7 +38,7 @@ public class CapsExtensionProviderTest extends InitExtensions {
|
|||
+ " node='http://foo.example.org/bar'"
|
||||
+ " ver='QgayPKawpkPSDYmwt/WM94uA1u0='/>";
|
||||
// @formatter:on
|
||||
CapsExtension capsExtension = TestUtils.parseExtensionElement(capsExtensionString);
|
||||
CapsExtension capsExtension = SmackTestUtil.parse(capsExtensionString, CapsExtensionProvider.class, parserKind);
|
||||
assertNotNull(capsExtension);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import javax.xml.parsers.FactoryConfigurationError;
|
|||
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.delay.DelayInformationManager;
|
||||
|
|
@ -40,8 +42,6 @@ import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
|||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class DelayInformationTest extends InitExtensions {
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
assertEquals(date, delayInfo.getStamp());
|
||||
assertEquals("Offline Storage", delayInfo.getReason());
|
||||
|
||||
assertEquals(XmlPullParser.END_TAG, parser.getEventType());
|
||||
assertEquals(XmlPullParser.Event.END_ELEMENT, parser.getEventType());
|
||||
assertEquals("x", parser.getName());
|
||||
|
||||
control = XMLBuilder.create("x")
|
||||
|
|
@ -92,7 +92,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
assertEquals(date, delayInfo.getStamp());
|
||||
assertNull(delayInfo.getReason());
|
||||
|
||||
assertEquals(XmlPullParser.END_TAG, parser.getEventType());
|
||||
assertEquals(XmlPullParser.Event.END_ELEMENT, parser.getEventType());
|
||||
assertEquals("x", parser.getName());
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import static org.junit.Assert.assertThat;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
|
|
@ -31,7 +32,6 @@ import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
|
|||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class ForwardedTest {
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ public class ForwardedTest {
|
|||
assertThat("romeo@montague.com", equalsCharSequence(fwd.getForwardedStanza().getFrom()));
|
||||
|
||||
// check end of tag
|
||||
assertEquals(XmlPullParser.END_TAG, parser.getEventType());
|
||||
assertEquals(XmlPullParser.Event.END_ELEMENT, parser.getEventType());
|
||||
assertEquals("forwarded", parser.getName());
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ public class ForwardedTest {
|
|||
assertThat("romeo@montague.com", equalsCharSequence(fwd.getForwardedStanza().getFrom()));
|
||||
|
||||
// check end of tag
|
||||
assertEquals(XmlPullParser.END_TAG, parser.getEventType());
|
||||
assertEquals(XmlPullParser.Event.END_ELEMENT, parser.getEventType());
|
||||
assertEquals("forwarded", parser.getName());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import static junit.framework.TestCase.assertNotSame;
|
|||
import static junit.framework.TestCase.assertNull;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
||||
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.element.JingleError;
|
||||
import org.jivesoftware.smackx.jingle.provider.JingleErrorProvider;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.jingle;
|
|||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||
import static junit.framework.TestCase.assertNull;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider;
|
||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ import static org.junit.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class JingleProviderTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import static junit.framework.TestCase.assertNull;
|
|||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate;
|
||||
|
|
|
|||
|
|
@ -25,12 +25,13 @@ import java.util.Date;
|
|||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.last_interaction.element.IdleElement;
|
||||
import org.jivesoftware.smackx.last_interaction.provider.IdleProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class IdleTest extends SmackTestSuite {
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.message_correct;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.message_correct.element.MessageCorrectExtension;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MessageCorrectExtensionTest {
|
||||
|
|
@ -42,11 +43,11 @@ public class MessageCorrectExtensionTest {
|
|||
Message initialMessage = PacketParserUtils.parseStanza(initialMessageXml);
|
||||
MessageCorrectExtension messageCorrectExtension = new MessageCorrectExtension(idInitialMessage);
|
||||
|
||||
Assert.assertEquals(messageCorrectExtension.toXML().toString(), messageCorrectionXml.toString());
|
||||
assertEquals(messageCorrectExtension.toXML().toString(), messageCorrectionXml.toString());
|
||||
|
||||
initialMessage.addExtension(messageCorrectExtension);
|
||||
|
||||
Assert.assertEquals(initialMessage.toXML().toString(), expectedXml.toString());
|
||||
assertEquals(initialMessage.toXML().toString(), expectedXml.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,13 +24,14 @@ import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
|||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
|
||||
import org.jivesoftware.smackx.mood.element.MoodElement;
|
||||
import org.jivesoftware.smackx.mood.provider.MoodProvider;
|
||||
import org.jivesoftware.smackx.mood.provider.SimpleMoodConcretisationProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* This test checks, if extending XEP-0107: User Mood using custom mood concretisations works.
|
||||
|
|
|
|||
|
|
@ -23,12 +23,13 @@ import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
|||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.mood.element.MoodElement;
|
||||
import org.jivesoftware.smackx.mood.provider.MoodProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class MoodElementTest extends SmackTestSuite {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import static junit.framework.TestCase.assertTrue;
|
|||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
import org.jivesoftware.smackx.mood.element.MoodElement;
|
||||
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
|
|||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
@ -77,7 +76,7 @@ public class ConfigureFormTest extends InitExtensions {
|
|||
fail();
|
||||
}
|
||||
catch (XMPPErrorException e) {
|
||||
Assert.assertEquals(StanzaError.Type.AUTH, e.getStanzaError().getType());
|
||||
assertEquals(StanzaError.Type.AUTH, e.getStanzaError().getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.packet.ExtensionElement;
|
|||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
|
|
@ -32,7 +33,6 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* Item validation test.
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.jivesoftware.smack.packet.IQ.Type;
|
|||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.pubsub.Affiliation.AffiliationNamespace;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
|
|
@ -40,7 +41,6 @@ import org.jivesoftware.util.Protocol;
|
|||
import org.junit.Test;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class PubSubNodeTest extends SmackTestSuite {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.pubsub.PubSubElementType;
|
||||
import org.jivesoftware.smackx.pubsub.Subscription;
|
||||
|
|
@ -31,7 +32,6 @@ import org.jivesoftware.smackx.pubsub.SubscriptionsExtension;
|
|||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class PubSubProviderTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.jivesoftware.smack.packet.Message;
|
|||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.test.util.WaitForPacketListener;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.receipts.DeliveryReceiptManager.AutoReceiptMode;
|
||||
|
|
@ -38,7 +39,6 @@ import com.jamesmurty.utils.XMLBuilder;
|
|||
import org.junit.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class DeliveryReceiptTest extends InitExtensions {
|
||||
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ import static org.junit.Assert.assertEquals;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.shim.packet.Header;
|
||||
import org.jivesoftware.smackx.shim.packet.HeadersExtension;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class HeadersProviderTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull;
|
|||
|
||||
import org.jivesoftware.smack.packet.Element;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.FormField.Type;
|
||||
|
|
@ -33,7 +34,6 @@ import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement;
|
|||
import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.RangeValidateElement;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* Unit tests for DataForm reading and parsing.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
|
|
@ -33,8 +35,6 @@ import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Text;
|
|||
import org.jivesoftware.smackx.xdatalayout.provider.DataLayoutProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Unit tests for DataForm reading and parsing.
|
||||
|
|
@ -143,9 +143,8 @@ public class DataLayoutTest {
|
|||
public void testLayoutFromFile() throws Exception {
|
||||
DataFormProvider pr = new DataFormProvider();
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.newXmppParser();
|
||||
parser.setInput(new InputStreamReader(this.getClass().getResourceAsStream(TEST_INPUT_1), "UTF-8"));
|
||||
parser.next();
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(this.getClass().getResourceAsStream(TEST_INPUT_1), "UTF-8");
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(inputStreamReader);
|
||||
|
||||
DataForm form = pr.parse(parser);
|
||||
assertNotNull(form);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014 Anno van Vliet, 2018 Florian Schmaus
|
||||
* Copyright 2014 Anno van Vliet, 2018-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -22,18 +22,22 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement;
|
||||
import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.BasicValidateElement;
|
||||
import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.ListRange;
|
||||
import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.RangeValidateElement;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
/**
|
||||
* Data validation test.
|
||||
|
|
@ -132,8 +136,9 @@ public class DataValidationTest {
|
|||
DataValidationProvider.parse(parser);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamespacePrefix() throws Exception {
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void testNamespacePrefix(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
|
||||
String formFieldUsingNamespacePrefix =
|
||||
"<x xmlns='jabber:x:data'" +
|
||||
" xmlns:xdv='http://jabber.org/protocol/xdata-validate'" +
|
||||
|
|
@ -155,7 +160,7 @@ public class DataValidationTest {
|
|||
" </field>" +
|
||||
"</x>";
|
||||
|
||||
DataForm dataForm = TestUtils.parseExtensionElement(formFieldUsingNamespacePrefix);
|
||||
DataForm dataForm = SmackTestUtil.parse(formFieldUsingNamespacePrefix, DataFormProvider.class, parserKind);
|
||||
|
||||
assertEquals("Sample Form", dataForm.getTitle());
|
||||
|
||||
|
|
|
|||
|
|
@ -21,24 +21,24 @@ import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequ
|
|||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.xhtmlim.packet.XHTMLExtension;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
||||
public class XHTMLExtensionProviderTest {
|
||||
public static final String XHTML_EXTENSION_SAMPLE_RESOURCE_NAME = "xhtml.xml";
|
||||
|
||||
@Test
|
||||
public void parsesWell() throws IOException, XmlPullParserException {
|
||||
XmlPullParser parser = PacketParserUtils.newXmppParser();
|
||||
parser.setInput(getClass().getResourceAsStream(XHTML_EXTENSION_SAMPLE_RESOURCE_NAME), "UTF-8");
|
||||
InputStream inputStream = getClass().getResourceAsStream(XHTML_EXTENSION_SAMPLE_RESOURCE_NAME);
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(inputStream);
|
||||
parser.next();
|
||||
|
||||
XHTMLExtensionProvider provider = new XHTMLExtensionProvider();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue