mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-07 05:31:08 +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
|
|
@ -16,13 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.experimental.ExperimentalInitializer;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExperimentalInitializerTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,15 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.carbons;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.ExperimentalInitializerTest;
|
||||
import org.jivesoftware.smackx.carbons.packet.CarbonExtension;
|
||||
|
|
@ -30,8 +32,9 @@ import org.jivesoftware.smackx.carbons.provider.CarbonManagerProvider;
|
|||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
public class CarbonTest extends ExperimentalInitializerTest {
|
||||
|
||||
|
|
@ -65,10 +68,10 @@ public class CarbonTest extends ExperimentalInitializerTest {
|
|||
assertEquals(null, fwd.getDelayInformation());
|
||||
|
||||
// check message
|
||||
assertThat("romeo@montague.com", equalsCharSequence(fwd.getForwardedStanza().getFrom()));
|
||||
assertEquals("romeo@montague.com", fwd.getForwardedStanza().getFrom().toString());
|
||||
|
||||
// check end of tag
|
||||
assertEquals(XmlPullParser.END_TAG, parser.getEventType());
|
||||
assertEquals(XmlPullParser.Event.END_ELEMENT, parser.getEventType());
|
||||
assertEquals("sent", parser.getName());
|
||||
}
|
||||
|
||||
|
|
@ -91,20 +94,19 @@ public class CarbonTest extends ExperimentalInitializerTest {
|
|||
assertEquals(CarbonExtension.Direction.received, cc.getDirection());
|
||||
|
||||
// check end of tag
|
||||
assertEquals(XmlPullParser.END_TAG, parser.getEventType());
|
||||
assertEquals(XmlPullParser.Event.END_ELEMENT, parser.getEventType());
|
||||
assertEquals("received", parser.getName());
|
||||
}
|
||||
|
||||
@Test(expected = Exception.class)
|
||||
public void carbonEmptyTest() throws Exception {
|
||||
XmlPullParser parser;
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void carbonEmptyTest(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
|
||||
String control;
|
||||
|
||||
control = XMLBuilder.create("sent")
|
||||
.a("xmlns", "urn:xmpp:forwarded:0")
|
||||
.asString(outputProperties);
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
new CarbonManagerProvider().parse(parser);
|
||||
assertThrows(IOException.class, () -> SmackTestUtil.parse(control, CarbonManagerProvider.class, parserKind));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,19 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.chat_markers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements.AcknowledgedExtension;
|
||||
import org.jivesoftware.smackx.chat_markers.provider.AcknowledgedProvider;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class AcknowledgedExtensionTest {
|
||||
|
||||
|
|
@ -41,18 +42,18 @@ public class AcknowledgedExtensionTest {
|
|||
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
||||
message.setStanzaId("message-2");
|
||||
message.addExtension(new ChatMarkersElements.AcknowledgedExtension("message-1"));
|
||||
Assert.assertEquals(acknowledgedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(acknowledgedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkDisplayedProvider() throws Exception {
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(acknowledgedExtension);
|
||||
AcknowledgedExtension acknowledgedExtension1 = new AcknowledgedProvider().parse(parser);
|
||||
Assert.assertEquals("message-1", acknowledgedExtension1.getId());
|
||||
assertEquals("message-1", acknowledgedExtension1.getId());
|
||||
|
||||
Message message = PacketParserUtils.parseStanza(acknowledgedMessageStanza);
|
||||
AcknowledgedExtension acknowledgedExtension2 = AcknowledgedExtension.from(message);
|
||||
Assert.assertEquals("message-1", acknowledgedExtension2.getId());
|
||||
assertEquals("message-1", acknowledgedExtension2.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,19 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.chat_markers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements.DisplayedExtension;
|
||||
import org.jivesoftware.smackx.chat_markers.provider.DisplayedProvider;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class DisplayedExtensionTest {
|
||||
|
||||
|
|
@ -41,18 +42,18 @@ public class DisplayedExtensionTest {
|
|||
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
||||
message.setStanzaId("message-2");
|
||||
message.addExtension(new ChatMarkersElements.DisplayedExtension("message-1"));
|
||||
Assert.assertEquals(displayedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(displayedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkDisplayedProvider() throws Exception {
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(displayedExtension);
|
||||
DisplayedExtension displayedExtension1 = new DisplayedProvider().parse(parser);
|
||||
Assert.assertEquals("message-1", displayedExtension1.getId());
|
||||
assertEquals("message-1", displayedExtension1.getId());
|
||||
|
||||
Message message = PacketParserUtils.parseStanza(displayedMessageStanza);
|
||||
DisplayedExtension displayedExtension2 = DisplayedExtension.from(message);
|
||||
Assert.assertEquals("message-1", displayedExtension2.getId());
|
||||
assertEquals("message-1", displayedExtension2.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,18 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.chat_markers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements.MarkableExtension;
|
||||
import org.jivesoftware.smackx.chat_markers.provider.MarkableProvider;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class MarkableExtensionTest {
|
||||
|
||||
|
|
@ -42,18 +43,18 @@ public class MarkableExtensionTest {
|
|||
message.setStanzaId("message-1");
|
||||
message.setBody("My lord, dispatch; read o'er these articles.");
|
||||
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
|
||||
Assert.assertEquals(markableMessageStanza, message.toXML().toString());
|
||||
assertEquals(markableMessageStanza, message.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkMarkableProvider() throws Exception {
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(markableExtension);
|
||||
MarkableExtension markableExtension1 = new MarkableProvider().parse(parser);
|
||||
Assert.assertEquals(markableExtension, markableExtension1.toXML().toString());
|
||||
assertEquals(markableExtension, markableExtension1.toXML().toString());
|
||||
|
||||
Message message = PacketParserUtils.parseStanza(markableMessageStanza);
|
||||
MarkableExtension markableExtension2 = MarkableExtension.from(message);
|
||||
Assert.assertEquals(markableExtension, markableExtension2.toXML().toString());
|
||||
assertEquals(markableExtension, markableExtension2.toXML().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,19 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.chat_markers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements.ReceivedExtension;
|
||||
import org.jivesoftware.smackx.chat_markers.provider.ReceivedProvider;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class ReceivedExtensionTest {
|
||||
|
||||
|
|
@ -41,18 +42,18 @@ public class ReceivedExtensionTest {
|
|||
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
||||
message.setStanzaId("message-2");
|
||||
message.addExtension(new ChatMarkersElements.ReceivedExtension("message-1"));
|
||||
Assert.assertEquals(receivedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(receivedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkReceivedProvider() throws Exception {
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(receivedExtension);
|
||||
ReceivedExtension receivedExtension1 = new ReceivedProvider().parse(parser);
|
||||
Assert.assertEquals("message-1", receivedExtension1.getId());
|
||||
assertEquals("message-1", receivedExtension1.getId());
|
||||
|
||||
Message message = PacketParserUtils.parseStanza(receivedMessageStanza);
|
||||
ReceivedExtension receivedExtension2 = ReceivedExtension.from(message);
|
||||
Assert.assertEquals("message-1", receivedExtension2.getId());
|
||||
assertEquals("message-1", receivedExtension2.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.jivesoftware.smack.test.util.SmackTestSuite;
|
|||
|
||||
import org.jivesoftware.smackx.colors.ConsistentColor.Deficiency;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ConsistentColorsTest extends SmackTestSuite {
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ import java.util.List;
|
|||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
import org.jivesoftware.smackx.eme.element.ExplicitMessageEncryptionElement;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExplicitMessageEncryptionElementTest extends SmackTestSuite {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus
|
||||
* Copyright 2017-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.
|
||||
|
|
@ -16,14 +16,19 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.eme.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.eme.element.ExplicitMessageEncryptionElement;
|
||||
import org.jivesoftware.smackx.eme.element.ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
public class ExplicitMessageEncryptionProviderTest {
|
||||
|
||||
|
|
@ -34,15 +39,19 @@ public class ExplicitMessageEncryptionProviderTest {
|
|||
private static final String UNKNOWN_EME_ELEMENT = "<encryption xmlns='urn:xmpp:eme:0' namespace='" + UNKNOWN_NAMESPACE
|
||||
+ "' name='" + UNKNOWN_NAME + "'/>";
|
||||
|
||||
@Test
|
||||
public void testParseOxEmeElement() throws Exception {
|
||||
ExplicitMessageEncryptionElement eme = TestUtils.parseExtensionElement(OX_EME_ELEMENT);
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void testParseOxEmeElement(SmackTestUtil.XmlPullParserKind parserKind)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
ExplicitMessageEncryptionElement eme = SmackTestUtil.parse(OX_EME_ELEMENT, ExplicitMessageEncryptionProvider.class, parserKind);
|
||||
assertEquals(ExplicitMessageEncryptionProtocol.openpgpV0, eme.getProtocol());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseUnknownEmeElement() throws Exception {
|
||||
ExplicitMessageEncryptionElement eme = TestUtils.parseExtensionElement(UNKNOWN_EME_ELEMENT);
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void testParseUnknownEmeElement(SmackTestUtil.XmlPullParserKind parserKind)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
ExplicitMessageEncryptionElement eme = SmackTestUtil.parse(UNKNOWN_EME_ELEMENT, ExplicitMessageEncryptionProvider.class, parserKind);
|
||||
assertEquals(UNKNOWN_NAMESPACE, eme.getEncryptionNamespace());
|
||||
assertEquals(UNKNOWN_NAME, eme.getName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.SHA_256;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
|
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test toXML and parse of HashElement and HashElementProvider.
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test HashManager functionality.
|
||||
|
|
|
|||
|
|
@ -16,15 +16,20 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.hoxt.packet.AbstractHttpOverXmpp;
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppReq;
|
||||
|
|
@ -32,8 +37,9 @@ import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp;
|
|||
import org.jivesoftware.smackx.shim.packet.Header;
|
||||
import org.jivesoftware.smackx.shim.packet.HeadersExtension;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
/**
|
||||
* Tests correct headers and data parsing in 'req' and 'resp' elements.
|
||||
|
|
@ -84,8 +90,10 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
checkHeaders(body.getHeaders(), expectedHeaders);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isTextDataParsedCorrectly() throws Exception {
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void isTextDataParsedCorrectly(SmackTestUtil.XmlPullParserKind parserKind)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String expectedText = "@prefix dc: <http://purl.org/dc/elements/1.1/>."
|
||||
+ "@base <http://clayster.com/>."
|
||||
+ "<xep> dc:title \"HTTP over XMPP\";"
|
||||
|
|
@ -103,12 +111,14 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
+ "</text></data></resp>";
|
||||
|
||||
AbstractHttpOverXmpp.Text text = (AbstractHttpOverXmpp.Text) parseAbstractBody(
|
||||
string, "resp").getData().getChild();
|
||||
string, "resp", parserKind).getData().getChild();
|
||||
assertEquals(expectedText, text.getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isXmlDataParsedCorrectly() throws Exception {
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void isXmlDataParsedCorrectly(SmackTestUtil.XmlPullParserKind parserKind)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String expectedXml = "<sparql><head><variable name=\"title\"/><variable name=\"creator\"/>" // no xmlns here
|
||||
+ "</head><results><result>"
|
||||
+ "<binding name=\"title\">"
|
||||
|
|
@ -137,12 +147,14 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
+ encodedXml
|
||||
+ "</xml></data></resp>";
|
||||
AbstractHttpOverXmpp.Xml xmlProviderValue = (AbstractHttpOverXmpp.Xml) parseAbstractBody(
|
||||
string, "resp").getData().getChild();
|
||||
string, "resp", parserKind).getData().getChild();
|
||||
assertEquals(expectedXml, xmlProviderValue.getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isBase64DataParsedCorrectly() throws Exception {
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void isBase64DataParsedCorrectly(SmackTestUtil.XmlPullParserKind parserKind)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String base64Data = "iVBORw0KGgoAAAANSUhEUgAAASwAAAGQCAYAAAAUdV17AAAAAXNSR0 ... tVWJd+e+y1AAAAABJRU5ErkJggg==";
|
||||
String string = "<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>"
|
||||
+ "<headers xmlns='http://jabber.org/protocol/shim'><header name='Server'>Clayster</header></headers>"
|
||||
|
|
@ -150,12 +162,14 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
+ base64Data
|
||||
+ "</base64></data></resp>";
|
||||
AbstractHttpOverXmpp.Base64 base64ProviderValue = (AbstractHttpOverXmpp.Base64) parseAbstractBody(
|
||||
string, "resp").getData().getChild();
|
||||
string, "resp", parserKind).getData().getChild();
|
||||
assertEquals(base64Data, base64ProviderValue.getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChunkedBase64DataParsedCorrectly() throws Exception {
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void isChunkedBase64DataParsedCorrectly(SmackTestUtil.XmlPullParserKind parserKind)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String streamId = "Stream0001";
|
||||
String chunkBase64Data = " <chunkedBase64 streamId='" + streamId + "'/>";
|
||||
String string = "<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>"
|
||||
|
|
@ -164,12 +178,14 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
+ chunkBase64Data
|
||||
+ "</data></resp>";
|
||||
AbstractHttpOverXmpp.ChunkedBase64 chunkedBase64Value = (AbstractHttpOverXmpp.ChunkedBase64) parseAbstractBody(
|
||||
string, "resp").getData().getChild();
|
||||
string, "resp", parserKind).getData().getChild();
|
||||
assertEquals(streamId, chunkedBase64Value.getStreamId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isIbbDataParsedCorrectly() throws Exception {
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void isIbbDataParsedCorrectly(SmackTestUtil.XmlPullParserKind parserKind)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String sid = "Stream0002";
|
||||
String ibbData = " <ibb sid='" + sid + "'/>";
|
||||
String string = "<resp xmlns='urn:xmpp:http' version='1.1' statusCode='200' statusMessage='OK'>"
|
||||
|
|
@ -178,14 +194,16 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
+ ibbData
|
||||
+ "</data></resp>";
|
||||
AbstractHttpOverXmpp.Ibb ibbValue = (AbstractHttpOverXmpp.Ibb) parseAbstractBody(
|
||||
string, "resp").getData().getChild();
|
||||
string, "resp", parserKind).getData().getChild();
|
||||
assertEquals(sid, ibbValue.getSid());
|
||||
}
|
||||
|
||||
// TODO The method name makes no sense after the HOXT re-design, change to parseHttpOverXmppResp()
|
||||
private static HttpOverXmppResp parseAbstractBody(String string, String tag) throws Exception {
|
||||
private static HttpOverXmppResp parseAbstractBody(String string, String tag,
|
||||
SmackTestUtil.XmlPullParserKind parserKind)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider();
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(string, tag);
|
||||
XmlPullParser parser = SmackTestUtil.getParserFor(string, tag, parserKind);
|
||||
|
||||
IQ iq = provider.parse(parser);
|
||||
assertTrue(iq instanceof HttpOverXmppResp);
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.hoxt.packet.Base64BinaryChunk;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests correct parsing of 'chunk' elements in Message stanza.
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpMethod;
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppReq;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HttpOverXmppReqProviderTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests correct attribute parsing in 'resp' element.
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.httpfileupload;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class FileTooLargeErrorCreateTest {
|
||||
private static final String fileTooLargeErrorExtensionExample
|
||||
|
|
@ -31,8 +32,8 @@ public class FileTooLargeErrorCreateTest {
|
|||
public void checkFileTooLargeErrorExtensionCreation() {
|
||||
FileTooLargeError fileTooLargeError = new FileTooLargeError(20000);
|
||||
|
||||
Assert.assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
Assert.assertEquals(fileTooLargeErrorExtensionExample, fileTooLargeError.toXML().toString());
|
||||
assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
assertEquals(fileTooLargeErrorExtensionExample, fileTooLargeError.toXML().toString());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
package org.jivesoftware.smackx.httpfileupload;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.Slot;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class SlotCreateTest {
|
||||
|
|
@ -39,9 +39,9 @@ public class SlotCreateTest {
|
|||
Slot slot = new Slot(new URL("https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
new URL("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"));
|
||||
|
||||
Assert.assertEquals(new URL("https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
assertEquals(new URL("https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
slot.getPutUrl());
|
||||
Assert.assertEquals(new URL("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
assertEquals(new URL("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
slot.getGetUrl());
|
||||
|
||||
assertXMLEqual(testSlot, slot.getChildElementXML().toString());
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@
|
|||
package org.jivesoftware.smackx.httpfileupload;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.SlotRequest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
|
@ -46,9 +47,9 @@ public class SlotRequestCreateTest {
|
|||
public void checkSlotRequestCreation() throws SAXException, IOException {
|
||||
SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 23456, "image/jpeg");
|
||||
|
||||
Assert.assertEquals("my_juliet.png", slotRequest.getFilename());
|
||||
Assert.assertEquals(23456, slotRequest.getSize());
|
||||
Assert.assertEquals("image/jpeg", slotRequest.getContentType());
|
||||
assertEquals("my_juliet.png", slotRequest.getFilename());
|
||||
assertEquals(23456, slotRequest.getSize());
|
||||
assertEquals("image/jpeg", slotRequest.getContentType());
|
||||
|
||||
assertXMLEqual(testRequest, slotRequest.getChildElementXML().toString());
|
||||
}
|
||||
|
|
@ -57,20 +58,22 @@ public class SlotRequestCreateTest {
|
|||
public void checkSlotRequestCreationWithoutContentType() throws SAXException, IOException {
|
||||
SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_romeo.png", 52523);
|
||||
|
||||
Assert.assertEquals("my_romeo.png", slotRequest.getFilename());
|
||||
Assert.assertEquals(52523, slotRequest.getSize());
|
||||
Assert.assertEquals(null, slotRequest.getContentType());
|
||||
assertEquals("my_romeo.png", slotRequest.getFilename());
|
||||
assertEquals(52523, slotRequest.getSize());
|
||||
assertEquals(null, slotRequest.getContentType());
|
||||
|
||||
assertXMLEqual(testRequestWithoutContentType, slotRequest.getChildElementXML().toString());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void checkSlotRequestCreationNegativeSize() {
|
||||
new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", -23456, "image/jpeg");
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", -23456, "image/jpeg"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void checkSlotRequestCreationZeroSize() {
|
||||
new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 0, "image/jpeg");
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 0, "image/jpeg"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.httpfileupload.provider;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class FileTooLargeErrorProviderTest {
|
||||
|
||||
|
|
@ -52,9 +53,9 @@ public class FileTooLargeErrorProviderTest {
|
|||
public void checkSlotErrorFileToLarge() throws Exception {
|
||||
IQ fileTooLargeErrorIQ = PacketParserUtils.parseStanza(slotErrorFileToLarge);
|
||||
|
||||
Assert.assertEquals(IQ.Type.error, fileTooLargeErrorIQ.getType());
|
||||
assertEquals(IQ.Type.error, fileTooLargeErrorIQ.getType());
|
||||
|
||||
FileTooLargeError fileTooLargeError = FileTooLargeError.from(fileTooLargeErrorIQ);
|
||||
Assert.assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.httpfileupload.provider;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
|
@ -28,7 +28,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.httpfileupload.element.Slot;
|
||||
import org.jivesoftware.smackx.httpfileupload.element.Slot_V0_2;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class SlotProviderTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smackx.mam.MamManager.MamQueryArgs;
|
|||
import org.jivesoftware.smackx.mam.element.MamElements;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
|
|
|||
|
|
@ -16,17 +16,21 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.mam.element.MamFinIQ;
|
||||
import org.jivesoftware.smackx.mam.provider.MamFinIQProvider;
|
||||
import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MamFinProviderTest extends MamTest {
|
||||
|
||||
|
|
@ -39,13 +43,13 @@ public class MamFinProviderTest extends MamTest {
|
|||
XmlPullParser parser = PacketParserUtils.getParserFor(exmapleMamFinXml);
|
||||
MamFinIQ mamFinIQ = new MamFinIQProvider().parse(parser);
|
||||
|
||||
Assert.assertFalse(mamFinIQ.isComplete());
|
||||
Assert.assertTrue(mamFinIQ.isStable());
|
||||
Assert.assertNull(mamFinIQ.getQueryId());
|
||||
assertFalse(mamFinIQ.isComplete());
|
||||
assertTrue(mamFinIQ.isStable());
|
||||
assertNull(mamFinIQ.getQueryId());
|
||||
|
||||
RSMSet rsmSet = mamFinIQ.getRSMSet();
|
||||
Assert.assertEquals(rsmSet.getAfter(), "09af3-cc343-b409f");
|
||||
Assert.assertEquals(rsmSet.getMax(), 10);
|
||||
assertEquals(rsmSet.getAfter(), "09af3-cc343-b409f");
|
||||
assertEquals(rsmSet.getMax(), 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -64,13 +68,13 @@ public class MamFinProviderTest extends MamTest {
|
|||
IQ iq = PacketParserUtils.parseStanza(IQ_LIMITED_RESULTS_EXAMPLE);
|
||||
|
||||
MamFinIQ mamFinIQ = (MamFinIQ) iq;
|
||||
Assert.assertEquals(mamFinIQ.getType(), Type.result);
|
||||
assertEquals(mamFinIQ.getType(), Type.result);
|
||||
|
||||
Assert.assertTrue(mamFinIQ.isComplete());
|
||||
Assert.assertEquals(mamFinIQ.getRSMSet().getCount(), 16);
|
||||
Assert.assertEquals(mamFinIQ.getRSMSet().getFirst(), "23452-4534-1");
|
||||
Assert.assertEquals(mamFinIQ.getRSMSet().getFirstIndex(), 0);
|
||||
Assert.assertEquals(mamFinIQ.getRSMSet().getLast(), "390-2342-22");
|
||||
assertTrue(mamFinIQ.isComplete());
|
||||
assertEquals(mamFinIQ.getRSMSet().getCount(), 16);
|
||||
assertEquals(mamFinIQ.getRSMSet().getFirst(), "23452-4534-1");
|
||||
assertEquals(mamFinIQ.getRSMSet().getFirstIndex(), 0);
|
||||
assertEquals(mamFinIQ.getRSMSet().getLast(), "390-2342-22");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,20 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.mam.element.MamPrefsIQ;
|
||||
import org.jivesoftware.smackx.mam.provider.MamPrefsIQProvider;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class MamPrefIQProviderTest extends MamTest {
|
||||
|
||||
|
|
@ -52,20 +54,20 @@ public class MamPrefIQProviderTest extends MamTest {
|
|||
XmlPullParser parser1 = PacketParserUtils.getParserFor(exampleMamPrefsIQ1);
|
||||
MamPrefsIQ mamPrefIQ1 = new MamPrefsIQProvider().parse(parser1);
|
||||
|
||||
Assert.assertEquals(IQ.Type.set, mamPrefIQ1.getType());
|
||||
Assert.assertEquals(mamPrefIQ1.getAlwaysJids().get(0).toString(), "romeo@montague.lit");
|
||||
Assert.assertEquals(mamPrefIQ1.getNeverJids().get(0).toString(), "montague@montague.lit");
|
||||
assertEquals(IQ.Type.set, mamPrefIQ1.getType());
|
||||
assertEquals(mamPrefIQ1.getAlwaysJids().get(0).toString(), "romeo@montague.lit");
|
||||
assertEquals(mamPrefIQ1.getNeverJids().get(0).toString(), "montague@montague.lit");
|
||||
|
||||
XmlPullParser parser2 = PacketParserUtils.getParserFor(exampleMamPrefsIQ2);
|
||||
MamPrefsIQ mamPrefIQ2 = new MamPrefsIQProvider().parse(parser2);
|
||||
Assert.assertEquals(IQ.Type.set, mamPrefIQ2.getType());
|
||||
Assert.assertEquals(mamPrefIQ2.getAlwaysJids().get(0).toString(), "romeo@montague.lit");
|
||||
Assert.assertEquals(mamPrefIQ2.getAlwaysJids().get(1).toString(), "montague@montague.lit");
|
||||
Assert.assertTrue(mamPrefIQ2.getNeverJids().isEmpty());
|
||||
assertEquals(IQ.Type.set, mamPrefIQ2.getType());
|
||||
assertEquals(mamPrefIQ2.getAlwaysJids().get(0).toString(), "romeo@montague.lit");
|
||||
assertEquals(mamPrefIQ2.getAlwaysJids().get(1).toString(), "montague@montague.lit");
|
||||
assertTrue(mamPrefIQ2.getNeverJids().isEmpty());
|
||||
|
||||
XmlPullParser parser3 = PacketParserUtils.getParserFor(exampleMamPrefsIQ3);
|
||||
MamPrefsIQ mamPrefIQ3 = new MamPrefsIQProvider().parse(parser3);
|
||||
Assert.assertEquals(IQ.Type.set, mamPrefIQ3.getType());
|
||||
assertEquals(IQ.Type.set, mamPrefIQ3.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -77,10 +79,10 @@ public class MamPrefIQProviderTest extends MamTest {
|
|||
List<Jid> alwaysJids = mamPrefsIQ.getAlwaysJids();
|
||||
List<Jid> neverJids = mamPrefsIQ.getNeverJids();
|
||||
|
||||
Assert.assertEquals(alwaysJids.size(), 1);
|
||||
Assert.assertEquals(neverJids.size(), 2);
|
||||
Assert.assertEquals(alwaysJids.get(0).toString(), "romeo@montague.lit");
|
||||
Assert.assertEquals(neverJids.get(1).toString(), "montague@montague.lit");
|
||||
assertEquals(alwaysJids.size(), 1);
|
||||
assertEquals(neverJids.size(), 2);
|
||||
assertEquals(alwaysJids.get(0).toString(), "romeo@montague.lit");
|
||||
assertEquals(neverJids.get(1).toString(), "montague@montague.lit");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -27,8 +31,7 @@ import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
|||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MamQueryIQProviderTest {
|
||||
|
||||
|
|
@ -54,35 +57,35 @@ public class MamQueryIQProviderTest {
|
|||
IQ iq1 = PacketParserUtils.parseStanza(exampleMamQueryIQ1);
|
||||
MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1;
|
||||
|
||||
Assert.assertEquals(mamQueryIQ1.getType(), Type.set);
|
||||
Assert.assertEquals(mamQueryIQ1.getQueryId(), "test");
|
||||
assertEquals(mamQueryIQ1.getType(), Type.set);
|
||||
assertEquals(mamQueryIQ1.getQueryId(), "test");
|
||||
|
||||
DataForm dataForm1 = (DataForm) mamQueryIQ1.getExtension(DataForm.NAMESPACE);
|
||||
Assert.assertEquals(dataForm1.getType(), DataForm.Type.submit);
|
||||
assertEquals(dataForm1.getType(), DataForm.Type.submit);
|
||||
|
||||
List<FormField> fields1 = dataForm1.getFields();
|
||||
Assert.assertEquals(fields1.get(0).getType(), FormField.Type.hidden);
|
||||
Assert.assertEquals(fields1.get(1).getType(), FormField.Type.text_single);
|
||||
Assert.assertEquals(fields1.get(1).getValues().get(0).toString(), "Where arth thou, my Juliet?");
|
||||
Assert.assertEquals(fields1.get(2).getValues().get(0).toString(), "{http://jabber.org/protocol/mood}mood/lonely");
|
||||
assertEquals(fields1.get(0).getType(), FormField.Type.hidden);
|
||||
assertEquals(fields1.get(1).getType(), FormField.Type.text_single);
|
||||
assertEquals(fields1.get(1).getValues().get(0).toString(), "Where arth thou, my Juliet?");
|
||||
assertEquals(fields1.get(2).getValues().get(0).toString(), "{http://jabber.org/protocol/mood}mood/lonely");
|
||||
|
||||
// example2
|
||||
IQ iq2 = PacketParserUtils.parseStanza(exampleMamQueryIQ2);
|
||||
MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2;
|
||||
|
||||
Assert.assertEquals(mamQueryIQ2.getType(), Type.result);
|
||||
Assert.assertNull(mamQueryIQ2.getQueryId());
|
||||
assertEquals(mamQueryIQ2.getType(), Type.result);
|
||||
assertNull(mamQueryIQ2.getQueryId());
|
||||
|
||||
DataForm dataForm2 = (DataForm) mamQueryIQ2.getExtension(DataForm.NAMESPACE);
|
||||
Assert.assertEquals(dataForm2.getType(), DataForm.Type.form);
|
||||
assertEquals(dataForm2.getType(), DataForm.Type.form);
|
||||
|
||||
List<FormField> fields2 = dataForm2.getFields();
|
||||
Assert.assertEquals(fields2.get(0).getValues().get(0).toString(), "urn:xmpp:mam:1");
|
||||
Assert.assertTrue(fields2.get(0).getValues().size() == 1);
|
||||
Assert.assertEquals(fields2.get(1).getType(), FormField.Type.jid_single);
|
||||
Assert.assertEquals(fields2.get(2).getType(), FormField.Type.text_single);
|
||||
Assert.assertEquals(fields2.get(2).getValues(), new ArrayList<>());
|
||||
Assert.assertEquals(fields2.get(4).getVariable(), "urn:example:xmpp:free-text-search");
|
||||
assertEquals(fields2.get(0).getValues().get(0).toString(), "urn:xmpp:mam:1");
|
||||
assertTrue(fields2.get(0).getValues().size() == 1);
|
||||
assertEquals(fields2.get(1).getType(), FormField.Type.jid_single);
|
||||
assertEquals(fields2.get(2).getType(), FormField.Type.text_single);
|
||||
assertEquals(fields2.get(2).getValues(), new ArrayList<>());
|
||||
assertEquals(fields2.get(4).getVariable(), "urn:example:xmpp:free-text-search");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,20 +16,21 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension;
|
||||
import org.jivesoftware.smackx.mam.provider.MamResultProvider;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MamResultProviderTest {
|
||||
|
||||
|
|
@ -51,20 +52,20 @@ public class MamResultProviderTest {
|
|||
XmlPullParser parser = PacketParserUtils.getParserFor(exampleMamResultXml);
|
||||
MamResultExtension mamResultExtension = new MamResultProvider().parse(parser);
|
||||
|
||||
Assert.assertEquals(mamResultExtension.getQueryId(), "f27");
|
||||
Assert.assertEquals(mamResultExtension.getId(), "28482-98726-73623");
|
||||
assertEquals(mamResultExtension.getQueryId(), "f27");
|
||||
assertEquals(mamResultExtension.getId(), "28482-98726-73623");
|
||||
|
||||
GregorianCalendar calendar = new GregorianCalendar(2010, 7 - 1, 10, 23, 8, 25);
|
||||
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
Date date = calendar.getTime();
|
||||
|
||||
Forwarded forwarded = mamResultExtension.getForwarded();
|
||||
Assert.assertEquals(forwarded.getDelayInformation().getStamp(), date);
|
||||
assertEquals(forwarded.getDelayInformation().getStamp(), date);
|
||||
|
||||
Message message = (Message) forwarded.getForwardedStanza();
|
||||
Assert.assertEquals(message.getFrom().toString(), "romeo@montague.lit/orchard");
|
||||
Assert.assertEquals(message.getTo().toString(), "juliet@capulet.lit/balcony");
|
||||
Assert.assertEquals(message.getBody(),
|
||||
assertEquals(message.getFrom().toString(), "romeo@montague.lit/orchard");
|
||||
assertEquals(message.getTo().toString(), "juliet@capulet.lit/balcony");
|
||||
assertEquals(message.getBody(),
|
||||
"Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
|
||||
}
|
||||
|
||||
|
|
@ -73,20 +74,20 @@ public class MamResultProviderTest {
|
|||
Message message = PacketParserUtils.parseStanza(exampleResultMessage);
|
||||
MamResultExtension mamResultExtension = MamResultExtension.from(message);
|
||||
|
||||
Assert.assertEquals(mamResultExtension.getQueryId(), "f27");
|
||||
Assert.assertEquals(mamResultExtension.getId(), "28482-98726-73623");
|
||||
assertEquals(mamResultExtension.getQueryId(), "f27");
|
||||
assertEquals(mamResultExtension.getId(), "28482-98726-73623");
|
||||
|
||||
GregorianCalendar calendar = new GregorianCalendar(2010, 7 - 1, 10, 23, 8, 25);
|
||||
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
Date date = calendar.getTime();
|
||||
|
||||
Forwarded forwarded = mamResultExtension.getForwarded();
|
||||
Assert.assertEquals(forwarded.getDelayInformation().getStamp(), date);
|
||||
assertEquals(forwarded.getDelayInformation().getStamp(), date);
|
||||
|
||||
Message forwardedMessage = (Message) forwarded.getForwardedStanza();
|
||||
Assert.assertEquals(forwardedMessage.getFrom().toString(), "witch@shakespeare.lit");
|
||||
Assert.assertEquals(forwardedMessage.getTo().toString(), "macbeth@shakespeare.lit");
|
||||
Assert.assertEquals(forwardedMessage.getBody(), "Hail to thee");
|
||||
assertEquals(forwardedMessage.getFrom().toString(), "witch@shakespeare.lit");
|
||||
assertEquals(forwardedMessage.getTo().toString(), "macbeth@shakespeare.lit");
|
||||
assertEquals(forwardedMessage.getBody(), "Hail to thee");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@ import org.jivesoftware.smack.XMPPConnection;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
public class MamTest extends InitExtensions {
|
||||
|
||||
protected XMPPConnection connection;
|
||||
protected String queryId;
|
||||
protected MamManager mamManager;
|
||||
protected static XMPPConnection connection;
|
||||
protected static String queryId;
|
||||
protected static MamManager mamManager;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
// mock connection
|
||||
connection = new DummyConnection();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
|
|
@ -23,8 +25,7 @@ import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
|||
import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class PagingTest extends MamTest {
|
||||
|
||||
|
|
@ -44,9 +45,9 @@ public class PagingTest extends MamTest {
|
|||
mamQueryIQ.setType(IQ.Type.set);
|
||||
mamQueryIQ.addExtension(rsmSet);
|
||||
|
||||
Assert.assertEquals(mamQueryIQ.getDataForm(), dataForm);
|
||||
Assert.assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0).toString(), "urn:xmpp:mam:1");
|
||||
Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), pagingStanza);
|
||||
assertEquals(mamQueryIQ.getDataForm(), dataForm);
|
||||
assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0).toString(), "urn:xmpp:mam:1");
|
||||
assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), pagingStanza);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -25,8 +27,7 @@ import org.jivesoftware.smackx.mam.element.MamElements;
|
|||
import org.jivesoftware.smackx.mam.element.MamPrefsIQ;
|
||||
import org.jivesoftware.smackx.mam.element.MamPrefsIQ.DefaultBehavior;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
@ -43,7 +44,7 @@ public class PreferencesTest {
|
|||
public void checkRetrievePrefsStanza() throws Exception {
|
||||
MamPrefsIQ mamPrefIQ = new MamPrefsIQ();
|
||||
mamPrefIQ.setStanzaId("sarasa");
|
||||
Assert.assertEquals(mamPrefIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), retrievePrefsStanzaExample);
|
||||
assertEquals(mamPrefIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), retrievePrefsStanzaExample);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -57,7 +58,7 @@ public class PreferencesTest {
|
|||
|
||||
MamPrefsIQ mamPrefIQ = new MamPrefsIQ(alwaysJids, neverJids, DefaultBehavior.roster);
|
||||
mamPrefIQ.setStanzaId("sarasa");
|
||||
Assert.assertEquals(mamPrefIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), updatePrefsStanzaExample);
|
||||
assertEquals(mamPrefIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), updatePrefsStanzaExample);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
|
@ -32,8 +34,7 @@ import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension;
|
|||
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class QueryArchiveTest extends MamTest {
|
||||
|
|
@ -56,7 +57,7 @@ public class QueryArchiveTest extends MamTest {
|
|||
MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, dataForm);
|
||||
mamQueryIQ.setType(IQ.Type.set);
|
||||
mamQueryIQ.setStanzaId("sarasa");
|
||||
Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamSimpleQueryIQ);
|
||||
assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamSimpleQueryIQ);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -82,18 +83,18 @@ public class QueryArchiveTest extends MamTest {
|
|||
message.addExtension(new MamResultExtension("g27", "34482-21985-73620", forwarded));
|
||||
|
||||
// FIXME: The order of assertEquals is reversed, fix it by switching it.
|
||||
Assert.assertEquals(message.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamQueryResultExample);
|
||||
assertEquals(message.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamQueryResultExample);
|
||||
|
||||
MamResultExtension mamResultExtension = MamResultExtension.from(message);
|
||||
|
||||
Assert.assertEquals(mamResultExtension.getId(), "34482-21985-73620");
|
||||
Assert.assertEquals(mamResultExtension.getForwarded().getDelayInformation().getStamp(), date);
|
||||
assertEquals(mamResultExtension.getId(), "34482-21985-73620");
|
||||
assertEquals(mamResultExtension.getForwarded().getDelayInformation().getStamp(), date);
|
||||
|
||||
Message resultMessage = (Message) mamResultExtension.getForwarded().getForwardedStanza();
|
||||
Assert.assertEquals(resultMessage.getFrom(), JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
|
||||
Assert.assertEquals(resultMessage.getStanzaId(), "162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
|
||||
Assert.assertEquals(resultMessage.getType(), Type.chat);
|
||||
Assert.assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew.");
|
||||
assertEquals(resultMessage.getFrom(), JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
|
||||
assertEquals(resultMessage.getStanzaId(), "162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
|
||||
assertEquals(resultMessage.getType(), Type.chat);
|
||||
assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2016 Fernando Ramirez, 2018 Florian Schmaus
|
||||
* Copyright 2016 Fernando Ramirez, 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.
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
|
|
@ -24,8 +26,7 @@ import org.jivesoftware.smackx.mam.element.MamElements;
|
|||
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ResultsLimitTest extends MamTest {
|
||||
|
||||
|
|
@ -36,7 +37,6 @@ public class ResultsLimitTest extends MamTest {
|
|||
|
||||
@Test
|
||||
public void checkResultsLimit() throws Exception {
|
||||
|
||||
DataForm dataForm = getNewMamForm();
|
||||
MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, dataForm);
|
||||
mamQueryIQ.setType(IQ.Type.set);
|
||||
|
|
@ -44,7 +44,7 @@ public class ResultsLimitTest extends MamTest {
|
|||
|
||||
MamQueryArgs mamQueryArgs = MamQueryArgs.builder().setResultPageSize(10).build();
|
||||
mamQueryArgs.maybeAddRsmSet(mamQueryIQ);
|
||||
Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), resultsLimitStanza);
|
||||
assertEquals(resultsLimitStanza, mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.mam;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
|||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class RetrieveFormFieldsTest extends MamTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,14 @@ package org.jivesoftware.smackx.message_markup;
|
|||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.message_markup.element.BlockQuoteElement;
|
||||
import org.jivesoftware.smackx.message_markup.element.CodeBlockElement;
|
||||
import org.jivesoftware.smackx.message_markup.element.ListElement;
|
||||
|
|
@ -30,8 +33,7 @@ import org.jivesoftware.smackx.message_markup.element.MarkupElement;
|
|||
import org.jivesoftware.smackx.message_markup.element.SpanElement;
|
||||
import org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MessageMarkupTest extends SmackTestSuite {
|
||||
|
||||
|
|
@ -107,16 +109,18 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
assertEquals(SpanElement.SpanStyle.deleted, spanElement.getStyles().iterator().next());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void wrongStartEndTest() {
|
||||
MarkupElement.getBuilder().setEmphasis(12, 10);
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
MarkupElement.getBuilder().setEmphasis(12, 10));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void overlappingSpansTest() {
|
||||
MarkupElement.Builder m = MarkupElement.getBuilder();
|
||||
m.setEmphasis(0, 10);
|
||||
m.setDeleted(5, 15);
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
m.setDeleted(5, 15));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -172,10 +176,11 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
assertEquals(47, list.getEntries().get(1).getStart());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void listWrongSecondEntryTest() {
|
||||
MarkupElement.Builder m = MarkupElement.getBuilder();
|
||||
m.beginList().addEntry(0,1).addEntry(3,4);
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
m.beginList().addEntry(0,1).addEntry(3,4));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
|
@ -23,8 +25,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightElements.AffiliationsChangeExtension;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
@ -55,10 +56,10 @@ public class MUCLightAffiliationsChangeExtensionTest {
|
|||
.from(changeAffiliationsMessage);
|
||||
|
||||
HashMap<Jid, MUCLightAffiliation> affiliations = affiliationsChangeExtension.getAffiliations();
|
||||
Assert.assertEquals(affiliations.size(), 3);
|
||||
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
|
||||
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
|
||||
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
|
||||
assertEquals(affiliations.size(), 3);
|
||||
assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
|
||||
assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
|
||||
assertEquals(affiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -68,11 +69,11 @@ public class MUCLightAffiliationsChangeExtensionTest {
|
|||
.from(changeAffiliationsMessage);
|
||||
|
||||
HashMap<Jid, MUCLightAffiliation> affiliations = affiliationsChangeExtension.getAffiliations();
|
||||
Assert.assertEquals(affiliations.size(), 2);
|
||||
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
|
||||
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
|
||||
assertEquals(affiliations.size(), 2);
|
||||
assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
|
||||
assertEquals(affiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
|
||||
|
||||
Assert.assertEquals(affiliationsChangeExtension.getVersion(), "qwerty");
|
||||
assertEquals(affiliationsChangeExtension.getVersion(), "qwerty");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -83,12 +84,12 @@ public class MUCLightAffiliationsChangeExtensionTest {
|
|||
.from(changeAffiliationsMessage);
|
||||
|
||||
HashMap<Jid, MUCLightAffiliation> affiliations = affiliationsChangeExtension.getAffiliations();
|
||||
Assert.assertEquals(affiliations.size(), 2);
|
||||
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
|
||||
Assert.assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
|
||||
assertEquals(affiliations.size(), 2);
|
||||
assertEquals(affiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
|
||||
assertEquals(affiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
|
||||
|
||||
Assert.assertEquals(affiliationsChangeExtension.getPrevVersion(), "njiokm");
|
||||
Assert.assertEquals(affiliationsChangeExtension.getVersion(), "qwerty");
|
||||
assertEquals(affiliationsChangeExtension.getPrevVersion(), "njiokm");
|
||||
assertEquals(affiliationsChangeExtension.getVersion(), "qwerty");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
|
@ -25,8 +27,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ public class MUCLightBlockingTest {
|
|||
mucLightBlockingIQ.setStanzaId("getblock1");
|
||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||
|
||||
Assert.assertEquals(getBlockingListIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(getBlockingListIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -70,12 +71,12 @@ public class MUCLightBlockingTest {
|
|||
IQ iqInfoResult = PacketParserUtils.parseStanza(getBlockingListIQResponse);
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = (MUCLightBlockingIQ) iqInfoResult;
|
||||
|
||||
Assert.assertEquals(2, mucLightBlockingIQ.getRooms().size());
|
||||
Assert.assertEquals(1, mucLightBlockingIQ.getUsers().size());
|
||||
Assert.assertEquals(false, mucLightBlockingIQ.getRooms().get(JidCreate.from("coven@muclight.shakespeare.lit")));
|
||||
Assert.assertEquals(false,
|
||||
assertEquals(2, mucLightBlockingIQ.getRooms().size());
|
||||
assertEquals(1, mucLightBlockingIQ.getUsers().size());
|
||||
assertEquals(false, mucLightBlockingIQ.getRooms().get(JidCreate.from("coven@muclight.shakespeare.lit")));
|
||||
assertEquals(false,
|
||||
mucLightBlockingIQ.getRooms().get(JidCreate.from("sarasa@muclight.shakespeare.lit")));
|
||||
Assert.assertEquals(false, mucLightBlockingIQ.getUsers().get(JidCreate.from("hag77@shakespeare.lit")));
|
||||
assertEquals(false, mucLightBlockingIQ.getUsers().get(JidCreate.from("hag77@shakespeare.lit")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -89,7 +90,7 @@ public class MUCLightBlockingTest {
|
|||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||
mucLightBlockingIQ.setStanzaId("block1");
|
||||
|
||||
Assert.assertEquals(blockingRoomsIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(blockingRoomsIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -103,7 +104,7 @@ public class MUCLightBlockingTest {
|
|||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||
mucLightBlockingIQ.setStanzaId("block2");
|
||||
|
||||
Assert.assertEquals(blockingUsersIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(blockingUsersIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -119,7 +120,7 @@ public class MUCLightBlockingTest {
|
|||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||
mucLightBlockingIQ.setStanzaId("unblock1");
|
||||
|
||||
Assert.assertEquals(unblockingUsersAndRoomsExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(unblockingUsersAndRoomsExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,15 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightChangeAffiliationsIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
@ -46,13 +47,13 @@ public class MUCLightChangeAffiliationsIQTest {
|
|||
JidCreate.from("coven@muclight.shakespeare.lit"), affiliations);
|
||||
mucLightChangeAffiliationsIQ.setStanzaId("member1");
|
||||
|
||||
Assert.assertEquals(mucLightChangeAffiliationsIQ.getTo(), "coven@muclight.shakespeare.lit");
|
||||
Assert.assertEquals(mucLightChangeAffiliationsIQ.getType(), IQ.Type.set);
|
||||
assertEquals(mucLightChangeAffiliationsIQ.getTo(), "coven@muclight.shakespeare.lit");
|
||||
assertEquals(mucLightChangeAffiliationsIQ.getType(), IQ.Type.set);
|
||||
|
||||
HashMap<Jid, MUCLightAffiliation> iqAffiliations = mucLightChangeAffiliationsIQ.getAffiliations();
|
||||
Assert.assertEquals(iqAffiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
|
||||
Assert.assertEquals(iqAffiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
|
||||
Assert.assertEquals(iqAffiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
|
||||
assertEquals(iqAffiliations.get(JidCreate.from("sarasa1@shakespeare.lit")), MUCLightAffiliation.member);
|
||||
assertEquals(iqAffiliations.get(JidCreate.from("sarasa2@shakespeare.lit")), MUCLightAffiliation.owner);
|
||||
assertEquals(iqAffiliations.get(JidCreate.from("sarasa3@shakespeare.lit")), MUCLightAffiliation.none);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,15 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightElements.ConfigurationsChangeExtension;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MUCLightConfigurationsChangeExtensionTest {
|
||||
|
||||
|
|
@ -46,12 +48,12 @@ public class MUCLightConfigurationsChangeExtensionTest {
|
|||
ConfigurationsChangeExtension configurationsChangeExtension = ConfigurationsChangeExtension
|
||||
.from(configurationsMessage);
|
||||
|
||||
Assert.assertEquals("asdfghj000", configurationsChangeExtension.getPrevVersion());
|
||||
Assert.assertEquals("asdfghj", configurationsChangeExtension.getVersion());
|
||||
Assert.assertEquals("To be or not to be?", configurationsChangeExtension.getSubject());
|
||||
Assert.assertNull(configurationsChangeExtension.getRoomName());
|
||||
Assert.assertNull(configurationsChangeExtension.getCustomConfigs());
|
||||
Assert.assertEquals(messageWithSubjectChangeExample, configurationsMessage.toXML().toString());
|
||||
assertEquals("asdfghj000", configurationsChangeExtension.getPrevVersion());
|
||||
assertEquals("asdfghj", configurationsChangeExtension.getVersion());
|
||||
assertEquals("To be or not to be?", configurationsChangeExtension.getSubject());
|
||||
assertNull(configurationsChangeExtension.getRoomName());
|
||||
assertNull(configurationsChangeExtension.getCustomConfigs());
|
||||
assertEquals(messageWithSubjectChangeExample, configurationsMessage.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -60,12 +62,12 @@ public class MUCLightConfigurationsChangeExtensionTest {
|
|||
ConfigurationsChangeExtension configurationsChangeExtension = ConfigurationsChangeExtension
|
||||
.from(configurationsMessage);
|
||||
|
||||
Assert.assertEquals("zaqwsx", configurationsChangeExtension.getPrevVersion());
|
||||
Assert.assertEquals("zxcvbnm", configurationsChangeExtension.getVersion());
|
||||
Assert.assertEquals("A Darker Cave", configurationsChangeExtension.getRoomName());
|
||||
Assert.assertNull(configurationsChangeExtension.getSubject());
|
||||
Assert.assertNull(configurationsChangeExtension.getCustomConfigs());
|
||||
Assert.assertEquals(messageWithRoomNameChangeExample, configurationsMessage.toXML().toString());
|
||||
assertEquals("zaqwsx", configurationsChangeExtension.getPrevVersion());
|
||||
assertEquals("zxcvbnm", configurationsChangeExtension.getVersion());
|
||||
assertEquals("A Darker Cave", configurationsChangeExtension.getRoomName());
|
||||
assertNull(configurationsChangeExtension.getSubject());
|
||||
assertNull(configurationsChangeExtension.getCustomConfigs());
|
||||
assertEquals(messageWithRoomNameChangeExample, configurationsMessage.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -74,12 +76,12 @@ public class MUCLightConfigurationsChangeExtensionTest {
|
|||
ConfigurationsChangeExtension configurationsChangeExtension = ConfigurationsChangeExtension
|
||||
.from(configurationsMessage);
|
||||
|
||||
Assert.assertEquals("zaqwsx", configurationsChangeExtension.getPrevVersion());
|
||||
Assert.assertEquals("zxcvbnm", configurationsChangeExtension.getVersion());
|
||||
Assert.assertEquals("A Darker Cave", configurationsChangeExtension.getRoomName());
|
||||
Assert.assertNull(configurationsChangeExtension.getSubject());
|
||||
Assert.assertEquals("blue", configurationsChangeExtension.getCustomConfigs().get("color"));
|
||||
Assert.assertEquals(messageWithConfigsChangeExample, configurationsMessage.toXML().toString());
|
||||
assertEquals("zaqwsx", configurationsChangeExtension.getPrevVersion());
|
||||
assertEquals("zxcvbnm", configurationsChangeExtension.getVersion());
|
||||
assertEquals("A Darker Cave", configurationsChangeExtension.getRoomName());
|
||||
assertNull(configurationsChangeExtension.getSubject());
|
||||
assertEquals("blue", configurationsChangeExtension.getCustomConfigs().get("color"));
|
||||
assertEquals(messageWithConfigsChangeExample, configurationsMessage.toXML().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,15 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
@ -45,11 +46,11 @@ public class MUCLightCreateIQTest {
|
|||
"test", occupants);
|
||||
mucLightCreateIQ.setStanzaId("1c72W-50");
|
||||
|
||||
Assert.assertEquals(mucLightCreateIQ.getConfiguration().getRoomName(), "test");
|
||||
assertEquals(mucLightCreateIQ.getConfiguration().getRoomName(), "test");
|
||||
|
||||
HashMap<Jid, MUCLightAffiliation> iqOccupants = mucLightCreateIQ.getOccupants();
|
||||
Assert.assertEquals(iqOccupants.get(JidCreate.from("charlie@test.com")), MUCLightAffiliation.member);
|
||||
Assert.assertEquals(iqOccupants.get(JidCreate.from("pep@test.com")), MUCLightAffiliation.member);
|
||||
assertEquals(iqOccupants.get(JidCreate.from("charlie@test.com")), MUCLightAffiliation.member);
|
||||
assertEquals(iqOccupants.get(JidCreate.from("pep@test.com")), MUCLightAffiliation.member);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightDestroyIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class MUCLightDestroyTest {
|
||||
|
|
@ -33,7 +34,7 @@ public class MUCLightDestroyTest {
|
|||
public void checkDestroyMUCLightStanza() throws Exception {
|
||||
MUCLightDestroyIQ mucLightDestroyIQ = new MUCLightDestroyIQ(JidCreate.from("coven@muclight.shakespeare.lit"));
|
||||
mucLightDestroyIQ.setStanzaId("destroy1");
|
||||
Assert.assertEquals(mucLightDestroyIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), stanza);
|
||||
assertEquals(mucLightDestroyIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), stanza);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
|
@ -25,8 +27,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ;
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightGetAffiliationsIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ public class MUCLightGetAffiliationsTest {
|
|||
MUCLightGetAffiliationsIQ mucLightGetAffiliationsIQ = new MUCLightGetAffiliationsIQ(
|
||||
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
||||
mucLightGetAffiliationsIQ.setStanzaId("getmembers");
|
||||
Assert.assertEquals(getAffiliationsIQExample, mucLightGetAffiliationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(getAffiliationsIQExample, mucLightGetAffiliationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -54,13 +55,13 @@ public class MUCLightGetAffiliationsTest {
|
|||
IQ iqInfoResult = PacketParserUtils.parseStanza(getAffiliationsResponseExample);
|
||||
MUCLightAffiliationsIQ mucLightAffiliationsIQ = (MUCLightAffiliationsIQ) iqInfoResult;
|
||||
|
||||
Assert.assertEquals("123456", mucLightAffiliationsIQ.getVersion());
|
||||
assertEquals("123456", mucLightAffiliationsIQ.getVersion());
|
||||
|
||||
HashMap<Jid, MUCLightAffiliation> affiliations = mucLightAffiliationsIQ.getAffiliations();
|
||||
Assert.assertEquals(3, affiliations.size());
|
||||
Assert.assertEquals(MUCLightAffiliation.owner, affiliations.get(JidCreate.from("user1@shakespeare.lit")));
|
||||
Assert.assertEquals(MUCLightAffiliation.member, affiliations.get(JidCreate.from("user2@shakespeare.lit")));
|
||||
Assert.assertEquals(MUCLightAffiliation.member, affiliations.get(JidCreate.from("user3@shakespeare.lit")));
|
||||
assertEquals(3, affiliations.size());
|
||||
assertEquals(MUCLightAffiliation.owner, affiliations.get(JidCreate.from("user1@shakespeare.lit")));
|
||||
assertEquals(MUCLightAffiliation.member, affiliations.get(JidCreate.from("user2@shakespeare.lit")));
|
||||
assertEquals(MUCLightAffiliation.member, affiliations.get(JidCreate.from("user3@shakespeare.lit")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
|
@ -25,8 +28,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ;
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class MUCLightGetConfigsTest {
|
||||
|
|
@ -49,7 +51,7 @@ public class MUCLightGetConfigsTest {
|
|||
MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ(
|
||||
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
||||
mucLightGetConfigsIQ.setStanzaId("config0");
|
||||
Assert.assertEquals(getConfigsIQExample, mucLightGetConfigsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(getConfigsIQExample, mucLightGetConfigsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -57,10 +59,10 @@ public class MUCLightGetConfigsTest {
|
|||
IQ iqInfoResult = PacketParserUtils.parseStanza(getConfigsResponseExample);
|
||||
MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) iqInfoResult;
|
||||
|
||||
Assert.assertEquals("123456", mucLightConfigurationIQ.getVersion());
|
||||
Assert.assertEquals("A Dark Cave", mucLightConfigurationIQ.getConfiguration().getRoomName());
|
||||
Assert.assertEquals("A subject", mucLightConfigurationIQ.getConfiguration().getSubject());
|
||||
Assert.assertNull(mucLightConfigurationIQ.getConfiguration().getCustomConfigs());
|
||||
assertEquals("123456", mucLightConfigurationIQ.getVersion());
|
||||
assertEquals("A Dark Cave", mucLightConfigurationIQ.getConfiguration().getRoomName());
|
||||
assertEquals("A subject", mucLightConfigurationIQ.getConfiguration().getSubject());
|
||||
assertNull(mucLightConfigurationIQ.getConfiguration().getCustomConfigs());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -68,13 +70,13 @@ public class MUCLightGetConfigsTest {
|
|||
IQ iqInfoResult = PacketParserUtils.parseStanza(getConfigsResponseExampleWithCustomConfigs);
|
||||
MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) iqInfoResult;
|
||||
|
||||
Assert.assertEquals("123456", mucLightConfigurationIQ.getVersion());
|
||||
Assert.assertEquals("A Dark Cave", mucLightConfigurationIQ.getConfiguration().getRoomName());
|
||||
Assert.assertNull(mucLightConfigurationIQ.getConfiguration().getSubject());
|
||||
assertEquals("123456", mucLightConfigurationIQ.getVersion());
|
||||
assertEquals("A Dark Cave", mucLightConfigurationIQ.getConfiguration().getRoomName());
|
||||
assertNull(mucLightConfigurationIQ.getConfiguration().getSubject());
|
||||
|
||||
HashMap<String, String> customConfigs = mucLightConfigurationIQ.getConfiguration().getCustomConfigs();
|
||||
Assert.assertEquals("blue", customConfigs.get("color"));
|
||||
Assert.assertEquals("20", customConfigs.get("size"));
|
||||
assertEquals("blue", customConfigs.get("color"));
|
||||
assertEquals("20", customConfigs.get("size"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
|
@ -23,8 +25,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ;
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class MUCLightInfoTest {
|
||||
|
|
@ -46,7 +47,7 @@ public class MUCLightInfoTest {
|
|||
MUCLightGetInfoIQ mucLightGetInfoIQWithVersion = new MUCLightGetInfoIQ(
|
||||
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
||||
mucLightGetInfoIQWithVersion.setStanzaId("getinfo1");
|
||||
Assert.assertEquals(mucLightGetInfoIQWithVersion.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), exampleWithVersion);
|
||||
assertEquals(mucLightGetInfoIQWithVersion.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), exampleWithVersion);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -54,21 +55,21 @@ public class MUCLightInfoTest {
|
|||
MUCLightGetInfoIQ mucLightGetInfoIQWithoutVersion = new MUCLightGetInfoIQ(
|
||||
JidCreate.from("coven@muclight.shakespeare.lit"), null);
|
||||
mucLightGetInfoIQWithoutVersion.setStanzaId("getinfo1");
|
||||
Assert.assertEquals(mucLightGetInfoIQWithoutVersion.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), exampleWithoutVersion);
|
||||
assertEquals(mucLightGetInfoIQWithoutVersion.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), exampleWithoutVersion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkMUCLightInfoResult() throws Exception {
|
||||
IQ iqInfoResult = PacketParserUtils.parseStanza(exampleInfoResult);
|
||||
MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) iqInfoResult;
|
||||
Assert.assertEquals(mucLightInfoResponseIQ.getVersion(), "123456");
|
||||
Assert.assertEquals(mucLightInfoResponseIQ.getConfiguration().getRoomName(), "test");
|
||||
Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().size(), 3);
|
||||
Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("john@test.com")),
|
||||
assertEquals(mucLightInfoResponseIQ.getVersion(), "123456");
|
||||
assertEquals(mucLightInfoResponseIQ.getConfiguration().getRoomName(), "test");
|
||||
assertEquals(mucLightInfoResponseIQ.getOccupants().size(), 3);
|
||||
assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("john@test.com")),
|
||||
MUCLightAffiliation.owner);
|
||||
Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("charlie@test.com")),
|
||||
assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("charlie@test.com")),
|
||||
MUCLightAffiliation.member);
|
||||
Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("pep@test.com")),
|
||||
assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("pep@test.com")),
|
||||
MUCLightAffiliation.member);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,15 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muclight;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
import org.jivesoftware.smackx.muclight.element.MUCLightSetConfigsIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class MUCLightSetConfigsIQTest {
|
||||
|
|
@ -49,7 +50,7 @@ public class MUCLightSetConfigsIQTest {
|
|||
JidCreate.from("coven@muclight.shakespeare.lit"), "A Darker Cave", customConfigs);
|
||||
mucLightSetConfigsIQ.setStanzaId("conf1");
|
||||
|
||||
Assert.assertEquals(setConfigsIQExample, mucLightSetConfigsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(setConfigsIQExample, mucLightSetConfigsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -58,7 +59,7 @@ public class MUCLightSetConfigsIQTest {
|
|||
JidCreate.from("coven@muclight.shakespeare.lit"), "A Darker Cave", null);
|
||||
mucLightChangeRoomNameIQ.setStanzaId("roomName1");
|
||||
|
||||
Assert.assertEquals(changeRoomNameIQExample, mucLightChangeRoomNameIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(changeRoomNameIQExample, mucLightChangeRoomNameIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -67,7 +68,7 @@ public class MUCLightSetConfigsIQTest {
|
|||
JidCreate.from("coven@muclight.shakespeare.lit"), null, "To be or not to be?", null);
|
||||
mucLightChangeSubjectIQ.setStanzaId("subject1");
|
||||
|
||||
Assert.assertEquals(changeSubjectIQExample, mucLightChangeSubjectIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(changeSubjectIQExample, mucLightChangeSubjectIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.push_notifications;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
import org.jivesoftware.smackx.push_notifications.element.DisablePushNotificationsIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class DisablePushNotificationsIQTest {
|
||||
|
|
@ -38,7 +39,7 @@ public class DisablePushNotificationsIQTest {
|
|||
DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(
|
||||
JidCreate.from("push-5.client.example"));
|
||||
disablePushNotificationsIQ.setStanzaId("x97");
|
||||
Assert.assertEquals(disableAllNotificationsIQExample, disablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(disableAllNotificationsIQExample, disablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -46,7 +47,7 @@ public class DisablePushNotificationsIQTest {
|
|||
DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(
|
||||
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo");
|
||||
disablePushNotificationsIQ.setStanzaId("x97");
|
||||
Assert.assertEquals(disableNodeNotificationsIQExample, disablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(disableNodeNotificationsIQExample, disablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,15 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.push_notifications;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
import org.jivesoftware.smackx.push_notifications.element.EnablePushNotificationsIQ;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class EnablePushNotificationsIQTest {
|
||||
|
|
@ -43,7 +44,7 @@ public class EnablePushNotificationsIQTest {
|
|||
EnablePushNotificationsIQ enablePushNotificationsIQ = new EnablePushNotificationsIQ(
|
||||
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo");
|
||||
enablePushNotificationsIQ.setStanzaId("x42");
|
||||
Assert.assertEquals(exampleEnableIQ, enablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(exampleEnableIQ, enablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -55,7 +56,7 @@ public class EnablePushNotificationsIQTest {
|
|||
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo", publishOptions);
|
||||
enablePushNotificationsIQ.setStanzaId("x42");
|
||||
|
||||
Assert.assertEquals(exampleEnableIQWithPublishOptions, enablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertEquals(exampleEnableIQWithPublishOptions, enablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,15 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.push_notifications;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.push_notifications.element.PushNotificationsElements.RemoteDisablingExtension;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class RemoteDisablingPushNotificationsTest {
|
||||
|
|
@ -47,23 +49,23 @@ public class RemoteDisablingPushNotificationsTest {
|
|||
Message message = PacketParserUtils.parseStanza(remoteDisablingExample);
|
||||
RemoteDisablingExtension remoteDisablingExtension = RemoteDisablingExtension.from(message);
|
||||
|
||||
Assert.assertEquals("yxs32uqsflafdk3iuqo", remoteDisablingExtension.getNode());
|
||||
Assert.assertEquals(JidCreate.from("user@example.com"), remoteDisablingExtension.getUserJid());
|
||||
assertEquals("yxs32uqsflafdk3iuqo", remoteDisablingExtension.getNode());
|
||||
assertEquals(JidCreate.from("user@example.com"), remoteDisablingExtension.getUserJid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkWrongRemoteDisablighPushNotifications() throws Exception {
|
||||
Message message1 = PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
RemoteDisablingExtension remoteDisablingExtension1 = RemoteDisablingExtension.from(message1);
|
||||
Assert.assertNull(remoteDisablingExtension1);
|
||||
assertNull(remoteDisablingExtension1);
|
||||
|
||||
Message message2 = PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
RemoteDisablingExtension remoteDisablingExtension2 = RemoteDisablingExtension.from(message2);
|
||||
Assert.assertNull(remoteDisablingExtension2);
|
||||
assertNull(remoteDisablingExtension2);
|
||||
|
||||
Message message3 = PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
RemoteDisablingExtension remoteDisablingExtension3 = RemoteDisablingExtension.from(message3);
|
||||
Assert.assertNull(remoteDisablingExtension3);
|
||||
assertNull(remoteDisablingExtension3);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,16 +19,18 @@ package org.jivesoftware.smackx.reference;
|
|||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertNull;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
|
||||
import org.jivesoftware.smackx.reference.element.ReferenceElement;
|
||||
import org.jivesoftware.smackx.reference.provider.ReferenceProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ReferenceTest extends SmackTestSuite {
|
||||
|
||||
|
|
@ -76,24 +78,28 @@ public class ReferenceTest extends SmackTestSuite {
|
|||
assertXMLEqual(xml, parsed.toXML().toString());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void beginGreaterEndIllegalTest() throws URISyntaxException {
|
||||
new ReferenceElement(100, 10, ReferenceElement.Type.mention, null, new URI("xmpp:test@test.test"));
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new ReferenceElement(100, 10, ReferenceElement.Type.mention, null, new URI("xmpp:test@test.test")));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void beginSmallerZeroTest() throws URISyntaxException {
|
||||
new ReferenceElement(-1, 12, ReferenceElement.Type.data, null, new URI("xmpp:test@test.test"));
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new ReferenceElement(-1, 12, ReferenceElement.Type.data, null, new URI("xmpp:test@test.test")));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void endSmallerZeroTest() throws URISyntaxException {
|
||||
new ReferenceElement(12, -2, ReferenceElement.Type.mention, null, new URI("xmpp:test@test.test"));
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new ReferenceElement(12, -2, ReferenceElement.Type.mention, null, new URI("xmpp:test@test.test")));
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
@Test
|
||||
public void typeArgumentNullTest() throws URISyntaxException {
|
||||
new ReferenceElement(1, 2, null, null, new URI("xmpp:test@test.test"));
|
||||
assertThrows(NullPointerException.class, () ->
|
||||
new ReferenceElement(1, 2, null, null, new URI("xmpp:test@test.test")));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -26,12 +26,13 @@ import org.jivesoftware.smack.packet.Message;
|
|||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.sid.element.OriginIdElement;
|
||||
import org.jivesoftware.smackx.sid.element.StanzaIdElement;
|
||||
import org.jivesoftware.smackx.sid.provider.OriginIdProvider;
|
||||
import org.jivesoftware.smackx.sid.provider.StanzaIdProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class StableUniqueStanzaIdTest extends SmackTestSuite {
|
||||
|
||||
|
|
|
|||
|
|
@ -20,17 +20,19 @@ import static junit.framework.TestCase.assertEquals;
|
|||
import static junit.framework.TestCase.assertNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.spoiler.element.SpoilerElement;
|
||||
import org.jivesoftware.smackx.spoiler.provider.SpoilerProvider;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class SpoilerTest extends SmackTestSuite {
|
||||
|
||||
|
|
@ -114,15 +116,15 @@ public class SpoilerTest extends SmackTestSuite {
|
|||
assertEquals(spoilerText, spoilers.get("de"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void spoilerCheckArgumentsNullTest() {
|
||||
@SuppressWarnings("unused")
|
||||
SpoilerElement spoilerElement = new SpoilerElement("de", null);
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new SpoilerElement("de", null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void spoilerCheckArgumentsEmptyTest() {
|
||||
@SuppressWarnings("unused")
|
||||
SpoilerElement spoilerElement = new SpoilerElement("de", "");
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new SpoilerElement("de", ""));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue