1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-21 22:02:06 +01:00

Bump errorprone to 2.2.0

This commit is contained in:
Florian Schmaus 2018-03-28 15:56:04 +02:00
parent 214218c49b
commit 3132d9a224
17 changed files with 59 additions and 87 deletions

View file

@ -10,7 +10,7 @@ buildscript {
classpath 'org.kordamp:markdown-gradle-plugin:1.0.0' classpath 'org.kordamp:markdown-gradle-plugin:1.0.0'
classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.2.2' classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.2.2'
classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.3.1" classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.3.1"
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.10' classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
} }
} }
@ -160,7 +160,15 @@ allprojects {
'-Xlint:-path', '-Xlint:-path',
// Disable errorprone checks // Disable errorprone checks
'-Xep:TypeParameterUnusedInFormals:OFF', '-Xep:TypeParameterUnusedInFormals:OFF',
'-Xep:TopLevel:OFF', // Disable errorpone StringSplitter check, as it
// recommends using Splitter from Guava, which we don't
// have (nor want to use in Smack).
'-Xep:StringSplitter:OFF',
'-Xep:JdkObsolete:OFF',
// Disabled because sinttest re-uses BeforeClass from junit.
// TODO: change sinttest so that it has it's own
// BeforeClass and re-enable this check.
'-Xep:JUnit4ClassAnnotationNonStatic:OFF',
] ]
} }
@ -191,11 +199,8 @@ allprojects {
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }
// Pin the errorprone version to prevent "unsupported major.minor dependencies {
// version 52.0" error messages caused by the errorprone javac. errorprone 'com.google.errorprone:error_prone_core:2.2.0'
// See https://github.com/tbroyer/gradle-errorprone-plugin/issues/18 for more information.
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.18'
} }
// Make all project's 'test' target depend on javadoc, so that // Make all project's 'test' target depend on javadoc, so that

View file

@ -88,6 +88,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
/** /**
* Holds the initial configuration used while creating the connection. * Holds the initial configuration used while creating the connection.
*/ */
@SuppressWarnings("HidingField")
private final BOSHConfiguration config; private final BOSHConfiguration config;
// Some flags which provides some info about the current state. // Some flags which provides some info about the current state.

View file

@ -18,20 +18,18 @@ package org.jivesoftware.smack;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
public class SmackConfigurationTest { public class SmackConfigurationTest {
/**
* Test is Smack is able to initialize itself without throwing a Throwable.
*/
@Test @Test
public void testSmackConfiguration() { public void testSmackConfiguration() {
try { SmackConfiguration.getDefaultReplyTimeout();
SmackConfiguration.getDefaultReplyTimeout();
} catch (Throwable t) {
fail("SmackConfiguration threw Throwable");
}
} }
// As there is currently no annotation/way to run a testclass/single test in a separate VM, // As there is currently no annotation/way to run a testclass/single test in a separate VM,

View file

@ -312,6 +312,7 @@ public abstract class FileTransfer {
return amountWritten; return amountWritten;
} }
@SuppressWarnings("JavaLangClash")
public enum Error { public enum Error {
/** /**
* No error. * No error.

View file

@ -160,7 +160,7 @@ public class InBandBytestreamManagerTest extends InitExtensions {
} }
@Test @Test
public void shouldUseConfiguredStanzaType() throws SmackException, InterruptedException { public void shouldUseConfiguredStanzaType() throws SmackException, InterruptedException, XMPPException {
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection); InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
byteStreamManager.setStanza(StanzaType.MESSAGE); byteStreamManager.setStanza(StanzaType.MESSAGE);
@ -173,14 +173,10 @@ public class InBandBytestreamManagerTest extends InitExtensions {
}); });
try { // start In-Band Bytestream
// start In-Band Bytestream byteStreamManager.establishSession(targetJID);
byteStreamManager.establishSession(targetJID);
}
catch (XMPPException e) {
protocol.verifyAll();
}
protocol.verifyAll();
} }
@Test @Test

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
@ -77,6 +78,7 @@ public class ConfigureFormTest extends InitExtensions
try try
{ {
node.getNodeConfiguration(); node.getNodeConfiguration();
fail();
} }
catch (XMPPErrorException e) catch (XMPPErrorException e)
{ {

View file

@ -67,12 +67,7 @@ public class DataValidationHelperTest {
} }
field.setType(FormField.Type.list_multi); field.setType(FormField.Type.list_multi);
try { element.checkConsistency(field);
element.checkConsistency(field);
}
catch (ValidationConsistencyException e) {
fail("No correct check on consistency");
}
} }

View file

@ -21,7 +21,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.jivesoftware.smack.DummyConnection; import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
@ -343,7 +342,7 @@ public class ChatConnectionTest {
try { try {
chatServer.join(); chatServer.join();
} catch (InterruptedException e) { } catch (InterruptedException e) {
fail(); throw new AssertionError(e);
} }
waitListener.waitAndReset(); waitListener.waitAndReset();
} }

View file

@ -683,9 +683,9 @@ public class RosterTest extends InitSmackIm {
connection.processStanza(response); connection.processStanza(response);
// Verify the roster update request // Verify the roster update request
assertSame("A roster set MUST contain one and only one <item/> element.", if (rosterRequest.getRosterItemCount() != 1) {
1, throw new AssertionError("A roster set MUST contain one and only one <item/> element.");
rosterRequest.getRosterItemCount()); }
verifyUpdateRequest(rosterRequest); verifyUpdateRequest(rosterRequest);
break; break;
} }

View file

@ -180,9 +180,9 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
connection.processStanza(response); connection.processStanza(response);
// Verify the roster update request // Verify the roster update request
assertSame("A roster set MUST contain one and only one <item/> element.", if (rosterRequest.getRosterItemCount() != 1) {
1, throw new AssertionError("A roster set MUST contain one and only one <item/> element.");
rosterRequest.getRosterItemCount()); }
verifyRosterUpdateRequest(rosterRequest); verifyRosterUpdateRequest(rosterRequest);
break; break;
} }

View file

@ -23,7 +23,6 @@ import static org.jivesoftware.smackx.omemo.OmemoIntegrationTestHelper.unidirect
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
@ -37,7 +36,6 @@ import org.jivesoftware.smackx.omemo.internal.OmemoMessageInformation;
import org.jivesoftware.smackx.omemo.listener.OmemoMessageListener; import org.jivesoftware.smackx.omemo.listener.OmemoMessageListener;
import org.jivesoftware.smackx.omemo.util.OmemoMessageBuilder; import org.jivesoftware.smackx.omemo.util.OmemoMessageBuilder;
import junit.framework.TestCase;
import org.igniterealtime.smack.inttest.SmackIntegrationTest; import org.igniterealtime.smack.inttest.SmackIntegrationTest;
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment; import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
import org.igniterealtime.smack.inttest.TestNotPossibleException; import org.igniterealtime.smack.inttest.TestNotPossibleException;
@ -97,11 +95,8 @@ public class OmemoKeyTransportTest extends AbstractOmemoIntegrationTest {
ChatManager.getInstanceFor(alice.getConnection()).chatWith(bob.getOwnJid().asEntityBareJidIfPossible()) ChatManager.getInstanceFor(alice.getConnection()).chatWith(bob.getOwnJid().asEntityBareJidIfPossible())
.send(message); .send(message);
try { // TODO: Should use 'timeout' field instead of hardcoded '10 * 1000'.
syncPoint.waitForResult(10 * 1000); syncPoint.waitForResult(10 * 1000);
} catch (TimeoutException e) {
TestCase.fail("We MUST have received the keyTransportMessage within 10 seconds.");
}
} }
@Override @Override

View file

@ -39,7 +39,7 @@ import org.xmlpull.v1.XmlPullParserException;
*/ */
public class AgentStatus implements ExtensionElement { public class AgentStatus implements ExtensionElement {
@SuppressWarnings("SimpleDateFormatConstant") @SuppressWarnings("DateFormatConstant")
private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
static { static {

View file

@ -41,7 +41,7 @@ import org.xmlpull.v1.XmlPullParserException;
*/ */
public class OccupantsInfo extends IQ { public class OccupantsInfo extends IQ {
@SuppressWarnings("SimpleDateFormatConstant") @SuppressWarnings("DateFormatConstant")
private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
static { static {

View file

@ -37,7 +37,7 @@ import org.jxmpp.jid.Jid;
*/ */
public class Transcripts extends IQ { public class Transcripts extends IQ {
@SuppressWarnings("SimpleDateFormatConstant") @SuppressWarnings("DateFormatConstant")
private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
static { static {
UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0")); UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));

View file

@ -39,7 +39,7 @@ import org.xmlpull.v1.XmlPullParserException;
*/ */
public class TranscriptsProvider extends IQProvider<Transcripts> { public class TranscriptsProvider extends IQProvider<Transcripts> {
@SuppressWarnings("SimpleDateFormatConstant") @SuppressWarnings("DateFormatConstant")
private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
static { static {
UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0")); UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));

View file

@ -24,7 +24,6 @@ import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertNotSame; import static junit.framework.TestCase.assertNotSame;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.fail;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -66,32 +65,24 @@ public class SignalOmemoKeyUtilTest extends SmackTestSuite {
} }
@Test @Test
public void omemoIdentityKeyPairSerializationTest() { public void omemoIdentityKeyPairSerializationTest() throws CorruptedOmemoKeyException {
IdentityKeyPair ikp = keyUtil.generateOmemoIdentityKeyPair(); IdentityKeyPair ikp = keyUtil.generateOmemoIdentityKeyPair();
byte[] bytes = keyUtil.identityKeyPairToBytes(ikp); byte[] bytes = keyUtil.identityKeyPairToBytes(ikp);
assertNotNull("serialized identityKeyPair must not be null.", assertNotNull("serialized identityKeyPair must not be null.",
bytes); bytes);
assertNotSame("serialized identityKeyPair must not be of length 0.", assertNotSame("serialized identityKeyPair must not be of length 0.",
0, bytes.length); 0, bytes.length);
try {
IdentityKeyPair ikp2 = keyUtil.identityKeyPairFromBytes(bytes); IdentityKeyPair ikp2 = keyUtil.identityKeyPairFromBytes(bytes);
assertTrue("Deserialized IdentityKeyPairs PublicKey must equal the originals one.", assertTrue("Deserialized IdentityKeyPairs PublicKey must equal the originals one.",
ikp.getPublicKey().equals(ikp2.getPublicKey())); ikp.getPublicKey().equals(ikp2.getPublicKey()));
} catch (CorruptedOmemoKeyException e) {
fail("Caught exception while deserializing IdentityKeyPair.");
}
} }
@Test @Test
public void omemoIdentityKeySerializationTest() { public void omemoIdentityKeySerializationTest() throws CorruptedOmemoKeyException {
IdentityKey k = keyUtil.generateOmemoIdentityKeyPair().getPublicKey(); IdentityKey k = keyUtil.generateOmemoIdentityKeyPair().getPublicKey();
assertEquals("Deserialized IdentityKey must equal the original one.", k,
try { keyUtil.identityKeyFromBytes(keyUtil.identityKeyToBytes(k)));
assertEquals("Deserialized IdentityKey must equal the original one.",
k, keyUtil.identityKeyFromBytes(keyUtil.identityKeyToBytes(k)));
} catch (CorruptedOmemoKeyException e) {
fail("Caught exception while serializing and deserializing identityKey (" + e + "): " + e.getMessage());
}
} }
@Test @Test
@ -103,16 +94,12 @@ public class SignalOmemoKeyUtilTest extends SmackTestSuite {
} }
@Test @Test
public void generateOmemoSignedPreKeyTest() { public void generateOmemoSignedPreKeyTest() throws CorruptedOmemoKeyException {
IdentityKeyPair ikp = keyUtil.generateOmemoIdentityKeyPair(); IdentityKeyPair ikp = keyUtil.generateOmemoIdentityKeyPair();
try { SignedPreKeyRecord spk = keyUtil.generateOmemoSignedPreKey(ikp, 1);
SignedPreKeyRecord spk = keyUtil.generateOmemoSignedPreKey(ikp, 1); assertNotNull("SignedPreKey must not be null.", spk);
assertNotNull("SignedPreKey must not be null.", spk); assertEquals("SignedPreKeyId must match.", 1, spk.getId());
assertEquals("SignedPreKeyId must match.", 1, spk.getId()); assertEquals("singedPreKeyId must match here also.", 1, keyUtil.signedPreKeyIdFromKey(spk));
assertEquals("singedPreKeyId must match here also.", 1, keyUtil.signedPreKeyIdFromKey(spk));
} catch (CorruptedOmemoKeyException e) {
fail("Caught an exception while generating signedPreKey (" + e + "): " + e.getMessage());
}
} }
@Test @Test
@ -124,25 +111,17 @@ public class SignalOmemoKeyUtilTest extends SmackTestSuite {
} }
@Test @Test
public void addressToDeviceTest() { public void addressToDeviceTest() throws XmppStringprepException {
SignalProtocolAddress address = new SignalProtocolAddress("test@server.tld",1337); SignalProtocolAddress address = new SignalProtocolAddress("test@server.tld", 1337);
try { OmemoDevice device = keyUtil.addressAsOmemoDevice(address);
OmemoDevice device = keyUtil.addressAsOmemoDevice(address); assertEquals(device, new OmemoDevice(JidCreate.bareFrom("test@server.tld"), 1337));
assertEquals(device, new OmemoDevice(JidCreate.bareFrom("test@server.tld"), 1337));
} catch (XmppStringprepException e) {
fail("Could not convert address to device: " + e + " " + e.getMessage());
}
} }
@Test @Test
public void deviceToAddressTest() { public void deviceToAddressTest() throws XmppStringprepException {
try { OmemoDevice device = new OmemoDevice(JidCreate.bareFrom("test@server.tld"), 1337);
OmemoDevice device = new OmemoDevice(JidCreate.bareFrom("test@server.tld"), 1337); SignalProtocolAddress address = keyUtil.omemoDeviceAsAddress(device);
SignalProtocolAddress address = keyUtil.omemoDeviceAsAddress(device); assertEquals(address, new SignalProtocolAddress("test@server.tld", 1337));
assertEquals(address, new SignalProtocolAddress("test@server.tld", 1337));
} catch (XmppStringprepException e) {
fail("Could not convert device to address: " + e + " " + e.getMessage());
}
} }
@Test @Test

View file

@ -293,6 +293,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
*/ */
private final Set<StanzaFilter> requestAckPredicates = new LinkedHashSet<>(); private final Set<StanzaFilter> requestAckPredicates = new LinkedHashSet<>();
@SuppressWarnings("HidingField")
private final XMPPTCPConnectionConfiguration config; private final XMPPTCPConnectionConfiguration config;
/** /**