mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-24 07:58:50 -05:00
use KeyringTestHelper.diffKeyrings method for unit test
Conflicts: OpenKeychain/src/test/java/tests/UncachedKeyringTest.java
This commit is contained in:
parent
83e5a3d341
commit
9971f9ad4c
@ -60,7 +60,7 @@ public class KeyringTestingHelper {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,11 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.*;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel;
|
||||
import org.sufficientlysecure.keychain.testsupport.*;
|
||||
import org.sufficientlysecure.keychain.testsupport.KeyringBuilder;
|
||||
import org.sufficientlysecure.keychain.testsupport.KeyringTestingHelper;
|
||||
import org.sufficientlysecure.keychain.testsupport.TestDataUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
@ -21,6 +25,20 @@ public class UncachedKeyringTest {
|
||||
// Uncomment to dump the encoded key for manual inspection
|
||||
// TestDataUtil.appendToOutput(new ByteArrayInputStream(inputKeyRing.getEncoded()), new FileOutputStream(new File("/tmp/key-encoded")));
|
||||
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