mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-14 04:45:04 -05:00
use KeyringTestHelper.diffKeyrings method for unit test
This commit is contained in:
parent
23524af81d
commit
9320d2d8a2
@ -60,7 +60,7 @@ public class KeyringTestingHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
System.out.println("tag: " + tag + ", code: " + Arrays.hashCode(buf));
|
// System.out.println("tag: " + tag + ", code: " + Arrays.hashCode(buf));
|
||||||
return Arrays.hashCode(buf);
|
return Arrays.hashCode(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,14 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.*;
|
import org.robolectric.*;
|
||||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||||
|
import org.sufficientlysecure.keychain.service.OperationResultParcel;
|
||||||
import org.sufficientlysecure.keychain.testsupport.*;
|
import org.sufficientlysecure.keychain.testsupport.*;
|
||||||
import org.sufficientlysecure.keychain.testsupport.KeyringBuilder;
|
import org.sufficientlysecure.keychain.testsupport.KeyringBuilder;
|
||||||
|
import org.sufficientlysecure.keychain.testsupport.KeyringTestingHelper;
|
||||||
import org.sufficientlysecure.keychain.testsupport.TestDataUtil;
|
import org.sufficientlysecure.keychain.testsupport.TestDataUtil;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
|
||||||
public class UncachedKeyringTest {
|
public class UncachedKeyringTest {
|
||||||
@ -17,7 +21,20 @@ public class UncachedKeyringTest {
|
|||||||
public void testVerifySuccess() throws Exception {
|
public void testVerifySuccess() throws Exception {
|
||||||
UncachedKeyRing expectedKeyRing = KeyringBuilder.ring2();
|
UncachedKeyRing expectedKeyRing = KeyringBuilder.ring2();
|
||||||
UncachedKeyRing inputKeyRing = KeyringBuilder.ring1();
|
UncachedKeyRing inputKeyRing = KeyringBuilder.ring1();
|
||||||
new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, expectedKeyRing);
|
// new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, expectedKeyRing);
|
||||||
|
|
||||||
|
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
||||||
|
UncachedKeyRing canonicalizedRing = inputKeyRing.canonicalize(log, 0);
|
||||||
|
|
||||||
|
if (canonicalizedRing == null) {
|
||||||
|
throw new AssertionError("Canonicalization failed; messages: [" + log.toString() + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet onlyA = new HashSet<KeyringTestingHelper.Packet>();
|
||||||
|
HashSet onlyB = new HashSet<KeyringTestingHelper.Packet>();
|
||||||
|
Assert.assertTrue(KeyringTestingHelper.diffKeyrings(
|
||||||
|
canonicalizedRing.getEncoded(), expectedKeyRing.getEncoded(), onlyA, onlyB));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user