mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 09:09:38 +02:00
Merge branch '4.2' into master-paul-merged
This commit is contained in:
commit
431e5b3c67
434 changed files with 1770 additions and 1517 deletions
|
@ -123,7 +123,7 @@ public class CarbonExtension implements ExtensionElement {
|
|||
/**
|
||||
* Defines the direction of a {@link CarbonExtension} message.
|
||||
*/
|
||||
public static enum Direction {
|
||||
public enum Direction {
|
||||
received,
|
||||
sent
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ExplicitMessageEncryptionElement implements ExtensionElement {
|
|||
private final String namespace;
|
||||
private final String name;
|
||||
|
||||
private ExplicitMessageEncryptionProtocol(String namespace, String name) {
|
||||
ExplicitMessageEncryptionProtocol(String namespace, String name) {
|
||||
this.namespace = namespace;
|
||||
this.name = name;
|
||||
PROTOCOL_LUT.put(namespace, this);
|
||||
|
|
|
@ -90,7 +90,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
/**
|
||||
* A builder for XMPP connection configurations.
|
||||
* <p>
|
||||
* See ConnectionConfiguration Buidler for more details.
|
||||
* See ConnectionConfiguration Builder for more details.
|
||||
* </p>
|
||||
*
|
||||
* @param <B> the builder type parameter.
|
||||
|
|
|
@ -64,7 +64,18 @@ import org.jxmpp.jid.DomainBareJid;
|
|||
*/
|
||||
public final class HttpFileUploadManager extends Manager {
|
||||
|
||||
/**
|
||||
* Namespace of XEP-0363 v0.4 or higher. Constant value {@value #NAMESPACE}.
|
||||
*
|
||||
* @see <a href="https://xmpp.org/extensions/attic/xep-0363-0.4.0.html">XEP-0363 v0.4.0</a>
|
||||
*/
|
||||
public static final String NAMESPACE = "urn:xmpp:http:upload:0";
|
||||
|
||||
/**
|
||||
* Namespace of XEP-0363 v0.2 or lower. Constant value {@value #NAMESPACE_0_2}.
|
||||
*
|
||||
* @see <a href="https://xmpp.org/extensions/attic/xep-0363-0.2.5.html">XEP-0363 v0.2.5</a>
|
||||
*/
|
||||
public static final String NAMESPACE_0_2 = "urn:xmpp:http:upload";
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(HttpFileUploadManager.class.getName());
|
||||
|
@ -459,6 +470,22 @@ public final class HttpFileUploadManager extends Manager {
|
|||
}
|
||||
}
|
||||
|
||||
public static UploadService.Version namespaceToVersion(String namespace) {
|
||||
UploadService.Version version;
|
||||
switch (namespace) {
|
||||
case NAMESPACE:
|
||||
version = Version.v0_3;
|
||||
break;
|
||||
case NAMESPACE_0_2:
|
||||
version = Version.v0_2;
|
||||
break;
|
||||
default:
|
||||
version = null;
|
||||
break;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
private static boolean containsHttpFileUploadNamespace(DiscoverInfo discoverInfo) {
|
||||
return discoverInfo.containsFeature(NAMESPACE) || discoverInfo.containsFeature(NAMESPACE_0_2);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,19 @@ import org.jxmpp.jid.DomainBareJid;
|
|||
|
||||
public class UploadService {
|
||||
|
||||
enum Version {
|
||||
public enum Version {
|
||||
/**
|
||||
* Upload service as specified in XEP-0363 v0.2 or lower.
|
||||
*
|
||||
* @see <a href="https://xmpp.org/extensions/attic/xep-0363-0.2.5.html">XEP-0363 v0.2.5</a>
|
||||
*/
|
||||
v0_2,
|
||||
|
||||
/**
|
||||
* Upload service as specified in XEP-0363 v0.3 or higher.
|
||||
*
|
||||
* @see <a href="https://xmpp.org/extensions/attic/xep-0363-0.4.0.html">XEP-0363 v0.4.0</a>
|
||||
*/
|
||||
v0_3,
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,9 @@ public class Slot extends IQ {
|
|||
public static final String ELEMENT = "slot";
|
||||
public static final String NAMESPACE = SlotRequest.NAMESPACE;
|
||||
|
||||
private final URL putUrl;
|
||||
private final URL getUrl;
|
||||
protected final URL putUrl;
|
||||
protected final URL getUrl;
|
||||
|
||||
private final Map<String, String> headers;
|
||||
|
||||
public Slot(URL putUrl, URL getUrl) {
|
||||
|
@ -73,12 +74,21 @@ public class Slot extends IQ {
|
|||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
|
||||
xml.element("put", putUrl.toString());
|
||||
xml.element("get", getUrl.toString());
|
||||
for (Map.Entry<String, String> entry : getHeaders().entrySet()) {
|
||||
xml.openElement("header").attribute(entry.getKey(), entry.getValue());
|
||||
xml.halfOpenElement("put").attribute("url", putUrl.toString());
|
||||
if (headers.isEmpty()) {
|
||||
xml.closeEmptyElement();
|
||||
} else {
|
||||
xml.rightAngleBracket();
|
||||
for (Map.Entry<String, String> entry : getHeaders().entrySet()) {
|
||||
xml.halfOpenElement("header").attribute("name", entry.getKey()).rightAngleBracket();
|
||||
xml.escape(entry.getValue());
|
||||
xml.closeElement("header");
|
||||
}
|
||||
xml.closeElement("put");
|
||||
}
|
||||
|
||||
xml.halfOpenElement("get").attribute("url", getUrl.toString()).closeEmptyElement();
|
||||
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,13 @@ public class Slot_V0_2 extends Slot {
|
|||
super(putUrl, getUrl, null, NAMESPACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
|
||||
xml.element("put", putUrl.toString());
|
||||
xml.element("get", getUrl.toString());
|
||||
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2017 Grigory Fedorov
|
||||
* Copyright © 2017 Grigory Fedorov, Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,6 +25,8 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager;
|
||||
import org.jivesoftware.smackx.httpfileupload.UploadService;
|
||||
import org.jivesoftware.smackx.httpfileupload.element.Slot;
|
||||
import org.jivesoftware.smackx.httpfileupload.element.Slot_V0_2;
|
||||
|
||||
|
@ -42,9 +44,13 @@ public class SlotProvider extends IQProvider<Slot> {
|
|||
@Override
|
||||
public Slot parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
final String namespace = parser.getNamespace();
|
||||
|
||||
final UploadService.Version version = HttpFileUploadManager.namespaceToVersion(namespace);
|
||||
assert version != null;
|
||||
|
||||
URL putUrl = null;
|
||||
URL getUrl = null;
|
||||
Map<String, String> headers = null;
|
||||
PutElement_V0_4_Content putElementV04Content = null;
|
||||
|
||||
outerloop: while (true) {
|
||||
int event = parser.next();
|
||||
|
@ -53,19 +59,33 @@ public class SlotProvider extends IQProvider<Slot> {
|
|||
case XmlPullParser.START_TAG:
|
||||
String name = parser.getName();
|
||||
switch (name) {
|
||||
case "put":
|
||||
putUrl = new URL(parser.nextText());
|
||||
break;
|
||||
case "get":
|
||||
getUrl = new URL(parser.nextText());
|
||||
break;
|
||||
case "header":
|
||||
String headerName = ParserUtils.getRequiredAttribute(parser, "name");
|
||||
String headerValue = ParserUtils.getRequiredNextText(parser);
|
||||
if (headers == null) {
|
||||
headers = new HashMap<>();
|
||||
case "put": {
|
||||
switch (version) {
|
||||
case v0_2:
|
||||
String putUrlString = parser.nextText();
|
||||
putUrl = new URL(putUrlString);
|
||||
break;
|
||||
case v0_3:
|
||||
putElementV04Content = parsePutElement_V0_4(parser);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
headers.put(headerName, headerValue);
|
||||
break;
|
||||
}
|
||||
case "get":
|
||||
String getUrlString;
|
||||
switch (version) {
|
||||
case v0_2:
|
||||
getUrlString = parser.nextText();
|
||||
break;
|
||||
case v0_3:
|
||||
getUrlString = parser.getAttributeValue(null, "url");
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
getUrl = new URL(getUrlString);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -77,13 +97,67 @@ public class SlotProvider extends IQProvider<Slot> {
|
|||
}
|
||||
}
|
||||
|
||||
switch (namespace) {
|
||||
case Slot.NAMESPACE:
|
||||
return new Slot(putUrl, getUrl, headers);
|
||||
case Slot_V0_2.NAMESPACE:
|
||||
switch (version) {
|
||||
case v0_3:
|
||||
return new Slot(putElementV04Content.putUrl, getUrl, putElementV04Content.headers);
|
||||
case v0_2:
|
||||
return new Slot_V0_2(putUrl, getUrl);
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public static PutElement_V0_4_Content parsePutElement_V0_4(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
final int initialDepth = parser.getDepth();
|
||||
|
||||
String putUrlString = parser.getAttributeValue(null, "url");
|
||||
URL putUrl = new URL(putUrlString);
|
||||
|
||||
Map<String, String> headers = null;
|
||||
outerloop: while (true) {
|
||||
int next = parser.next();
|
||||
switch (next) {
|
||||
case XmlPullParser.START_TAG:
|
||||
String name = parser.getName();
|
||||
switch (name) {
|
||||
case "header":
|
||||
String headerName = ParserUtils.getRequiredAttribute(parser, "name");
|
||||
String headerValue = ParserUtils.getRequiredNextText(parser);
|
||||
if (headers == null) {
|
||||
headers = new HashMap<>();
|
||||
}
|
||||
headers.put(headerName, headerValue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XmlPullParser.END_TAG:
|
||||
if (parser.getDepth() == initialDepth) {
|
||||
break outerloop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new PutElement_V0_4_Content(putUrl, headers);
|
||||
}
|
||||
|
||||
public static final class PutElement_V0_4_Content {
|
||||
private final URL putUrl;
|
||||
private final Map<String, String> headers;
|
||||
|
||||
private PutElement_V0_4_Content(URL putUrl, Map<String, String> headers) {
|
||||
this.putUrl = putUrl;
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public URL getPutUrl() {
|
||||
return putUrl;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ import org.jxmpp.jid.Jid;
|
|||
|
||||
public interface ThingControlRequest {
|
||||
|
||||
public void processRequest(Jid from, Collection<SetData> setData) throws XMPPErrorException;
|
||||
void processRequest(Jid from, Collection<SetData> setData) throws XMPPErrorException;
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class IoTSetResponse extends IQ {
|
|||
|
||||
public IoTSetResponse(IoTSetRequest iotSetRequest) {
|
||||
this();
|
||||
initialzeAsResultFor(iotSetRequest);
|
||||
initializeAsResultFor(iotSetRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@ public abstract class SetData implements NamedElement {
|
|||
|
||||
private final String toStringCache;
|
||||
|
||||
private Type() {
|
||||
Type() {
|
||||
toStringCache = this.name().toLowerCase(Locale.US);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@ package org.jivesoftware.smackx.iot.data;
|
|||
|
||||
public interface ThingMomentaryReadOutRequest {
|
||||
|
||||
public void momentaryReadOutRequest(ThingMomentaryReadOutResult callback);
|
||||
void momentaryReadOutRequest(ThingMomentaryReadOutResult callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@ import org.jivesoftware.smackx.iot.data.element.IoTDataField;
|
|||
|
||||
public interface ThingMomentaryReadOutResult {
|
||||
|
||||
public void momentaryReadOut(List<? extends IoTDataField> results);
|
||||
void momentaryReadOut(List<? extends IoTDataField> results);
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class IoTDataRequest extends IQ {
|
|||
public static final String NAMESPACE = Constants.IOT_SENSORDATA_NAMESPACE;
|
||||
|
||||
/**
|
||||
* The sequence nummber. According to XEP-0323 an xs:int.
|
||||
* The sequence number. According to XEP-0323 an xs:int.
|
||||
*/
|
||||
private final int seqNr;
|
||||
|
||||
|
|
|
@ -20,6 +20,6 @@ import org.jxmpp.jid.BareJid;
|
|||
|
||||
public interface ThingStateChangeListener {
|
||||
|
||||
public void owned(BareJid owner);
|
||||
void owned(BareJid owner);
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class Tag implements NamedElement {
|
|||
|
||||
public enum Type {
|
||||
str,
|
||||
num;
|
||||
num
|
||||
}
|
||||
|
||||
private final String name;
|
||||
|
|
|
@ -161,8 +161,8 @@ public final class IoTProvisioningManager extends Manager {
|
|||
// Notify the recommended friend that we will now accept his
|
||||
// friendship requests.
|
||||
final XMPPConnection connection = connection();
|
||||
Friend friendNotifiacation = new Friend(connection.getUser().asBareJid());
|
||||
Message notificationMessage = new Message(friendJid, friendNotifiacation);
|
||||
Friend friendNotification = new Friend(connection.getUser().asBareJid());
|
||||
Message notificationMessage = new Message(friendJid, friendNotification);
|
||||
connection.sendStanza(notificationMessage);
|
||||
} else {
|
||||
// Check is the message was send from a thing we previously
|
||||
|
@ -236,7 +236,7 @@ public final class IoTProvisioningManager extends Manager {
|
|||
}
|
||||
catch (NoResponseException | XMPPErrorException | NotConnectedException | InterruptedException e) {
|
||||
LOGGER.log(Level.WARNING,
|
||||
"Could not determine privisioning server. Ignoring friend request from " + from, e);
|
||||
"Could not determine provisioning server. Ignoring friend request from " + from, e);
|
||||
}
|
||||
if (provisioningServer == null) {
|
||||
return null;
|
||||
|
@ -420,7 +420,7 @@ public final class IoTProvisioningManager extends Manager {
|
|||
if (!provisioningServer.equals(stanza.getFrom())) {
|
||||
if (log) {
|
||||
LOGGER.warning("Ignoring request '" + stanza
|
||||
+ "' because not from provising server '" + provisioningServer
|
||||
+ "' because not from provisioning server '" + provisioningServer
|
||||
+ "'.");
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -239,11 +239,11 @@ public final class MamManager extends Manager {
|
|||
|
||||
|
||||
/**
|
||||
* Query an message archive like a MUC archive or a pubsub node archive, addressed by an archiveAddress, applying
|
||||
* Query an message archive like a MUC archive or a PubSub node archive, addressed by an archiveAddress, applying
|
||||
* filters: max count, start date, end date, from/to JID and with additional fields. When archiveAddress is null the
|
||||
* default, the server will be requested.
|
||||
*
|
||||
* @param node The Pubsub node name, can be null
|
||||
* @param node The PubSub node name, can be null
|
||||
* @param max
|
||||
* @param start
|
||||
* @param end
|
||||
|
@ -346,7 +346,7 @@ public final class MamManager extends Manager {
|
|||
/**
|
||||
* Returns a page of the archive.
|
||||
*
|
||||
* @param node The Pubsub node name, can be null
|
||||
* @param node The PubSub node name, can be null
|
||||
* @param dataForm
|
||||
* @param rsmSet
|
||||
* @return the MAM query result
|
||||
|
@ -498,7 +498,7 @@ public final class MamManager extends Manager {
|
|||
/**
|
||||
* Get the form fields supported by the server.
|
||||
*
|
||||
* @param node The Pubsub node name, can be null
|
||||
* @param node The PubSub node name, can be null
|
||||
* @return the list of form fields.
|
||||
* @throws NoResponseException
|
||||
* @throws XMPPErrorException
|
||||
|
@ -521,7 +521,7 @@ public final class MamManager extends Manager {
|
|||
private MamQueryResult queryArchive(MamQueryIQ mamQueryIq) throws NoResponseException, XMPPErrorException,
|
||||
NotConnectedException, InterruptedException, NotLoggedInException {
|
||||
final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
|
||||
MamFinIQ mamFinIQ = null;
|
||||
MamFinIQ mamFinIQ;
|
||||
|
||||
StanzaCollector mamFinIQCollector = connection.createStanzaCollector(new IQReplyFilter(mamQueryIq, connection));
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public class MultiUserChatLight {
|
|||
* Same as {@link #fromRoomFilter} together with
|
||||
* {@link MessageTypeFilter#GROUPCHAT}.
|
||||
*/
|
||||
private final StanzaFilter fromRoomGroupchatFilter;
|
||||
private final StanzaFilter fromRoomGroupChatFilter;
|
||||
|
||||
private final StanzaListener messageListener;
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class MultiUserChatLight {
|
|||
this.room = room;
|
||||
|
||||
fromRoomFilter = FromMatchesFilter.create(room);
|
||||
fromRoomGroupchatFilter = new AndFilter(fromRoomFilter, MessageTypeFilter.GROUPCHAT);
|
||||
fromRoomGroupChatFilter = new AndFilter(fromRoomFilter, MessageTypeFilter.GROUPCHAT);
|
||||
|
||||
messageListener = new StanzaListener() {
|
||||
@Override
|
||||
|
@ -105,7 +105,7 @@ public class MultiUserChatLight {
|
|||
}
|
||||
};
|
||||
|
||||
connection.addSyncStanzaListener(messageListener, fromRoomGroupchatFilter);
|
||||
connection.addSyncStanzaListener(messageListener, fromRoomGroupChatFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,7 +266,7 @@ public class MultiUserChatLight {
|
|||
throws Exception {
|
||||
MUCLightCreateIQ createMUCLightIQ = new MUCLightCreateIQ(room, roomName, occupants);
|
||||
|
||||
messageCollector = connection.createStanzaCollector(fromRoomGroupchatFilter);
|
||||
messageCollector = connection.createStanzaCollector(fromRoomGroupChatFilter);
|
||||
|
||||
try {
|
||||
connection.createStanzaCollectorAndSend(createMUCLightIQ).nextResultOrThrow();
|
||||
|
|
|
@ -96,7 +96,7 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
|
||||
private MultiUserChatLight createNewMucLightAndAddToMap(EntityBareJid jid) {
|
||||
MultiUserChatLight multiUserChatLight = new MultiUserChatLight(connection(), jid);
|
||||
multiUserChatLights.put(jid, new WeakReference<MultiUserChatLight>(multiUserChatLight));
|
||||
multiUserChatLights.put(jid, new WeakReference<>(multiUserChatLight));
|
||||
return multiUserChatLight;
|
||||
}
|
||||
|
||||
|
@ -193,11 +193,11 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
*/
|
||||
public List<Jid> getRoomsBlocked(DomainBareJid mucLightService)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
MUCLightBlockingIQ muclIghtBlockingIQResult = getBlockingList(mucLightService);
|
||||
MUCLightBlockingIQ mucLightBlockingIQResult = getBlockingList(mucLightService);
|
||||
|
||||
List<Jid> jids = new ArrayList<>();
|
||||
if (muclIghtBlockingIQResult.getRooms() != null) {
|
||||
jids.addAll(muclIghtBlockingIQResult.getRooms().keySet());
|
||||
if (mucLightBlockingIQResult.getRooms() != null) {
|
||||
jids.addAll(mucLightBlockingIQResult.getRooms().keySet());
|
||||
}
|
||||
|
||||
return jids;
|
||||
|
@ -215,11 +215,11 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
*/
|
||||
public List<Jid> getUsersBlocked(DomainBareJid mucLightService)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
MUCLightBlockingIQ muclIghtBlockingIQResult = getBlockingList(mucLightService);
|
||||
MUCLightBlockingIQ mucLightBlockingIQResult = getBlockingList(mucLightService);
|
||||
|
||||
List<Jid> jids = new ArrayList<>();
|
||||
if (muclIghtBlockingIQResult.getUsers() != null) {
|
||||
jids.addAll(muclIghtBlockingIQResult.getUsers().keySet());
|
||||
if (mucLightBlockingIQResult.getUsers() != null) {
|
||||
jids.addAll(mucLightBlockingIQResult.getUsers().keySet());
|
||||
}
|
||||
|
||||
return jids;
|
||||
|
@ -234,9 +234,9 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
StanzaFilter responseFilter = new IQReplyFilter(mucLightBlockingIQ, connection());
|
||||
IQ responseIq = connection().createStanzaCollectorAndSend(responseFilter, mucLightBlockingIQ)
|
||||
.nextResultOrThrow();
|
||||
MUCLightBlockingIQ muclIghtBlockingIQResult = (MUCLightBlockingIQ) responseIq;
|
||||
MUCLightBlockingIQ mucLightBlockingIQResult = (MUCLightBlockingIQ) responseIq;
|
||||
|
||||
return muclIghtBlockingIQResult;
|
||||
return mucLightBlockingIQResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -254,7 +254,7 @@
|
|||
<namespace>urn:xmpp:hints</namespace>
|
||||
<className>org.jivesoftware.smackx.hints.provider.StoreHintProvider</className>
|
||||
</extensionProvider>
|
||||
g
|
||||
|
||||
<!-- XEP-0363: HTTP File Upload -->
|
||||
<iqProvider>
|
||||
<elementName>slot</elementName>
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.junit.Test;
|
|||
public class ExperimentalInitializerTest {
|
||||
|
||||
@Test
|
||||
public void testExperimentalInitialzer() {
|
||||
public void testExperimentalInitializer() {
|
||||
ExperimentalInitializer epi = new ExperimentalInitializer();
|
||||
List<Exception> exceptions = epi.initialize();
|
||||
assertTrue(exceptions.size() == 0);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.carbons;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence;
|
||||
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AcknowledgedExtensionTest {
|
|||
AcknowledgedExtension acknowledgedExtension1 = new AcknowledgedProvider().parse(parser);
|
||||
Assert.assertEquals("message-1", acknowledgedExtension1.getId());
|
||||
|
||||
Message message = (Message) PacketParserUtils.parseStanza(acknowledgedMessageStanza);
|
||||
Message message = PacketParserUtils.parseStanza(acknowledgedMessageStanza);
|
||||
AcknowledgedExtension acknowledgedExtension2 = AcknowledgedExtension.from(message);
|
||||
Assert.assertEquals("message-1", acknowledgedExtension2.getId());
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class DisplayedExtensionTest {
|
|||
DisplayedExtension displayedExtension1 = new DisplayedProvider().parse(parser);
|
||||
Assert.assertEquals("message-1", displayedExtension1.getId());
|
||||
|
||||
Message message = (Message) PacketParserUtils.parseStanza(displayedMessageStanza);
|
||||
Message message = PacketParserUtils.parseStanza(displayedMessageStanza);
|
||||
DisplayedExtension displayedExtension2 = DisplayedExtension.from(message);
|
||||
Assert.assertEquals("message-1", displayedExtension2.getId());
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class MarkableExtensionTest {
|
|||
MarkableExtension markableExtension1 = new MarkableProvider().parse(parser);
|
||||
Assert.assertEquals(markableExtension, markableExtension1.toXML().toString());
|
||||
|
||||
Message message = (Message) PacketParserUtils.parseStanza(markableMessageStanza);
|
||||
Message message = PacketParserUtils.parseStanza(markableMessageStanza);
|
||||
MarkableExtension markableExtension2 = MarkableExtension.from(message);
|
||||
Assert.assertEquals(markableExtension, markableExtension2.toXML().toString());
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ReceivedExtensionTest {
|
|||
ReceivedExtension receivedExtension1 = new ReceivedProvider().parse(parser);
|
||||
Assert.assertEquals("message-1", receivedExtension1.getId());
|
||||
|
||||
Message message = (Message) PacketParserUtils.parseStanza(receivedMessageStanza);
|
||||
Message message = PacketParserUtils.parseStanza(receivedMessageStanza);
|
||||
ReceivedExtension receivedExtension2 = ReceivedExtension.from(message);
|
||||
Assert.assertEquals("message-1", receivedExtension2.getId());
|
||||
}
|
||||
|
|
|
@ -72,7 +72,6 @@ public class HttpOverXmppReqProviderTest {
|
|||
XmlPullParser parser = PacketParserUtils.getParserFor(string);
|
||||
IQ iq = provider.parse(parser);
|
||||
assertTrue(iq instanceof HttpOverXmppReq);
|
||||
HttpOverXmppReq castedIq = (HttpOverXmppReq) iq;
|
||||
return castedIq;
|
||||
return (HttpOverXmppReq) iq;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
public class FileTooLargeErrorCreateTest {
|
||||
String fileTooLargeErrorExtensionExample
|
||||
private static final String fileTooLargeErrorExtensionExample
|
||||
= "<file-too-large xmlns='urn:xmpp:http:upload:0'>"
|
||||
+ "<max-file-size>20000</max-file-size>"
|
||||
+ "</file-too-large>";
|
||||
|
|
|
@ -16,23 +16,26 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.httpfileupload;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
|
||||
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.xml.sax.SAXException;
|
||||
|
||||
public class SlotCreateTest {
|
||||
String testSlot
|
||||
private static final String testSlot
|
||||
= "<slot xmlns='urn:xmpp:http:upload:0'>"
|
||||
+ "<put>https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png</put>"
|
||||
+ "<get>https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png</get>"
|
||||
+ "<put url='https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png'></put>"
|
||||
+ "<get url='https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png'></get>"
|
||||
+ "</slot>";
|
||||
|
||||
@Test
|
||||
public void checkSlotRequestCreation() throws MalformedURLException {
|
||||
public void checkSlotRequestCreation() throws SAXException, IOException {
|
||||
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"));
|
||||
|
||||
|
@ -41,6 +44,6 @@ public class SlotCreateTest {
|
|||
Assert.assertEquals(new URL("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
slot.getGetUrl());
|
||||
|
||||
Assert.assertEquals(testSlot, slot.getChildElementXML().toString());
|
||||
assertXMLEqual(testSlot, slot.getChildElementXML().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,14 +29,14 @@ import org.xml.sax.SAXException;
|
|||
|
||||
public class SlotRequestCreateTest {
|
||||
|
||||
String testRequest
|
||||
private static final String testRequest
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'"
|
||||
+ " filename='my_juliet.png'"
|
||||
+ " size='23456'"
|
||||
+ " content-type='image/jpeg'"
|
||||
+ "/>";
|
||||
|
||||
String testRequestWithoutContentType
|
||||
private static final String testRequestWithoutContentType
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'"
|
||||
+ " filename='my_romeo.png'"
|
||||
+ " size='52523'"
|
||||
|
|
|
@ -30,7 +30,7 @@ public class FileTooLargeErrorProviderTest {
|
|||
* Example 7. Alternative response by the upload service if the file size was too large
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0363.html#errors">XEP-0363: HTTP File Upload 5. Error conditions</a>
|
||||
*/
|
||||
String slotErrorFileToLarge
|
||||
private static final String slotErrorFileToLarge
|
||||
= "<iq from='upload.montague.tld' "
|
||||
+ "id='step_03' "
|
||||
+ "to='romeo@montague.tld/garden' "
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2017 Grigory Fedorov
|
||||
* Copyright © 2017 Grigory Fedorov, 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,42 +16,108 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.httpfileupload.provider;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
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.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class SlotProviderTest {
|
||||
|
||||
private static final String PUT_URL_STRING = "https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png";
|
||||
|
||||
private static final String GET_URL_STRING = "https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png";
|
||||
|
||||
private static final URL PUT_URL = urlFromString(PUT_URL_STRING);
|
||||
private static final URL GET_URL = urlFromString(GET_URL_STRING);
|
||||
|
||||
private static URL urlFromString(String urlString) {
|
||||
try {
|
||||
return new URL(urlString);
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Example 6. The upload service responds with a slot
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0363.html#request">XEP-0363: HTTP File Upload 4. Requesting a slot</a>
|
||||
*/
|
||||
String slotExample
|
||||
private static final String SLOT_IQ
|
||||
= "<iq from='upload.montague.tld' "
|
||||
+ "id='step_03' "
|
||||
+ "to='romeo@montague.tld/garden' "
|
||||
+ "type='result'>"
|
||||
+ "<slot xmlns='urn:xmpp:http:upload:0'>"
|
||||
+ "<put>https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png</put>"
|
||||
+ "<get>https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png</get>"
|
||||
+ "<put url='" + PUT_URL_STRING + "'></put>"
|
||||
+ "<get url='" + GET_URL_STRING + "'></get>"
|
||||
+ "</slot>"
|
||||
+ "</iq>";
|
||||
|
||||
@Test
|
||||
public void checkSlotProvider() throws Exception {
|
||||
Slot slot = PacketParserUtils.parseStanza(slotExample);
|
||||
Slot slot = PacketParserUtils.parseStanza(SLOT_IQ);
|
||||
|
||||
Assert.assertEquals(IQ.Type.result, slot.getType());
|
||||
Assert.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"),
|
||||
slot.getGetUrl());
|
||||
checkUrls(slot);
|
||||
|
||||
assertXMLEqual(SLOT_IQ, slot.toXML().toString());
|
||||
}
|
||||
|
||||
private static final String SLOT_V0_2_IQ =
|
||||
"<iq from='upload.montague.tld' " +
|
||||
"id='step_03' " +
|
||||
"to='romeo@montague.tld/garden' " +
|
||||
"type='result'>" +
|
||||
"<slot xmlns='urn:xmpp:http:upload'>" +
|
||||
"<put>" + PUT_URL_STRING + "</put>" +
|
||||
"<get>" + GET_URL_STRING + "</get>" +
|
||||
"</slot>" +
|
||||
"</iq>";
|
||||
|
||||
@Test
|
||||
public void checkSlotV0_2Provider() throws Exception {
|
||||
Slot_V0_2 slot = PacketParserUtils.parseStanza(SLOT_V0_2_IQ);
|
||||
|
||||
checkUrls(slot);
|
||||
|
||||
String slotXml = slot.toXML().toString();
|
||||
assertXMLEqual(SLOT_V0_2_IQ, slotXml);
|
||||
}
|
||||
|
||||
private static final String SLOT_WITH_HEADERS_IQ =
|
||||
"<iq from='upload.montague.tld' " +
|
||||
"id='step_03' " +
|
||||
"to='romeo@montague.tld/garden' " +
|
||||
"type='result'>" +
|
||||
"<slot xmlns='urn:xmpp:http:upload:0'>" +
|
||||
"<put url='" + PUT_URL_STRING + "'>" +
|
||||
"<header name='Authorization'>Basic Base64String==</header>" +
|
||||
"<header name='Host'>montague.tld</header>" +
|
||||
"</put>" +
|
||||
"<get url='" + GET_URL_STRING + "' />" +
|
||||
"</slot>" +
|
||||
"</iq>";
|
||||
|
||||
@Test
|
||||
public void checkSlotWithHeaders() throws Exception {
|
||||
Slot slot = PacketParserUtils.parseStanza(SLOT_WITH_HEADERS_IQ);
|
||||
|
||||
checkUrls(slot);
|
||||
|
||||
String slotXml = slot.toXML().toString();
|
||||
assertXMLEqual(SLOT_WITH_HEADERS_IQ, slotXml);
|
||||
}
|
||||
|
||||
private static void checkUrls(Slot slot) {
|
||||
assertEquals(PUT_URL, slot.getPutUrl());
|
||||
assertEquals(GET_URL, slot.getGetUrl());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class MamFinProviderTest extends MamTest {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
IQ iq = (IQ) PacketParserUtils.parseStanza(IQ_LIMITED_RESULTS_EXAMPLE);
|
||||
IQ iq = PacketParserUtils.parseStanza(IQ_LIMITED_RESULTS_EXAMPLE);
|
||||
|
||||
MamFinIQ mamFinIQ = (MamFinIQ) iq;
|
||||
Assert.assertEquals(mamFinIQ.getType(), Type.result);
|
||||
|
|
|
@ -31,18 +31,18 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
|
||||
public class MamPrefIQProviderTest extends MamTest {
|
||||
|
||||
String exampleMamPrefsIQ1 = "<iq type='set' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1' default='roster'>"
|
||||
private static final String exampleMamPrefsIQ1 = "<iq type='set' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1' default='roster'>"
|
||||
+ "<always>" + "<jid>romeo@montague.lit</jid>" + "</always>" + "<never>"
|
||||
+ "<jid>montague@montague.lit</jid>" + "</never>" + "</prefs>" + "</iq>";
|
||||
|
||||
String exampleMamPrefsIQ2 = "<iq type='set' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1' default='roster'>"
|
||||
private static final String exampleMamPrefsIQ2 = "<iq type='set' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1' default='roster'>"
|
||||
+ "<always>" + "<jid>romeo@montague.lit</jid>" + "<jid>montague@montague.lit</jid>" + "</always>"
|
||||
+ "<never>" + "</never>" + "</prefs>" + "</iq>";
|
||||
|
||||
String exampleMamPrefsIQ3 = "<iq type='get' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1'>" + "</prefs>"
|
||||
private static final String exampleMamPrefsIQ3 = "<iq type='get' id='juliet3'>" + "<prefs xmlns='urn:xmpp:mam:1'>" + "</prefs>"
|
||||
+ "</iq>";
|
||||
|
||||
String exampleMamPrefsResultIQ = "<iq type='result' id='juliet3'>"
|
||||
private static final String exampleMamPrefsResultIQ = "<iq type='result' id='juliet3'>"
|
||||
+ "<prefs xmlns='urn:xmpp:mam:1' default='roster'>" + "<always>" + "<jid>romeo@montague.lit</jid>"
|
||||
+ "</always>" + "<never>" + "<jid>sarasa@montague.lit</jid>" + "<jid>montague@montague.lit</jid>"
|
||||
+ "</never>" + "</prefs>" + "</iq>";
|
||||
|
@ -53,14 +53,14 @@ public class MamPrefIQProviderTest extends MamTest {
|
|||
MamPrefsIQ mamPrefIQ1 = new MamPrefsIQProvider().parse(parser1);
|
||||
|
||||
Assert.assertEquals(IQ.Type.set, mamPrefIQ1.getType());
|
||||
Assert.assertEquals(mamPrefIQ1.getAlwaysJids().get(0), "romeo@montague.lit");
|
||||
Assert.assertEquals(mamPrefIQ1.getNeverJids().get(0), "montague@montague.lit");
|
||||
Assert.assertEquals(mamPrefIQ1.getAlwaysJids().get(0).toString(), "romeo@montague.lit");
|
||||
Assert.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), "romeo@montague.lit");
|
||||
Assert.assertEquals(mamPrefIQ2.getAlwaysJids().get(1), "montague@montague.lit");
|
||||
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());
|
||||
|
||||
XmlPullParser parser3 = PacketParserUtils.getParserFor(exampleMamPrefsIQ3);
|
||||
|
@ -70,7 +70,7 @@ public class MamPrefIQProviderTest extends MamTest {
|
|||
|
||||
@Test
|
||||
public void checkMamPrefResult() throws Exception {
|
||||
IQ iq = (IQ) PacketParserUtils.parseStanza(exampleMamPrefsResultIQ);
|
||||
IQ iq = PacketParserUtils.parseStanza(exampleMamPrefsResultIQ);
|
||||
|
||||
MamPrefsIQ mamPrefsIQ = (MamPrefsIQ) iq;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.Test;
|
|||
|
||||
public class MamQueryIQProviderTest {
|
||||
|
||||
String exampleMamQueryIQ1 = "<iq type='set' id='query4'>" + "<query xmlns='urn:xmpp:mam:1' queryid='test'>"
|
||||
private static final String exampleMamQueryIQ1 = "<iq type='set' id='query4'>" + "<query xmlns='urn:xmpp:mam:1' queryid='test'>"
|
||||
+ "<x xmlns='jabber:x:data' type='submit'>" + "<field type='hidden' var='FORM_TYPE'>"
|
||||
+ "<value>urn:xmpp:mam:1</value>" + "</field>"
|
||||
+ "<field type='text-single' var='urn:example:xmpp:free-text-search'>"
|
||||
|
@ -41,7 +41,7 @@ public class MamQueryIQProviderTest {
|
|||
+ "<value>{http://jabber.org/protocol/mood}mood/lonely</value>" + "</field>" + "</x>" + "</query>"
|
||||
+ "</iq>";
|
||||
|
||||
String exampleMamQueryIQ2 = "<iq type='result' id='form1'>" + "<query xmlns='urn:xmpp:mam:1'>"
|
||||
private static final String exampleMamQueryIQ2 = "<iq type='result' id='form1'>" + "<query xmlns='urn:xmpp:mam:1'>"
|
||||
+ "<x xmlns='jabber:x:data' type='form'>" + "<field type='hidden' var='FORM_TYPE'>"
|
||||
+ "<value>urn:xmpp:mam:1</value>" + "</field>" + "<field type='jid-single' var='with'/>"
|
||||
+ "<field type='text-single' var='start'/>" + "<field type='text-single' var='end'/>"
|
||||
|
@ -51,7 +51,7 @@ public class MamQueryIQProviderTest {
|
|||
@Test
|
||||
public void checkMamQueryIQProvider() throws Exception {
|
||||
// example 1
|
||||
IQ iq1 = (IQ) PacketParserUtils.parseStanza(exampleMamQueryIQ1);
|
||||
IQ iq1 = PacketParserUtils.parseStanza(exampleMamQueryIQ1);
|
||||
MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1;
|
||||
|
||||
Assert.assertEquals(mamQueryIQ1.getType(), Type.set);
|
||||
|
@ -67,7 +67,7 @@ public class MamQueryIQProviderTest {
|
|||
Assert.assertEquals(fields1.get(2).getValues().get(0), "{http://jabber.org/protocol/mood}mood/lonely");
|
||||
|
||||
// example2
|
||||
IQ iq2 = (IQ) PacketParserUtils.parseStanza(exampleMamQueryIQ2);
|
||||
IQ iq2 = PacketParserUtils.parseStanza(exampleMamQueryIQ2);
|
||||
MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2;
|
||||
|
||||
Assert.assertEquals(mamQueryIQ2.getType(), Type.result);
|
||||
|
|
|
@ -33,14 +33,14 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
|
||||
public class MamResultProviderTest {
|
||||
|
||||
String exampleMamResultXml = "<result xmlns='urn:xmpp:mam:1' queryid='f27' id='28482-98726-73623'>"
|
||||
private static final String exampleMamResultXml = "<result xmlns='urn:xmpp:mam:1' queryid='f27' id='28482-98726-73623'>"
|
||||
+ "<forwarded xmlns='urn:xmpp:forward:0'>" + "<delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/>"
|
||||
+ "<message xmlns='jabber:client'" + "to='juliet@capulet.lit/balcony'" + "from='romeo@montague.lit/orchard'"
|
||||
+ "type='chat'>"
|
||||
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
|
||||
+ "</message>" + "</forwarded>" + "</result>";
|
||||
|
||||
String exampleResultMessage = "<message id='aeb213' to='juliet@capulet.lit/chamber'>"
|
||||
private static final String exampleResultMessage = "<message id='aeb213' to='juliet@capulet.lit/chamber'>"
|
||||
+ "<result xmlns='urn:xmpp:mam:1' queryid='f27' id='28482-98726-73623'>"
|
||||
+ "<forwarded xmlns='urn:xmpp:forward:0'>" + "<delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/>"
|
||||
+ "<message xmlns='jabber:client' from='witch@shakespeare.lit' to='macbeth@shakespeare.lit'>"
|
||||
|
@ -62,15 +62,15 @@ public class MamResultProviderTest {
|
|||
Assert.assertEquals(forwarded.getDelayInformation().getStamp(), date);
|
||||
|
||||
Message message = (Message) forwarded.getForwardedStanza();
|
||||
Assert.assertEquals(message.getFrom(), "romeo@montague.lit/orchard");
|
||||
Assert.assertEquals(message.getTo(), "juliet@capulet.lit/balcony");
|
||||
Assert.assertEquals(message.getFrom().toString(), "romeo@montague.lit/orchard");
|
||||
Assert.assertEquals(message.getTo().toString(), "juliet@capulet.lit/balcony");
|
||||
Assert.assertEquals(message.getBody(),
|
||||
"Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkResultsParse() throws Exception {
|
||||
Message message = (Message) PacketParserUtils.parseStanza(exampleResultMessage);
|
||||
Message message = PacketParserUtils.parseStanza(exampleResultMessage);
|
||||
MamResultExtension mamResultExtension = MamResultExtension.from(message);
|
||||
|
||||
Assert.assertEquals(mamResultExtension.getQueryId(), "f27");
|
||||
|
@ -84,8 +84,8 @@ public class MamResultProviderTest {
|
|||
Assert.assertEquals(forwarded.getDelayInformation().getStamp(), date);
|
||||
|
||||
Message forwardedMessage = (Message) forwarded.getForwardedStanza();
|
||||
Assert.assertEquals(forwardedMessage.getFrom(), "witch@shakespeare.lit");
|
||||
Assert.assertEquals(forwardedMessage.getTo(), "macbeth@shakespeare.lit");
|
||||
Assert.assertEquals(forwardedMessage.getFrom().toString(), "witch@shakespeare.lit");
|
||||
Assert.assertEquals(forwardedMessage.getTo().toString(), "macbeth@shakespeare.lit");
|
||||
Assert.assertEquals(forwardedMessage.getBody(), "Hail to thee");
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class PreferencesTest {
|
||||
|
||||
String retrievePrefsStanzaExample = "<iq id='sarasa' type='get'>" + "<prefs xmlns='" + MamElements.NAMESPACE
|
||||
private static final String retrievePrefsStanzaExample = "<iq id='sarasa' type='get'>" + "<prefs xmlns='" + MamElements.NAMESPACE
|
||||
+ "'/>" + "</iq>";
|
||||
|
||||
String updatePrefsStanzaExample = "<iq id='sarasa' type='set'>" + "<prefs xmlns='" + MamElements.NAMESPACE
|
||||
private static final String updatePrefsStanzaExample = "<iq id='sarasa' type='set'>" + "<prefs xmlns='" + MamElements.NAMESPACE
|
||||
+ "' default='roster'>" + "<always>" + "<jid>romeo@montague.lit</jid>" + "<jid>other@montague.lit</jid>"
|
||||
+ "</always>" + "<never>" + "<jid>montague@montague.lit</jid>" + "</never>" + "</prefs>" + "</iq>";
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class QueryArchiveTest extends MamTest {
|
||||
|
||||
String mamSimpleQueryIQ = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:1' queryid='testid'>"
|
||||
private static final String mamSimpleQueryIQ = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:1' queryid='testid'>"
|
||||
+ "<x xmlns='jabber:x:data' type='submit'>" + "<field var='FORM_TYPE' type='hidden'>" + "<value>"
|
||||
+ MamElements.NAMESPACE + "</value>" + "</field>" + "</x>" + "</query>" + "</iq>";
|
||||
|
||||
String mamQueryResultExample = "<message to='hag66@shakespeare.lit/pda' from='coven@chat.shakespeare.lit' id='iasd207'>"
|
||||
private static final String mamQueryResultExample = "<message to='hag66@shakespeare.lit/pda' from='coven@chat.shakespeare.lit' id='iasd207'>"
|
||||
+ "<result xmlns='urn:xmpp:mam:1' queryid='g27' id='34482-21985-73620'>"
|
||||
+ "<forwarded xmlns='urn:xmpp:forward:0'>"
|
||||
+ "<delay xmlns='urn:xmpp:delay' stamp='2002-10-13T23:58:37.000+00:00'></delay>" + "<message "
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.junit.Test;
|
|||
|
||||
public class ResultsLimitTest extends MamTest {
|
||||
|
||||
String resultsLimitStanza = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:1' queryid='testid'>"
|
||||
private static final String resultsLimitStanza = "<iq id='sarasa' type='set'>" + "<query xmlns='urn:xmpp:mam:1' queryid='testid'>"
|
||||
+ "<x xmlns='jabber:x:data' type='submit'>" + "<field var='FORM_TYPE' type='hidden'>" + "<value>"
|
||||
+ MamElements.NAMESPACE + "</value>" + "</field>" + "</x>" + "<set xmlns='http://jabber.org/protocol/rsm'>"
|
||||
+ "<max>10</max>" + "</set>" + "</query>" + "</iq>";
|
||||
|
|
|
@ -30,19 +30,19 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightAffiliationsChangeExtensionTest {
|
||||
|
||||
String exampleMessageStanza = "<message " + "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
||||
private static final String exampleMessageStanza = "<message " + "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
||||
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>"
|
||||
+ "<user affiliation='owner'>sarasa2@shakespeare.lit</user>"
|
||||
+ "<user affiliation='member'>sarasa1@shakespeare.lit</user>"
|
||||
+ "<user affiliation='none'>sarasa3@shakespeare.lit</user>" + "</x>" + "</message>";
|
||||
|
||||
String exampleMessageStanzaWithVersion = "<message "
|
||||
private static final String exampleMessageStanzaWithVersion = "<message "
|
||||
+ "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
||||
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>" + "<version>qwerty</version>"
|
||||
+ "<user affiliation='member'>sarasa1@shakespeare.lit</user>"
|
||||
+ "<user affiliation='none'>sarasa3@shakespeare.lit</user>" + "</x>" + "<body></body>" + "</message>";
|
||||
|
||||
String exampleMessageStanzaWithPrevVersion = "<message "
|
||||
private static final String exampleMessageStanzaWithPrevVersion = "<message "
|
||||
+ "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
||||
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>" + "<prev-version>njiokm</prev-version>"
|
||||
+ "<version>qwerty</version>" + "<user affiliation='owner'>sarasa2@shakespeare.lit</user>"
|
||||
|
@ -50,7 +50,7 @@ public class MUCLightAffiliationsChangeExtensionTest {
|
|||
|
||||
@Test
|
||||
public void checkAffiliationsChangeExtension() throws Exception {
|
||||
Message changeAffiliationsMessage = (Message) PacketParserUtils.parseStanza(exampleMessageStanza);
|
||||
Message changeAffiliationsMessage = PacketParserUtils.parseStanza(exampleMessageStanza);
|
||||
AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension
|
||||
.from(changeAffiliationsMessage);
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class MUCLightAffiliationsChangeExtensionTest {
|
|||
|
||||
@Test
|
||||
public void checkAffiliationsChangeExtensionWithVersion() throws Exception {
|
||||
Message changeAffiliationsMessage = (Message) PacketParserUtils.parseStanza(exampleMessageStanzaWithVersion);
|
||||
Message changeAffiliationsMessage = PacketParserUtils.parseStanza(exampleMessageStanzaWithVersion);
|
||||
AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension
|
||||
.from(changeAffiliationsMessage);
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class MUCLightAffiliationsChangeExtensionTest {
|
|||
|
||||
@Test
|
||||
public void checkAffiliationsChangeExtensionWithPrevVersion() throws Exception {
|
||||
Message changeAffiliationsMessage = (Message) PacketParserUtils
|
||||
Message changeAffiliationsMessage = PacketParserUtils
|
||||
.parseStanza(exampleMessageStanzaWithPrevVersion);
|
||||
AffiliationsChangeExtension affiliationsChangeExtension = AffiliationsChangeExtension
|
||||
.from(changeAffiliationsMessage);
|
||||
|
|
|
@ -31,25 +31,25 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightBlockingTest {
|
||||
|
||||
String getBlockingListIQExample = "<iq to='muclight.shakespeare.lit' id='getblock1' type='get'>"
|
||||
private static final String getBlockingListIQExample = "<iq to='muclight.shakespeare.lit' id='getblock1' type='get'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#blocking'>" + "</query>" + "</iq>";
|
||||
|
||||
String getBlockingListIQResponse = "<iq type='result' id='getblock1' to='crone1@shakespeare.lit/desktop' from='muclight.shakespeare.lit'>"
|
||||
private static final String getBlockingListIQResponse = "<iq type='result' id='getblock1' to='crone1@shakespeare.lit/desktop' from='muclight.shakespeare.lit'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#blocking'>"
|
||||
+ "<room action='deny'>coven@muclight.shakespeare.lit</room>"
|
||||
+ "<room action='deny'>sarasa@muclight.shakespeare.lit</room>"
|
||||
+ "<user action='deny'>hag77@shakespeare.lit</user>" + "</query>" + "</iq>";
|
||||
|
||||
String blockingRoomsIQExample = "<iq to='muclight.shakespeare.lit' id='block1' type='set'>"
|
||||
private static final String blockingRoomsIQExample = "<iq to='muclight.shakespeare.lit' id='block1' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#blocking'>"
|
||||
+ "<room action='deny'>coven@muclight.shakespeare.lit</room>"
|
||||
+ "<room action='deny'>chapel@shakespeare.lit</room>" + "</query>" + "</iq>";
|
||||
|
||||
String blockingUsersIQExample = "<iq to='muclight.shakespeare.lit' id='block2' type='set'>"
|
||||
private static final String blockingUsersIQExample = "<iq to='muclight.shakespeare.lit' id='block2' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#blocking'>" + "<user action='deny'>hag77@shakespeare.lit</user>"
|
||||
+ "<user action='deny'>hag66@shakespeare.lit</user>" + "</query>" + "</iq>";
|
||||
|
||||
String unblockingUsersAndRoomsExample = "<iq to='muclight.shakespeare.lit' id='unblock1' type='set'>"
|
||||
private static final String unblockingUsersAndRoomsExample = "<iq to='muclight.shakespeare.lit' id='unblock1' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#blocking'>"
|
||||
+ "<room action='allow'>coven@muclight.shakespeare.lit</room>"
|
||||
+ "<user action='allow'>hag66@shakespeare.lit</user>" + "</query>" + "</iq>";
|
||||
|
@ -66,7 +66,7 @@ public class MUCLightBlockingTest {
|
|||
|
||||
@Test
|
||||
public void checkGetBlockingListResponse() throws Exception {
|
||||
IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getBlockingListIQResponse);
|
||||
IQ iqInfoResult = PacketParserUtils.parseStanza(getBlockingListIQResponse);
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = (MUCLightBlockingIQ) iqInfoResult;
|
||||
|
||||
Assert.assertEquals(2, mucLightBlockingIQ.getRooms().size());
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightChangeAffiliationsIQTest {
|
||||
|
||||
String stanza = "<iq " + "to='coven@muclight.shakespeare.lit' id='member1' type='set'>"
|
||||
private static final String stanza = "<iq " + "to='coven@muclight.shakespeare.lit' id='member1' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#affiliations'>"
|
||||
+ "<user affiliation='owner'>sarasa2@shakespeare.lit</user>"
|
||||
+ "<user affiliation='member'>sarasa1@shakespeare.lit</user>"
|
||||
|
|
|
@ -26,23 +26,23 @@ import org.junit.Test;
|
|||
|
||||
public class MUCLightConfigurationsChangeExtensionTest {
|
||||
|
||||
String messageWithSubjectChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||
private static final String messageWithSubjectChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>"
|
||||
+ "<prev-version>asdfghj000</prev-version>" + "<version>asdfghj</version>"
|
||||
+ "<subject>To be or not to be?</subject>" + "</x>" + "</message>";
|
||||
|
||||
String messageWithRoomNameChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||
private static final String messageWithRoomNameChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>" + "<prev-version>zaqwsx</prev-version>"
|
||||
+ "<version>zxcvbnm</version>" + "<roomname>A Darker Cave</roomname>" + "</x>" + "</message>";
|
||||
|
||||
String messageWithConfigsChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||
private static final String messageWithConfigsChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>" + "<prev-version>zaqwsx</prev-version>"
|
||||
+ "<version>zxcvbnm</version>" + "<roomname>A Darker Cave</roomname>" + "<color>blue</color>" + "</x>"
|
||||
+ "</message>";
|
||||
|
||||
@Test
|
||||
public void checkSubjectChangeExtension() throws Exception {
|
||||
Message configurationsMessage = (Message) PacketParserUtils.parseStanza(messageWithSubjectChangeExample);
|
||||
Message configurationsMessage = PacketParserUtils.parseStanza(messageWithSubjectChangeExample);
|
||||
ConfigurationsChangeExtension configurationsChangeExtension = ConfigurationsChangeExtension
|
||||
.from(configurationsMessage);
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class MUCLightConfigurationsChangeExtensionTest {
|
|||
|
||||
@Test
|
||||
public void checkRoomNameChangeExtension() throws Exception {
|
||||
Message configurationsMessage = (Message) PacketParserUtils.parseStanza(messageWithRoomNameChangeExample);
|
||||
Message configurationsMessage = PacketParserUtils.parseStanza(messageWithRoomNameChangeExample);
|
||||
ConfigurationsChangeExtension configurationsChangeExtension = ConfigurationsChangeExtension
|
||||
.from(configurationsMessage);
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class MUCLightConfigurationsChangeExtensionTest {
|
|||
|
||||
@Test
|
||||
public void checkConfigsChangeExtension() throws Exception {
|
||||
Message configurationsMessage = (Message) PacketParserUtils.parseStanza(messageWithConfigsChangeExample);
|
||||
Message configurationsMessage = PacketParserUtils.parseStanza(messageWithConfigsChangeExample);
|
||||
ConfigurationsChangeExtension configurationsChangeExtension = ConfigurationsChangeExtension
|
||||
.from(configurationsMessage);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightCreateIQTest {
|
||||
|
||||
String stanza = "<iq to='ef498f55-5f79-4238-a5ae-4efe19cbe617@muclight.test.com' id='1c72W-50' type='set'>"
|
||||
private static final String stanza = "<iq to='ef498f55-5f79-4238-a5ae-4efe19cbe617@muclight.test.com' id='1c72W-50' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#create'>" + "<configuration>" + "<roomname>test</roomname>"
|
||||
+ "</configuration>" + "<occupants>" + "<user affiliation='member'>charlie@test.com</user>"
|
||||
+ "<user affiliation='member'>pep@test.com</user>" + "</occupants>" + "</query>" + "</iq>";
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightDestroyTest {
|
||||
|
||||
String stanza = "<iq to='coven@muclight.shakespeare.lit' id='destroy1' type='set'>"
|
||||
private static final String stanza = "<iq to='coven@muclight.shakespeare.lit' id='destroy1' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#destroy'/>" + "</iq>";
|
||||
|
||||
@Test
|
||||
|
|
|
@ -31,10 +31,10 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightGetAffiliationsTest {
|
||||
|
||||
String getAffiliationsIQExample = "<iq to='coven@muclight.shakespeare.lit' id='getmembers' type='get'>"
|
||||
private static final String getAffiliationsIQExample = "<iq to='coven@muclight.shakespeare.lit' id='getmembers' type='get'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#affiliations'>" + "<version>abcdefg</version>" + "</query>" + "</iq>";
|
||||
|
||||
String getAffiliationsResponseExample = "<iq from='coven@muclight.shakespeare.lit' id='getmembers' to='crone1@shakespeare.lit/desktop' type='result'>"
|
||||
private static final String getAffiliationsResponseExample = "<iq from='coven@muclight.shakespeare.lit' id='getmembers' to='crone1@shakespeare.lit/desktop' type='result'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#affiliations'>" + "<version>123456</version>"
|
||||
+ "<user affiliation='owner'>user1@shakespeare.lit</user>"
|
||||
+ "<user affiliation='member'>user2@shakespeare.lit</user>"
|
||||
|
@ -50,7 +50,7 @@ public class MUCLightGetAffiliationsTest {
|
|||
|
||||
@Test
|
||||
public void checkGetAffiliationsResponse() throws Exception {
|
||||
IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getAffiliationsResponseExample);
|
||||
IQ iqInfoResult = PacketParserUtils.parseStanza(getAffiliationsResponseExample);
|
||||
MUCLightAffiliationsIQ mucLightAffiliationsIQ = (MUCLightAffiliationsIQ) iqInfoResult;
|
||||
|
||||
Assert.assertEquals("123456", mucLightAffiliationsIQ.getVersion());
|
||||
|
|
|
@ -30,15 +30,15 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightGetConfigsTest {
|
||||
|
||||
String getConfigsIQExample = "<iq to='coven@muclight.shakespeare.lit' id='config0' type='get'>"
|
||||
private static final String getConfigsIQExample = "<iq to='coven@muclight.shakespeare.lit' id='config0' type='get'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#configuration'>" + "<version>abcdefg</version>" + "</query>" + "</iq>";
|
||||
|
||||
String getConfigsResponseExample = "<iq from='coven@muclight.shakespeare.lit' id='getconfig1' "
|
||||
private static final String getConfigsResponseExample = "<iq from='coven@muclight.shakespeare.lit' id='getconfig1' "
|
||||
+ "to='crone1@shakespeare.lit/desktop' type='result'>" + "<query xmlns='urn:xmpp:muclight:0#configuration'>"
|
||||
+ "<version>123456</version>" + "<roomname>A Dark Cave</roomname>" + "<subject>A subject</subject>"
|
||||
+ "</query>" + "</iq>";
|
||||
|
||||
String getConfigsResponseExampleWithCustomConfigs = "<iq from='coven@muclight.shakespeare.lit' id='getconfig2' "
|
||||
private static final String getConfigsResponseExampleWithCustomConfigs = "<iq from='coven@muclight.shakespeare.lit' id='getconfig2' "
|
||||
+ "to='crone1@shakespeare.lit/desktop' type='result'>" + "<query xmlns='urn:xmpp:muclight:0#configuration'>"
|
||||
+ "<version>123456</version>" + "<roomname>A Dark Cave</roomname>" + "<color>blue</color>"
|
||||
+ "<size>20</size>" + "</query>" + "</iq>";
|
||||
|
@ -53,7 +53,7 @@ public class MUCLightGetConfigsTest {
|
|||
|
||||
@Test
|
||||
public void checkGetConfigsResponse() throws Exception {
|
||||
IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getConfigsResponseExample);
|
||||
IQ iqInfoResult = PacketParserUtils.parseStanza(getConfigsResponseExample);
|
||||
MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) iqInfoResult;
|
||||
|
||||
Assert.assertEquals("123456", mucLightConfigurationIQ.getVersion());
|
||||
|
@ -64,7 +64,7 @@ public class MUCLightGetConfigsTest {
|
|||
|
||||
@Test
|
||||
public void checkGetConfigsResponseWithCustomConfigs() throws Exception {
|
||||
IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getConfigsResponseExampleWithCustomConfigs);
|
||||
IQ iqInfoResult = PacketParserUtils.parseStanza(getConfigsResponseExampleWithCustomConfigs);
|
||||
MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) iqInfoResult;
|
||||
|
||||
Assert.assertEquals("123456", mucLightConfigurationIQ.getVersion());
|
||||
|
|
|
@ -28,13 +28,13 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightInfoTest {
|
||||
|
||||
String exampleWithVersion = "<iq to='coven@muclight.shakespeare.lit' id='getinfo1' type='get'>"
|
||||
private static final String exampleWithVersion = "<iq to='coven@muclight.shakespeare.lit' id='getinfo1' type='get'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#info'>" + "<version>abcdefg</version>" + "</query>" + "</iq>";
|
||||
|
||||
String exampleWithoutVersion = "<iq to='coven@muclight.shakespeare.lit' id='getinfo1' type='get'>"
|
||||
private static final String exampleWithoutVersion = "<iq to='coven@muclight.shakespeare.lit' id='getinfo1' type='get'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#info'>" + "</query>" + "</iq>";
|
||||
|
||||
String exampleInfoResult = "<iq from='coven@muclight.shakespeare.lit' to='cronel@shakespeare.lit/desktop' id='getinfo1' type='result'>"
|
||||
private static final String exampleInfoResult = "<iq from='coven@muclight.shakespeare.lit' to='cronel@shakespeare.lit/desktop' id='getinfo1' type='result'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#info'>" + "<version>123456</version>" + "<configuration>"
|
||||
+ "<roomname>test</roomname>" + "</configuration>" + "<occupants>"
|
||||
+ "<user affiliation='owner'>john@test.com</user>" + "<user affiliation='member'>charlie@test.com</user>"
|
||||
|
@ -58,7 +58,7 @@ public class MUCLightInfoTest {
|
|||
|
||||
@Test
|
||||
public void checkMUCLightInfoResult() throws Exception {
|
||||
IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(exampleInfoResult);
|
||||
IQ iqInfoResult = PacketParserUtils.parseStanza(exampleInfoResult);
|
||||
MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) iqInfoResult;
|
||||
Assert.assertEquals(mucLightInfoResponseIQ.getVersion(), "123456");
|
||||
Assert.assertEquals(mucLightInfoResponseIQ.getConfiguration().getRoomName(), "test");
|
||||
|
|
|
@ -26,15 +26,15 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class MUCLightSetConfigsIQTest {
|
||||
|
||||
String setConfigsIQExample = "<iq to='coven@muclight.shakespeare.lit' id='conf1' type='set'>"
|
||||
private static final String setConfigsIQExample = "<iq to='coven@muclight.shakespeare.lit' id='conf1' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#configuration'>" + "<roomname>A Darker Cave</roomname>"
|
||||
+ "<color>blue</color>" + "</query>" + "</iq>";
|
||||
|
||||
String changeRoomNameIQExample = "<iq to='coven@muclight.shakespeare.lit' id='roomName1' type='set'>"
|
||||
private static final String changeRoomNameIQExample = "<iq to='coven@muclight.shakespeare.lit' id='roomName1' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#configuration'>" + "<roomname>A Darker Cave</roomname>" + "</query>"
|
||||
+ "</iq>";
|
||||
|
||||
String changeSubjectIQExample = "<iq to='coven@muclight.shakespeare.lit' id='subject1' type='set'>"
|
||||
private static final String changeSubjectIQExample = "<iq to='coven@muclight.shakespeare.lit' id='subject1' type='set'>"
|
||||
+ "<query xmlns='urn:xmpp:muclight:0#configuration'>" + "<subject>To be or not to be?</subject>"
|
||||
+ "</query>" + "</iq>";
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class DisablePushNotificationsIQTest {
|
||||
|
||||
String disableAllNotificationsIQExample = "<iq id='x97' type='set'>"
|
||||
private static final String disableAllNotificationsIQExample = "<iq id='x97' type='set'>"
|
||||
+ "<disable xmlns='urn:xmpp:push:0' jid='push-5.client.example'>" + "</disable>" + "</iq>";
|
||||
|
||||
String disableNodeNotificationsIQExample = "<iq id='x97' type='set'>"
|
||||
private static final String disableNodeNotificationsIQExample = "<iq id='x97' type='set'>"
|
||||
+ "<disable xmlns='urn:xmpp:push:0' jid='push-5.client.example' node='yxs32uqsflafdk3iuqo'>" + "</disable>"
|
||||
+ "</iq>";
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class EnablePushNotificationsIQTest {
|
||||
|
||||
String exampleEnableIQ = "<iq id='x42' type='set'>"
|
||||
private static final String exampleEnableIQ = "<iq id='x42' type='set'>"
|
||||
+ "<enable xmlns='urn:xmpp:push:0' jid='push-5.client.example' node='yxs32uqsflafdk3iuqo'>" + "</enable>"
|
||||
+ "</iq>";
|
||||
|
||||
String exampleEnableIQWithPublishOptions = "<iq id='x42' type='set'>"
|
||||
private static final String exampleEnableIQWithPublishOptions = "<iq id='x42' type='set'>"
|
||||
+ "<enable xmlns='urn:xmpp:push:0' jid='push-5.client.example' node='yxs32uqsflafdk3iuqo'>"
|
||||
+ "<x xmlns='jabber:x:data' type='submit'>"
|
||||
+ "<field var='FORM_TYPE'><value>http://jabber.org/protocol/pubsub#publish-options</value></field>"
|
||||
|
|
|
@ -27,24 +27,24 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class RemoteDisablingPushNotificationsTest {
|
||||
|
||||
String remoteDisablingExample = "<message from='push-5.client.example' to='user@example.com'>"
|
||||
private static final String remoteDisablingExample = "<message from='push-5.client.example' to='user@example.com'>"
|
||||
+ "<pubsub xmlns='http://jabber.org/protocol/pubsub' node='yxs32uqsflafdk3iuqo'>"
|
||||
+ "<affiliation jid='user@example.com' affiliation='none' />" + "</pubsub>" + "</message>";
|
||||
|
||||
String wrongRemoteDisabling1 = "<message from='push-5.client.example' to='user@example.com'>"
|
||||
private static final String wrongRemoteDisabling1 = "<message from='push-5.client.example' to='user@example.com'>"
|
||||
+ "<pubsub xmlns='http://jabber.org/protocol/pubsub' node='yxs32uqsflafdk3iuqo'>"
|
||||
+ "<affiliation jid='user@example.com'/>" + "</pubsub>" + "</message>";
|
||||
|
||||
String wrongRemoteDisabling2 = "<message from='push-5.client.example' to='user@example.com'>"
|
||||
private static final String wrongRemoteDisabling2 = "<message from='push-5.client.example' to='user@example.com'>"
|
||||
+ "<pubsub xmlns='http://jabber.org/protocol/pubsub' node='yxs32uqsflafdk3iuqo'>"
|
||||
+ "<affiliation jid='user@example.com' affiliation='member' />" + "</pubsub>" + "</message>";
|
||||
|
||||
String wrongRemoteDisabling3 = "<message from='push-5.client.example' to='user@example.com'>"
|
||||
private static final String wrongRemoteDisabling3 = "<message from='push-5.client.example' to='user@example.com'>"
|
||||
+ "<pubsub xmlns='http://jabber.org/protocol/pubsub'>" + "</pubsub>" + "</message>";
|
||||
|
||||
@Test
|
||||
public void checkRemoteDisablingPushNotificationsParse() throws Exception {
|
||||
Message message = (Message) PacketParserUtils.parseStanza(remoteDisablingExample);
|
||||
Message message = PacketParserUtils.parseStanza(remoteDisablingExample);
|
||||
RemoteDisablingExtension remoteDisablingExtension = RemoteDisablingExtension.from(message);
|
||||
|
||||
Assert.assertEquals("yxs32uqsflafdk3iuqo", remoteDisablingExtension.getNode());
|
||||
|
@ -53,15 +53,15 @@ public class RemoteDisablingPushNotificationsTest {
|
|||
|
||||
@Test
|
||||
public void checkWrongRemoteDisablighPushNotifications() throws Exception {
|
||||
Message message1 = (Message) PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
Message message1 = PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
RemoteDisablingExtension remoteDisablingExtension1 = RemoteDisablingExtension.from(message1);
|
||||
Assert.assertNull(remoteDisablingExtension1);
|
||||
|
||||
Message message2 = (Message) PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
Message message2 = PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
RemoteDisablingExtension remoteDisablingExtension2 = RemoteDisablingExtension.from(message2);
|
||||
Assert.assertNull(remoteDisablingExtension2);
|
||||
|
||||
Message message3 = (Message) PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
Message message3 = PacketParserUtils.parseStanza(wrongRemoteDisabling1);
|
||||
RemoteDisablingExtension remoteDisablingExtension3 = RemoteDisablingExtension.from(message3);
|
||||
Assert.assertNull(remoteDisablingExtension3);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue