Remove redundant throws clauses

Removes exceptions that are declared in a method's signature but never thrown by the method itself or its implementations/derivatives.
This commit is contained in:
Lars Grefer
2019-08-23 01:03:54 +02:00
parent f0515a021c
commit 34dd5fea30
418 changed files with 1146 additions and 1273 deletions

View File

@@ -45,24 +45,24 @@ public class Argon2EncodingUtilsTests {
));
@Test
public void decodeWhenValidEncodedHashWithIThenDecodeCorrectly() throws Exception {
public void decodeWhenValidEncodedHashWithIThenDecodeCorrectly() {
assertArgon2HashEquals(testDataEntry1.decoded, Argon2EncodingUtils.decode(testDataEntry1.encoded));
}
@Test
public void decodeWhenValidEncodedHashWithIDThenDecodeCorrectly() throws Exception {
public void decodeWhenValidEncodedHashWithIDThenDecodeCorrectly() {
assertArgon2HashEquals(testDataEntry2.decoded, Argon2EncodingUtils.decode(testDataEntry2.encoded));
}
@Test
public void encodeWhenValidArgumentsWithIThenEncodeToCorrectHash() throws Exception {
public void encodeWhenValidArgumentsWithIThenEncodeToCorrectHash() {
assertThat(Argon2EncodingUtils
.encode(testDataEntry1.decoded.getHash(), testDataEntry1.decoded.getParameters()))
.isEqualTo(testDataEntry1.encoded);
}
@Test
public void encodeWhenValidArgumentsWithID2ThenEncodeToCorrectHash() throws Exception {
public void encodeWhenValidArgumentsWithID2ThenEncodeToCorrectHash() {
assertThat(Argon2EncodingUtils
.encode(testDataEntry2.decoded.getHash(), testDataEntry2.decoded.getParameters()))
.isEqualTo(testDataEntry2.encoded);

View File

@@ -128,14 +128,14 @@ public class Argon2PasswordEncoderTests {
}
@Test
public void upgradeEncodingWhenSameEncodingThenFalse() throws Exception {
public void upgradeEncodingWhenSameEncodingThenFalse() {
String hash = encoder.encode("password");
assertThat(encoder.upgradeEncoding(hash)).isFalse();
}
@Test
public void upgradeEncodingWhenSameStandardParamsThenFalse() throws Exception {
public void upgradeEncodingWhenSameStandardParamsThenFalse() {
Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder();
String hash = encoder.encode("password");
@@ -144,7 +144,7 @@ public class Argon2PasswordEncoderTests {
}
@Test
public void upgradeEncodingWhenSameCustomParamsThenFalse() throws Exception {
public void upgradeEncodingWhenSameCustomParamsThenFalse() {
Argon2PasswordEncoder oldEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4);
Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4);
@@ -154,7 +154,7 @@ public class Argon2PasswordEncoderTests {
}
@Test
public void upgradeEncodingWhenHashHasLowerMemoryThenTrue() throws Exception {
public void upgradeEncodingWhenHashHasLowerMemoryThenTrue() {
Argon2PasswordEncoder oldEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4);
Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(20, 64, 4, 512, 4);
@@ -164,7 +164,7 @@ public class Argon2PasswordEncoderTests {
}
@Test
public void upgradeEncodingWhenHashHasLowerIterationsThenTrue() throws Exception {
public void upgradeEncodingWhenHashHasLowerIterationsThenTrue() {
Argon2PasswordEncoder oldEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4);
Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 5);
@@ -174,7 +174,7 @@ public class Argon2PasswordEncoderTests {
}
@Test
public void upgradeEncodingWhenHashHasHigherParamsThenFalse() throws Exception {
public void upgradeEncodingWhenHashHasHigherParamsThenFalse() {
Argon2PasswordEncoder oldEncoder = new Argon2PasswordEncoder(20, 64, 4, 256, 4);
Argon2PasswordEncoder newEncoder = new Argon2PasswordEncoder(20, 64, 4, 128, 3);

View File

@@ -83,8 +83,7 @@ public class BouncyCastleAesBytesEncryptorEquivalencyTest {
testCompatibility(bcEncryptor, jceEncryptor);
}
private void testEquivalence(BytesEncryptor left, BytesEncryptor right)
throws Exception {
private void testEquivalence(BytesEncryptor left, BytesEncryptor right) {
for (int size = 1; size < 2048; size++) {
testData = new byte[size];
secureRandom.nextBytes(testData);
@@ -101,8 +100,7 @@ public class BouncyCastleAesBytesEncryptorEquivalencyTest {
}
private void testCompatibility(BytesEncryptor left, BytesEncryptor right)
throws Exception {
private void testCompatibility(BytesEncryptor left, BytesEncryptor right) {
// tests that right can decrypt what left encrypted and vice versa
// and that the decypted data is the same as the original
for (int size = 1; size < 2048; size++) {

View File

@@ -44,13 +44,13 @@ public class BouncyCastleAesBytesEncryptorTest {
}
@Test
public void bcCbcWithSecureIvGeneratesDifferentMessages() throws Exception {
public void bcCbcWithSecureIvGeneratesDifferentMessages() {
BytesEncryptor bcEncryptor = new BouncyCastleAesCbcBytesEncryptor(password, salt);
generatesDifferentCipherTexts(bcEncryptor);
}
@Test
public void bcGcmWithSecureIvGeneratesDifferentMessages() throws Exception {
public void bcGcmWithSecureIvGeneratesDifferentMessages() {
BytesEncryptor bcEncryptor = new BouncyCastleAesGcmBytesEncryptor(password, salt);
generatesDifferentCipherTexts(bcEncryptor);
}
@@ -66,13 +66,13 @@ public class BouncyCastleAesBytesEncryptorTest {
}
@Test(expected = IllegalArgumentException.class)
public void bcCbcWithWrongLengthIv() throws Exception {
public void bcCbcWithWrongLengthIv() {
new BouncyCastleAesCbcBytesEncryptor(password, salt,
KeyGenerators.secureRandom(8));
}
@Test(expected = IllegalArgumentException.class)
public void bcGcmWithWrongLengthIv() throws Exception {
public void bcGcmWithWrongLengthIv() {
new BouncyCastleAesGcmBytesEncryptor(password, salt,
KeyGenerators.secureRandom(8));
}

View File

@@ -45,7 +45,7 @@ public class KeyGeneratorsTests {
}
@Test
public void shared() throws Exception {
public void shared() {
BytesKeyGenerator keyGenerator = KeyGenerators.shared(21);
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
byte[] key = keyGenerator.generateKey();

View File

@@ -75,7 +75,7 @@ public class LdapShaPasswordEncoderTests {
@Test
// SEC-1031
public void fullLengthOfHashIsUsedInComparison() throws Exception {
public void fullLengthOfHashIsUsedInComparison() {
assertThat(this.sha.matches("boabspasswurd", "{SSHA}25ro4PKC8jhQZ26jVsozhX/xaP0suHgX")).isTrue();
// Change the first hash character from '2' to '3'
assertThat(this.sha.matches("boabspasswurd", "{SSHA}35ro4PKC8jhQZ26jVsozhX/xaP0suHgX")).isFalse();

View File

@@ -43,7 +43,7 @@ public class MessageDigestPasswordEncoderTests {
}
@Test
public void md5NonAsciiPasswordHasCorrectHash() throws Exception {
public void md5NonAsciiPasswordHasCorrectHash() {
MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("MD5");
// $ echo -n "??" | md5
// 7eca689f0d3389d9dea66ae112e5cfd7
@@ -51,14 +51,14 @@ public class MessageDigestPasswordEncoderTests {
}
@Test
public void md5Base64() throws Exception {
public void md5Base64() {
MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("MD5");
pe.setEncodeHashAsBase64(true);
assertThat(pe.matches("abc123", "{THIS_IS_A_SALT}poqv2QKZ0LE33ij7S7aFcw==")).isTrue();
}
@Test
public void md5StretchFactorIsProcessedCorrectly() throws Exception {
public void md5StretchFactorIsProcessedCorrectly() {
MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("MD5");
pe.setIterations(2);
// Calculate value using:
@@ -101,7 +101,7 @@ public class MessageDigestPasswordEncoderTests {
}
@Test
public void testBase64() throws Exception {
public void testBase64() {
MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("SHA-1");
pe.setEncodeHashAsBase64(true);
String raw = "abc123";
@@ -109,14 +109,14 @@ public class MessageDigestPasswordEncoderTests {
}
@Test
public void test256() throws Exception {
public void test256() {
MessageDigestPasswordEncoder pe = new MessageDigestPasswordEncoder("SHA-1");
String raw = "abc123";
assertThat(pe.matches(raw, "{THIS_IS_A_SALT}4b79b7de23eb23b78cc5ede227d532b8a51f89b2ec166f808af76b0dbedc47d7"));
}
@Test(expected = IllegalStateException.class)
public void testInvalidStrength() throws Exception {
public void testInvalidStrength() {
new MessageDigestPasswordEncoder("SHA-666");
}
}