mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-07 13:41:08 +01: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
|
|
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.blocking;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
|
|
@ -42,7 +41,7 @@ public class GetBlockingListTest {
|
|||
@Test
|
||||
public void checkGetBlockingListIQStanza() throws Exception {
|
||||
BlockListIQ getBlockListIQ = new BlockListIQ(null);
|
||||
getBlockListIQ.setType(Type.get);
|
||||
getBlockListIQ.setType(IQ.Type.get);
|
||||
getBlockListIQ.setStanzaId("blocklist1");
|
||||
assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
|
@ -46,7 +46,7 @@ public class BoBIQTest extends SmackTestSuite {
|
|||
BoBIQ createdBoBIQ = new BoBIQ(bobHash);
|
||||
createdBoBIQ.setStanzaId("sarasa");
|
||||
createdBoBIQ.setTo(JidCreate.from("ladymacbeth@shakespeare.lit/castle"));
|
||||
createdBoBIQ.setType(Type.get);
|
||||
createdBoBIQ.setType(IQ.Type.get);
|
||||
|
||||
assertEquals(sampleBoBIQRequest, createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ public class BoBIQTest extends SmackTestSuite {
|
|||
BoBIQ createdBoBIQ = new BoBIQ(bobHash, bobData);
|
||||
createdBoBIQ.setStanzaId("sarasa");
|
||||
createdBoBIQ.setTo(JidCreate.from("doctor@shakespeare.lit/pda"));
|
||||
createdBoBIQ.setType(Type.result);
|
||||
createdBoBIQ.setType(IQ.Type.result);
|
||||
|
||||
assertEquals(bobIQ.getContentId().getHash(), createdBoBIQ.getContentId().getHash());
|
||||
assertEquals(bobIQ.getContentId().getHashType(), createdBoBIQ.getContentId().getHashType());
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ public class PingTest extends SmackTestSuite {
|
|||
/**
|
||||
* The returned connection won't send replies to IQs
|
||||
*
|
||||
* @return
|
||||
* @return a dummy connection.
|
||||
* @throws XMPPException if an XMPP protocol error was received.
|
||||
* @throws IOException if an I/O error occurred.
|
||||
* @throws SmackException if Smack detected an exceptional situation.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2020 Florian Schmaus
|
||||
* Copyright 2017-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 java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smackx.pubsub.Affiliation.Type;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -35,7 +34,7 @@ public class AffiliationsExtensionTest {
|
|||
@Test
|
||||
public void testAffiliationsExtensionToXml() throws SAXException, IOException {
|
||||
BareJid affiliatedJid = JidTestUtil.BARE_JID_1;
|
||||
Affiliation affiliation = new Affiliation(affiliatedJid, Type.member);
|
||||
Affiliation affiliation = new Affiliation(affiliatedJid, Affiliation.Type.member);
|
||||
List<Affiliation> affiliationsList = new ArrayList<>();
|
||||
affiliationsList.add(affiliation);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import org.jivesoftware.smack.ThreadedDummyConnection;
|
|||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
|
@ -63,7 +62,7 @@ public class ConfigureFormTest extends SmackTestSuite {
|
|||
Node node = mgr.getNode("princely_musings");
|
||||
|
||||
PubSub errorIq = new PubSub();
|
||||
errorIq.setType(Type.error);
|
||||
errorIq.setType(IQ.Type.error);
|
||||
errorIq.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
|
||||
StanzaError error = StanzaError.getBuilder(Condition.forbidden).build();
|
||||
errorIq.setError(error);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2018 Timothy Pitt, Florian Schmaus
|
||||
* Copyright 2018 Timothy Pitt, 2018-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.
|
||||
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.ThreadedDummyConnection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
|
@ -89,7 +89,7 @@ public class PubSubNodeTest extends SmackTestSuite {
|
|||
new Affiliation(JidTestUtil.BARE_JID_2, Affiliation.Type.publisher)
|
||||
);
|
||||
AffiliationsExtension affiliationsExtension = new AffiliationsExtension(AffiliationNamespace.owner, affiliations);
|
||||
PubSub response = new PubSub(JidTestUtil.PUBSUB_EXAMPLE_ORG, Type.result, PubSubNamespace.owner);
|
||||
PubSub response = new PubSub(JidTestUtil.PUBSUB_EXAMPLE_ORG, IQ.Type.result, PubSubNamespace.owner);
|
||||
response.addExtension(affiliationsExtension);
|
||||
protocol.addResponse(response);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
|
|||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.TextSingleFormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -85,21 +84,21 @@ public class SoftwareInfoFormTest extends SmackTestSuite {
|
|||
|
||||
@Test
|
||||
public void faultySoftwareInfoFormsTest() {
|
||||
DataForm.Builder dataFormbuilder = DataForm.builder(Type.result);
|
||||
DataForm.Builder dataFormbuilder = DataForm.builder(DataForm.Type.result);
|
||||
TextSingleFormField formField = FormField.buildHiddenFormType("faulty_formtype");
|
||||
dataFormbuilder.addField(formField);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
SoftwareInfoForm.getBuilder().setDataForm(dataFormbuilder.build()).build();
|
||||
});
|
||||
|
||||
DataForm.Builder builderWithoutFormType = DataForm.builder(Type.result);
|
||||
DataForm.Builder builderWithoutFormType = DataForm.builder(DataForm.Type.result);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
SoftwareInfoForm.getBuilder().setDataForm(builderWithoutFormType.build()).build();
|
||||
});
|
||||
}
|
||||
|
||||
public static SoftwareInfoForm createSoftwareInfoFormUsingDataForm() throws URISyntaxException {
|
||||
DataForm.Builder dataFormBuilder = DataForm.builder(Type.result);
|
||||
DataForm.Builder dataFormBuilder = DataForm.builder(DataForm.Type.result);
|
||||
TextSingleFormField formField = FormField.buildHiddenFormType(SoftwareInfoForm.FORM_TYPE);
|
||||
dataFormBuilder.addField(formField);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.jivesoftware.smackx.mediaelement.element.MediaElement;
|
|||
import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
|
||||
|
||||
import org.jivesoftware.util.ConnectionUtils;
|
||||
import org.jivesoftware.util.Protocol;
|
||||
|
|
@ -70,7 +69,7 @@ public class SoftwareInfoManagerTest {
|
|||
}
|
||||
|
||||
public static SoftwareInfoForm buildSoftwareInfoFromDataForm() throws URISyntaxException {
|
||||
DataForm.Builder dataFormBuilder = DataForm.builder(Type.result);
|
||||
DataForm.Builder dataFormBuilder = DataForm.builder(DataForm.Type.result);
|
||||
dataFormBuilder.addField(FormField.buildHiddenFormType(SoftwareInfoForm.FORM_TYPE));
|
||||
dataFormBuilder.addField(FormField.builder("icon")
|
||||
.addFormFieldChildElement(createMediaElement())
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.FormField.Type;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout;
|
||||
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref;
|
||||
|
|
@ -151,6 +150,6 @@ public class DataFormTest extends SmackTestSuite {
|
|||
public void testFixedField() throws Exception {
|
||||
final String formWithFixedField = "<x xmlns='jabber:x:data' type='form'><instructions>InstructionTest1</instructions><field type='fixed'><value>Fixed field value</value></field></x>";
|
||||
DataForm df = pr.parse(PacketParserUtils.getParserFor(formWithFixedField));
|
||||
assertEquals(Type.fixed, df.getFields().get(0).getType());
|
||||
assertEquals(FormField.Type.fixed, df.getFields().get(0).getType());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.provider.AbstractProvider;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
|
@ -145,7 +146,7 @@ public class DataValidationTest extends SmackTestSuite {
|
|||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void testRangeFailure(SmackTestUtil.XmlPullParserKind parserKind) throws IOException, XmlPullParserException {
|
||||
assertThrows(NumberFormatException.class,
|
||||
assertThrows(AbstractProvider.NumberFormatParseException.class,
|
||||
() -> SmackTestUtil.parse(TEST_OUTPUT_FAIL, DataValidationProvider.class, parserKind));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue