mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 18:29:45 +02:00
Bump ErrorProne to 2.5.1 and refactor Providers a bit
This also resulted in a refactoring of the Providers and parsing Exceptions. NumberFormatException and ParseException can now be thrown directly, the wrapping in a SmackParsingException is down at a higher layer, i.e. in AbstractProvider.
This commit is contained in:
parent
1df0763f92
commit
a7b3303f3e
136 changed files with 574 additions and 551 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2013-2014 Georg Lukas, 2020 Florian Schmaus.
|
||||
* Copyright 2013-2014 Georg Lukas, 2020-2021 Florian Schmaus.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.carbons.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
|
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
|
|||
public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtension> {
|
||||
|
||||
@Override
|
||||
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
Direction dir = Direction.valueOf(parser.getName());
|
||||
Forwarded<Message> fwd = null;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
* Copyright 2019-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -31,7 +31,6 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
||||
import org.jivesoftware.smack.packet.StanzaError.Type;
|
||||
import org.jivesoftware.smack.util.RandomUtil;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
@ -89,7 +88,7 @@ public final class DnsOverXmppManager extends Manager {
|
|||
response = resolver.resolve(query);
|
||||
} catch (IOException exception) {
|
||||
StanzaError errorBuilder = StanzaError.getBuilder()
|
||||
.setType(Type.CANCEL)
|
||||
.setType(StanzaError.Type.CANCEL)
|
||||
.setCondition(Condition.internal_server_error)
|
||||
.setDescriptiveEnText("Exception while resolving your DNS query", exception)
|
||||
.build()
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.net.HttpURLConnection;
|
|||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.logging.Level;
|
||||
|
@ -437,7 +436,7 @@ public final class HttpFileUploadManager extends Manager {
|
|||
urlConnection.setDoOutput(true);
|
||||
urlConnection.setFixedLengthStreamingMode(fileSize);
|
||||
urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
|
||||
for (Entry<String, String> header : slot.getHeaders().entrySet()) {
|
||||
for (Map.Entry<String, String> header : slot.getHeaders().entrySet()) {
|
||||
urlConnection.setRequestProperty(header.getKey(), header.getValue());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2016 Florian Schmaus
|
||||
* Copyright 2016-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,7 +22,6 @@ import org.jivesoftware.smack.Manager;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
|
||||
import org.jivesoftware.smackx.iot.provisioning.IoTProvisioningManager;
|
||||
|
||||
|
@ -70,7 +69,7 @@ public abstract class IoTManager extends Manager {
|
|||
|
||||
protected abstract class IoTIqRequestHandler extends AbstractIqRequestHandler {
|
||||
|
||||
protected IoTIqRequestHandler(String element, String namespace, Type type, Mode mode) {
|
||||
protected IoTIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
|
||||
super(element, namespace, type, mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Iterator;
|
|||
import org.jivesoftware.smackx.iot.control.ThingControlRequest;
|
||||
import org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest;
|
||||
import org.jivesoftware.smackx.iot.discovery.element.Tag;
|
||||
import org.jivesoftware.smackx.iot.discovery.element.Tag.Type;
|
||||
import org.jivesoftware.smackx.iot.element.NodeInfo;
|
||||
|
||||
public final class Thing {
|
||||
|
@ -112,35 +111,35 @@ public final class Thing {
|
|||
|
||||
public Builder setSerialNumber(String sn) {
|
||||
final String name = "SN";
|
||||
Tag tag = new Tag(name, Type.str, sn);
|
||||
Tag tag = new Tag(name, Tag.Type.str, sn);
|
||||
metaTags.put(name, tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setKey(String key) {
|
||||
final String name = "KEY";
|
||||
Tag tag = new Tag(name, Type.str, key);
|
||||
Tag tag = new Tag(name, Tag.Type.str, key);
|
||||
metaTags.put(name, tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setManufacturer(String manufacturer) {
|
||||
final String name = "MAN";
|
||||
Tag tag = new Tag(name, Type.str, manufacturer);
|
||||
Tag tag = new Tag(name, Tag.Type.str, manufacturer);
|
||||
metaTags.put(name, tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setModel(String model) {
|
||||
final String name = "MODEL";
|
||||
Tag tag = new Tag(name, Type.str, model);
|
||||
Tag tag = new Tag(name, Tag.Type.str, model);
|
||||
metaTags.put(name, tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setVersion(String version) {
|
||||
final String name = "V";
|
||||
Tag tag = new Tag(name, Type.num, version);
|
||||
Tag tag = new Tag(name, Tag.Type.num, version);
|
||||
metaTags.put(name, tag);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016-2019 Florian Schmaus
|
||||
* Copyright © 2016-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,8 +24,6 @@ import java.util.List;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
@ -45,7 +43,8 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
|
|||
private static final Logger LOGGER = Logger.getLogger(IoTFieldsExtensionProvider.class.getName());
|
||||
|
||||
@Override
|
||||
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackTextParseException {
|
||||
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws IOException, XmlPullParserException, ParseException {
|
||||
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number");
|
||||
boolean done = ParserUtils.getBooleanAttribute(parser, "done", false);
|
||||
List<NodeElement> nodes = new ArrayList<>();
|
||||
|
@ -74,7 +73,7 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
|
|||
return new IoTFieldsExtension(seqNr, done, nodes);
|
||||
}
|
||||
|
||||
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
|
||||
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
|
||||
final int initialDepth = parser.getDepth();
|
||||
final NodeInfo nodeInfo = NodeInfoParser.parse(parser);
|
||||
List<TimestampElement> timestampElements = new ArrayList<>();
|
||||
|
@ -103,15 +102,11 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
|
|||
return new NodeElement(nodeInfo, timestampElements);
|
||||
}
|
||||
|
||||
public TimestampElement parseTimestampElement(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
|
||||
public TimestampElement parseTimestampElement(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, ParseException {
|
||||
final int initialDepth = parser.getDepth();
|
||||
final String dateString = parser.getAttributeValue(null, "value");
|
||||
Date date;
|
||||
try {
|
||||
date = XmppDateTime.parseDate(dateString);
|
||||
} catch (ParseException e) {
|
||||
throw new SmackParsingException.SmackTextParseException(e);
|
||||
}
|
||||
Date date = XmppDateTime.parseDate(dateString);
|
||||
List<IoTDataField> fields = new ArrayList<>();
|
||||
outerloop: while (true) {
|
||||
final XmlPullParser.Event eventType = parser.next();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2016-2019 Florian Schmaus
|
||||
* Copyright 2016-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,7 +39,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
|||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -201,7 +200,7 @@ public final class IoTProvisioningManager extends Manager {
|
|||
}, FRIEND_MESSAGE);
|
||||
|
||||
connection.registerIQRequestHandler(
|
||||
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, Type.set, Mode.async) {
|
||||
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, IQ.Type.set, Mode.async) {
|
||||
@Override
|
||||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
if (!isFromProvisioningService(iqRequest, true)) {
|
||||
|
|
|
@ -44,7 +44,7 @@ public class JingleFileTransferProvider
|
|||
extends JingleContentDescriptionProvider<JingleFileTransfer> {
|
||||
|
||||
@Override
|
||||
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
|
||||
JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder();
|
||||
|
||||
|
@ -59,11 +59,7 @@ public class JingleFileTransferProvider
|
|||
elementName = parser.getName();
|
||||
switch (elementName) {
|
||||
case JingleFileTransferChild.ELEM_DATE:
|
||||
try {
|
||||
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
|
||||
} catch (ParseException e) {
|
||||
throw new SmackParsingException.SmackTextParseException(e);
|
||||
}
|
||||
break;
|
||||
|
||||
case JingleFileTransferChild.ELEM_DESC:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2016 Fernando Ramirez, 2020 Florian Schmaus
|
||||
* Copyright 2016 Fernando Ramirez, 2020-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.mam.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
|
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension;
|
|||
public class MamResultProvider extends ExtensionElementProvider<MamResultExtension> {
|
||||
|
||||
@Override
|
||||
public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||
public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
Forwarded<Message> forwarded = null;
|
||||
String queryId = parser.getAttributeValue("", "queryid");
|
||||
String id = parser.getAttributeValue("", "id");
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.message_retraction.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
|
@ -34,7 +35,7 @@ public class RetractedElementProvider extends ExtensionElementProvider<Retracted
|
|||
|
||||
@Override
|
||||
public RetractedElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
Date date = ParserUtils.getDateFromXep82String(parser.getAttributeValue("", RetractedElement.ATTR_STAMP));
|
||||
|
||||
OriginIdElement originIdElement = null;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.filter.IQReplyFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
|
@ -228,7 +227,7 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
private MUCLightBlockingIQ getBlockingList(DomainBareJid mucLightService)
|
||||
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null);
|
||||
mucLightBlockingIQ.setType(Type.get);
|
||||
mucLightBlockingIQ.setType(IQ.Type.get);
|
||||
mucLightBlockingIQ.setTo(mucLightService);
|
||||
|
||||
StanzaFilter responseFilter = new IQReplyFilter(mucLightBlockingIQ, connection());
|
||||
|
@ -278,7 +277,7 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
private void sendBlockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms)
|
||||
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
|
||||
mucLightBlockingIQ.setType(Type.set);
|
||||
mucLightBlockingIQ.setType(IQ.Type.set);
|
||||
mucLightBlockingIQ.setTo(mucLightService);
|
||||
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
|
||||
}
|
||||
|
@ -322,7 +321,7 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
private void sendBlockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users)
|
||||
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
|
||||
mucLightBlockingIQ.setType(Type.set);
|
||||
mucLightBlockingIQ.setType(IQ.Type.set);
|
||||
mucLightBlockingIQ.setTo(mucLightService);
|
||||
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
|
||||
}
|
||||
|
@ -366,7 +365,7 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
private void sendUnblockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms)
|
||||
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
|
||||
mucLightBlockingIQ.setType(Type.set);
|
||||
mucLightBlockingIQ.setType(IQ.Type.set);
|
||||
mucLightBlockingIQ.setTo(mucLightService);
|
||||
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
|
||||
}
|
||||
|
@ -410,7 +409,7 @@ public final class MultiUserChatLightManager extends Manager {
|
|||
private void sendUnblockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users)
|
||||
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
|
||||
mucLightBlockingIQ.setType(Type.set);
|
||||
mucLightBlockingIQ.setType(IQ.Type.set);
|
||||
mucLightBlockingIQ.setTo(mucLightService);
|
||||
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.muclight.provider;
|
|||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
@ -65,7 +65,7 @@ public class MUCLightBlockingIQProvider extends IQProvider<MUCLightBlockingIQ> {
|
|||
}
|
||||
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
|
||||
mucLightBlockingIQ.setType(Type.result);
|
||||
mucLightBlockingIQ.setType(IQ.Type.result);
|
||||
return mucLightBlockingIQ;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.jivesoftware.smack.XMPPConnection;
|
|||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.push_notifications.element.DisablePushNotificationsIQ;
|
||||
|
@ -166,7 +165,7 @@ public final class PushNotificationsManager extends Manager {
|
|||
throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
|
||||
final XMPPConnection connection = connection();
|
||||
IQ responseIQ = connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
|
||||
return responseIQ.getType() != Type.error;
|
||||
return responseIQ.getType() != IQ.Type.error;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.stanza_content_encryption.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
@ -42,7 +43,7 @@ public class ContentElementProvider extends ExtensionElementProvider<ContentElem
|
|||
|
||||
@Override
|
||||
public ContentElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
throws XmlPullParserException, IOException, ParseException, SmackParsingException {
|
||||
ContentElement.Builder builder = ContentElement.builder();
|
||||
|
||||
while (true) {
|
||||
|
@ -117,7 +118,7 @@ public class ContentElementProvider extends ExtensionElementProvider<ContentElem
|
|||
}
|
||||
|
||||
private static void parseTimestampAffix(XmlPullParser parser, ContentElement.Builder builder)
|
||||
throws SmackParsingException.SmackTextParseException {
|
||||
throws ParseException {
|
||||
Date timestamp = ParserUtils.getDateFromXep82String(
|
||||
parser.getAttributeValue("", TimestampAffixElement.ATTR_STAMP));
|
||||
builder.setTimestamp(timestamp);
|
||||
|
|
|
@ -22,7 +22,6 @@ 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;
|
||||
|
||||
|
@ -68,7 +67,7 @@ public class MamFinProviderTest extends MamTest {
|
|||
IQ iq = PacketParserUtils.parseStanza(IQ_LIMITED_RESULTS_EXAMPLE);
|
||||
|
||||
MamFinIQ mamFinIQ = (MamFinIQ) iq;
|
||||
assertEquals(mamFinIQ.getType(), Type.result);
|
||||
assertEquals(mamFinIQ.getType(), IQ.Type.result);
|
||||
|
||||
assertTrue(mamFinIQ.isComplete());
|
||||
assertEquals(mamFinIQ.getRSMSet().getCount(), 16);
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
||||
|
@ -57,7 +56,7 @@ public class MamQueryIQProviderTest {
|
|||
IQ iq1 = PacketParserUtils.parseStanza(exampleMamQueryIQ1);
|
||||
MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1;
|
||||
|
||||
assertEquals(mamQueryIQ1.getType(), Type.set);
|
||||
assertEquals(mamQueryIQ1.getType(), IQ.Type.set);
|
||||
assertEquals(mamQueryIQ1.getQueryId(), "test");
|
||||
|
||||
DataForm dataForm1 = (DataForm) mamQueryIQ1.getExtension(DataForm.NAMESPACE);
|
||||
|
@ -73,7 +72,7 @@ public class MamQueryIQProviderTest {
|
|||
IQ iq2 = PacketParserUtils.parseStanza(exampleMamQueryIQ2);
|
||||
MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2;
|
||||
|
||||
assertEquals(mamQueryIQ2.getType(), Type.result);
|
||||
assertEquals(mamQueryIQ2.getType(), IQ.Type.result);
|
||||
assertNull(mamQueryIQ2.getQueryId());
|
||||
|
||||
DataForm dataForm2 = (DataForm) mamQueryIQ2.getExtension(DataForm.NAMESPACE);
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.TimeZone;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Message.Type;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
|
||||
|
@ -75,7 +74,7 @@ public class QueryArchiveTest extends MamTest {
|
|||
DelayInformation delay = new DelayInformation(date);
|
||||
Message forwardedMessage = StanzaBuilder.buildMessage("162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2")
|
||||
.from(JidCreate.from("coven@chat.shakespeare.lit/firstwitch"))
|
||||
.ofType(Type.chat)
|
||||
.ofType(Message.Type.chat)
|
||||
.setBody("Thrice the brinded cat hath mew.")
|
||||
.build();
|
||||
|
||||
|
@ -93,7 +92,7 @@ public class QueryArchiveTest extends MamTest {
|
|||
Message resultMessage = mamResultExtension.getForwarded().getForwardedStanza();
|
||||
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.getType(), Message.Type.chat);
|
||||
assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew.");
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
|
@ -59,7 +58,7 @@ public class MUCLightBlockingTest {
|
|||
@Test
|
||||
public void checkGetBlockingListIQ() throws Exception {
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null);
|
||||
mucLightBlockingIQ.setType(Type.get);
|
||||
mucLightBlockingIQ.setType(IQ.Type.get);
|
||||
mucLightBlockingIQ.setStanzaId("getblock1");
|
||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||
|
||||
|
@ -86,7 +85,7 @@ public class MUCLightBlockingTest {
|
|||
rooms.put(JidCreate.from("chapel@shakespeare.lit"), false);
|
||||
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
|
||||
mucLightBlockingIQ.setType(Type.set);
|
||||
mucLightBlockingIQ.setType(IQ.Type.set);
|
||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||
mucLightBlockingIQ.setStanzaId("block1");
|
||||
|
||||
|
@ -100,7 +99,7 @@ public class MUCLightBlockingTest {
|
|||
users.put(JidCreate.from("hag66@shakespeare.lit"), false);
|
||||
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
|
||||
mucLightBlockingIQ.setType(Type.set);
|
||||
mucLightBlockingIQ.setType(IQ.Type.set);
|
||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||
mucLightBlockingIQ.setStanzaId("block2");
|
||||
|
||||
|
@ -116,7 +115,7 @@ public class MUCLightBlockingTest {
|
|||
rooms.put(JidCreate.from("coven@muclight.shakespeare.lit"), true);
|
||||
|
||||
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
|
||||
mucLightBlockingIQ.setType(Type.set);
|
||||
mucLightBlockingIQ.setType(IQ.Type.set);
|
||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||
mucLightBlockingIQ.setStanzaId("unblock1");
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.StandardExtensionElement;
|
||||
|
@ -40,7 +41,7 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
public class ContentElementProviderTest {
|
||||
|
||||
@Test
|
||||
public void testParsing() throws XmlPullParserException, IOException, SmackParsingException {
|
||||
public void testParsing() throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||
String xml = "" +
|
||||
"<content xmlns='urn:xmpp:sce:0'>\n" +
|
||||
" <payload>\n" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue