1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 14:22:05 +01:00

Merge pull request #21 from pgpainless/junit

Switch to Jupiter JUnit for tests
This commit is contained in:
Paul Schaub 2020-11-13 16:32:57 +01:00 committed by GitHub
commit 473f64f56f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 160 additions and 167 deletions

View file

@ -53,7 +53,7 @@ allprojects {
}
project.ext {
junitVersion = 4.12
junitVersion = '5.7.0'
androidBootClasspath = getAndroidRuntimeJar(pgpainlessMinAndroidSdk)
rootConfigDir = new File(rootDir, 'config')
gitCommit = getGitCommit()
@ -92,6 +92,9 @@ allprojects {
}
}
test {
useJUnitPlatform()
}
}
subprojects {

View file

@ -3,7 +3,9 @@ plugins {
}
dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
/*
implementation "org.bouncycastle:bcprov-debug-jdk15on:$bouncyCastleVersion"
/*/

View file

@ -15,9 +15,9 @@
*/
package org.pgpainless.decryption_verification;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -30,8 +30,8 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
import org.bouncycastle.util.io.Streams;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.algorithm.CompressionAlgorithm;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
@ -46,7 +46,7 @@ public class DecryptAndVerifyMessageTest {
private PGPSecretKeyRing juliet;
private PGPSecretKeyRing romeo;
@Before
@BeforeEach
public void loadKeys() throws IOException, PGPException {
juliet = TestKeys.getJulietSecretKeyRing();
romeo = TestKeys.getRomeoSecretKeyRing();

View file

@ -15,10 +15,10 @@
*/
package org.pgpainless.encryption_signing;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -36,7 +36,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.util.io.Streams;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.algorithm.KeyFlag;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;

View file

@ -26,11 +26,11 @@ import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import jdk.nashorn.internal.ir.annotations.Ignore;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.util.io.Streams;
import org.junit.Ignore;
import org.pgpainless.PGPainless;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.collection.PGPKeyRing;

View file

@ -40,7 +40,7 @@ import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder;
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.provider.ProviderFactory;
public class BouncycastleExportSubkeys {

View file

@ -15,8 +15,8 @@
*/
package org.pgpainless.key;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
@ -24,7 +24,7 @@ import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class ImportExportKeyTest {

View file

@ -15,13 +15,13 @@
*/
package org.pgpainless.key;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.algorithm.KeyFlag;
public class KeyFlagTest {

View file

@ -15,28 +15,30 @@
*/
package org.pgpainless.key;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class OpenPgpV4FingerprintTest {
@Test(expected = IllegalArgumentException.class)
@Test
public void fpTooShort() {
String fp = "484f57414c495645"; // Asking Mark
new OpenPgpV4Fingerprint(fp);
assertThrows(IllegalArgumentException.class, () -> new OpenPgpV4Fingerprint(fp));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void invalidHexTest() {
String fp = "UNFORTUNATELYTHISISNOVALIDHEXADECIMALDOH";
new OpenPgpV4Fingerprint(fp);
assertThrows(IllegalArgumentException.class, () -> new OpenPgpV4Fingerprint(fp));
}
@Test
@ -88,9 +90,9 @@ public class OpenPgpV4FingerprintTest {
assertEquals(fingerprint, parsed);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testFromUriThrowsIfWrongScheme() throws URISyntaxException {
URI uri = new URI(null, "5448452043414B452049532041204C4945212121", null);
OpenPgpV4Fingerprint.fromUri(uri);
assertThrows(IllegalArgumentException.class, () -> OpenPgpV4Fingerprint.fromUri(uri));
}
}

View file

@ -15,15 +15,15 @@
*/
package org.pgpainless.key;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.util.TestUtils;
public class TestKeysTest {
@ -74,8 +74,8 @@ public class TestKeysTest {
@Test
public void assertJulietsFingerprintGetKeyIdMatches() {
assertEquals("calling getKeyId() on juliet's fingerprint must return her key id.",
TestKeys.JULIET_KEY_ID, TestKeys.JULIET_FINGERPRINT.getKeyId());
assertEquals(TestKeys.JULIET_KEY_ID, TestKeys.JULIET_FINGERPRINT.getKeyId(),
"calling getKeyId() on juliet's fingerprint must return her key id.");
}
@Test
@ -85,8 +85,8 @@ public class TestKeysTest {
@Test
public void assertRomeosKeyIdEquals() {
assertEquals("Key ID of Romeo's secret key must match his key id.",
TestKeys.ROMEO_KEY_ID, romeoSecRing.getSecretKey().getKeyID());
assertEquals(TestKeys.ROMEO_KEY_ID, romeoSecRing.getSecretKey().getKeyID(),
"Key ID of Romeo's secret key must match his key id.");
}
@Test
@ -145,7 +145,7 @@ public class TestKeysTest {
@Test
public void assertEmilsFingerprintGetKeyIdMatches() {
assertEquals("calling getKeyId() on emil's fingerprint must return her key id.",
TestKeys.EMIL_KEY_ID, TestKeys.EMIL_FINGERPRINT.getKeyId());
assertEquals(TestKeys.EMIL_KEY_ID, TestKeys.EMIL_FINGERPRINT.getKeyId(),
"calling getKeyId() on emil's fingerprint must return her key id.");
}
}

View file

@ -15,29 +15,30 @@
*/
package org.pgpainless.key;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.key.util.UserId;
public class UserIdTest {
@Test(expected = IllegalArgumentException.class)
@Test
public void throwForNullName() {
UserId.withName(null);
assertThrows(IllegalArgumentException.class, () -> UserId.withName(null));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void throwForNullComment() {
UserId.withName("foo")
.withComment(null);
assertThrows(IllegalArgumentException.class, () -> UserId.withName("foo")
.withComment(null));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void throwForNullEmail() {
UserId.withName("foo")
assertThrows(IllegalArgumentException.class, () -> UserId.withName("foo")
.withComment("bar")
.withEmail(null);
.withEmail(null));
}
@Test

View file

@ -24,7 +24,8 @@ import java.util.logging.Logger;
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.openpgp.PGPException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.key.OpenPgpV4Fingerprint;
import org.pgpainless.key.collection.PGPKeyRing;

View file

@ -15,8 +15,8 @@
*/
package org.pgpainless.key.generation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -26,7 +26,8 @@ import java.util.Iterator;
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.openpgp.PGPException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.key.collection.PGPKeyRing;
import org.pgpainless.key.generation.type.KeyType;

View file

@ -15,14 +15,14 @@
*/
package org.pgpainless.key.generation;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import org.bouncycastle.openpgp.PGPException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.key.generation.type.KeyType;
import org.pgpainless.key.generation.type.length.RsaLength;

View file

@ -15,7 +15,7 @@
*/
package org.pgpainless.key.modification;
import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
@ -29,7 +29,7 @@ import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.algorithm.KeyFlag;
import org.pgpainless.key.TestKeys;

View file

@ -15,8 +15,9 @@
*/
package org.pgpainless.key.modification;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
@ -26,7 +27,7 @@ import java.util.NoSuchElementException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.collection.PGPKeyRing;
@ -65,24 +66,24 @@ public class AddUserIdTest {
assertFalse(userIds.hasNext());
}
@Test(expected = NoSuchElementException.class)
@Test
public void addUserId_NoSuchElementExceptionForMissingKey() throws IOException, PGPException {
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
PGPainless.modifyKeyRing(secretKeys)
.addUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector());
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
.addUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector()));
}
@Test(expected = NoSuchElementException.class)
@Test
public void deleteUserId_noSuchElementExceptionForMissingUserId() throws IOException, PGPException {
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
PGPainless.modifyKeyRing(secretKeys)
.deleteUserId("invalid@user.id", new UnprotectedKeysProtector());
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
.deleteUserId("invalid@user.id", new UnprotectedKeysProtector()));
}
@Test(expected = NoSuchElementException.class)
@Test
public void deleteUserId_noSuchElementExceptionForMissingKey() throws IOException, PGPException {
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
PGPainless.modifyKeyRing(secretKeys)
.deleteUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector());
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
.deleteUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector()));
}
}

View file

@ -15,8 +15,9 @@
*/
package org.pgpainless.key.modification;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -33,7 +34,7 @@ import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider;
import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
import org.bouncycastle.util.io.Streams;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
import org.pgpainless.encryption_signing.EncryptionStream;
@ -63,25 +64,16 @@ public class ChangeSecretKeyRingPassphraseTest {
assertEquals(KeyRingProtectionSettings.secureDefaultSettings().getEncryptionAlgorithm().getAlgorithmId(),
changedPassphraseKeyRing.getSecretKeys().getSecretKey().getKeyEncryptionAlgorithm());
try {
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.emptyPassphrase());
fail("Unlocking secret key ring with empty passphrase MUST fail.");
} catch (PGPException e) {
// yay
}
assertThrows(PGPException.class, () ->
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.emptyPassphrase()),
"Unlocking secret key ring with empty passphrase MUST fail.");
try {
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.fromPassword("weakPassphrase"));
fail("Unlocking secret key ring with old passphrase MUST fail.");
} catch (PGPException e) {
// yay
}
assertThrows(PGPException.class, () ->
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.fromPassword("weakPassphrase")),
"Unlocking secret key ring with old passphrase MUST fail.");
try {
signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.fromPassword("1337p455phr453"));
} catch (PGPException e) {
fail("Unlocking the secret key ring with the new passphrase MUST succeed.");
}
assertDoesNotThrow(() -> signDummyMessageWithKeysAndPassphrase(changedPassphraseKeyRing, Passphrase.fromPassword("1337p455phr453")),
"Unlocking the secret key ring with the new passphrase MUST succeed.");
}
@Test
@ -124,19 +116,15 @@ public class ChangeSecretKeyRingPassphraseTest {
extractPrivateKey(primaryKey, Passphrase.fromPassword("weakPassphrase"));
extractPrivateKey(subKey, Passphrase.fromPassword("subKeyPassphrase"));
try {
extractPrivateKey(primaryKey, Passphrase.fromPassword("subKeyPassphrase"));
fail("Unlocking the primary key with the subkey passphrase must fail.");
} catch (PGPException e) {
// yay
}
final PGPSecretKey finalPrimaryKey = primaryKey;
assertThrows(PGPException.class,
() -> extractPrivateKey(finalPrimaryKey, Passphrase.fromPassword("subKeyPassphrase")),
"Unlocking the primary key with the subkey passphrase must fail.");
try {
extractPrivateKey(subKey, Passphrase.fromPassword("weakPassphrase"));
fail("Unlocking the subkey with the primary key passphrase must fail.");
} catch (PGPException e) {
// yay
}
final PGPSecretKey finalSubKey = subKey;
assertThrows(PGPException.class,
() -> extractPrivateKey(finalSubKey, Passphrase.fromPassword("weakPassphrase")),
"Unlocking the subkey with the primary key passphrase must fail.");
}
@Test
@ -158,20 +146,15 @@ public class ChangeSecretKeyRingPassphraseTest {
extractPrivateKey(primaryKey, Passphrase.emptyPassphrase());
extractPrivateKey(subKey, Passphrase.fromPassword("weakPassphrase"));
try {
extractPrivateKey(primaryKey, Passphrase.fromPassword("weakPassphrase"));
fail("Unlocking the unprotected primary key with the old passphrase must fail.");
} catch (PGPException e) {
// yay
}
try {
extractPrivateKey(subKey, Passphrase.emptyPassphrase());
fail("Unlocking the still protected subkey with an empty passphrase must fail.");
} catch (PGPException e) {
// yay
}
final PGPSecretKey finalPrimaryKey = primaryKey;
assertThrows(PGPException.class,
() -> extractPrivateKey(finalPrimaryKey, Passphrase.fromPassword("weakPassphrase")),
"Unlocking the unprotected primary key with the old passphrase must fail.");
final PGPSecretKey finalSubKey = subKey;
assertThrows(PGPException.class,
() -> extractPrivateKey(finalSubKey, Passphrase.emptyPassphrase()),
"Unlocking the still protected subkey with an empty passphrase must fail.");
}
/**

View file

@ -15,12 +15,15 @@
*/
package org.pgpainless.key.modification;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
public class KeyRingEditorTest {
@Test(expected = NullPointerException.class)
@Test
public void testConstructorThrowsNpeForNull() {
new KeyRingEditor(null);
assertThrows(NullPointerException.class,
() -> new KeyRingEditor(null));
}
}

View file

@ -15,8 +15,8 @@
*/
package org.pgpainless.key.modification;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Iterator;
@ -24,7 +24,7 @@ import java.util.Iterator;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.key.OpenPgpV4Fingerprint;
import org.pgpainless.key.TestKeys;

View file

@ -15,13 +15,13 @@
*/
package org.pgpainless.key.protection;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import javax.annotation.Nullable;
import org.bouncycastle.openpgp.PGPException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.protection.passphrase_provider.SecretKeyPassphraseProvider;
import org.pgpainless.util.Passphrase;

View file

@ -15,12 +15,12 @@
*/
package org.pgpainless.key.protection;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.util.Passphrase;
public class PassphraseTest {
@ -35,11 +35,6 @@ public class PassphraseTest {
passphrase.clear();
assertFalse(passphrase.isValid());
try {
passphrase.getChars();
fail();
} catch (IllegalStateException e) {
// expected
}
assertThrows(IllegalStateException.class, passphrase::getChars);
}
}

View file

@ -15,9 +15,9 @@
*/
package org.pgpainless.key.protection;
import static junit.framework.TestCase.assertNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class UnprotectedKeysProtectorTest {

View file

@ -15,15 +15,15 @@
*/
package org.pgpainless.key.selection.keyring;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.selection.keyring.impl.Email;

View file

@ -15,8 +15,8 @@
*/
package org.pgpainless.key.selection.keyring;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Collections;
@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.selection.keyring.impl.Whitelist;

View file

@ -15,14 +15,14 @@
*/
package org.pgpainless.key.selection.keyring;
import static junit.framework.TestCase.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.selection.keyring.impl.Wildcard;

View file

@ -15,15 +15,15 @@
*/
package org.pgpainless.key.selection.keyring;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.selection.keyring.impl.XMPP;

View file

@ -15,11 +15,11 @@
*/
package org.pgpainless.provider;
import static junit.framework.TestCase.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.security.Provider;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class ProviderFactoryTest {

View file

@ -15,7 +15,7 @@
*/
package org.pgpainless.symmetric_encryption;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -24,7 +24,7 @@ import java.util.logging.Logger;
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.openpgp.PGPException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
import org.pgpainless.util.Passphrase;

View file

@ -15,8 +15,10 @@
*/
package org.pgpainless.util;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
@ -26,7 +28,6 @@ import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import junit.framework.TestCase;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
@ -34,7 +35,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.key.collection.PGPKeyRing;
import org.pgpainless.key.generation.KeySpec;
@ -119,15 +120,15 @@ public class BCUtilTest {
}
}
TestCase.assertNotNull(subKey);
assertNotNull(subKey);
PGPSecretKeyRing alice_mallory = PGPSecretKeyRing.insertSecretKey(alice.getSecretKeys(), subKey);
// Check, if alice_mallory contains mallory's key
TestCase.assertNotNull(alice_mallory.getSecretKey(subKey.getKeyID()));
assertNotNull(alice_mallory.getSecretKey(subKey.getKeyID()));
PGPSecretKeyRing cleaned = BCUtil.removeUnassociatedKeysFromKeyRing(alice_mallory, alice.getPublicKeys().getPublicKey());
TestCase.assertNull(cleaned.getSecretKey(subKey.getKeyID()));
assertNull(cleaned.getSecretKey(subKey.getKeyID()));
}
@Test

View file

@ -15,13 +15,13 @@
*/
package org.pgpainless.util;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertNull;
import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
import java.util.Collections;
@ -30,7 +30,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class MultiMapTest {