use KeyringTestHelper.diffKeyrings method for unit test

This commit is contained in:
Vincent Breitmoser 2014-07-07 18:53:41 +02:00
parent 23524af81d
commit 9320d2d8a2
2 changed files with 19 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -5,10 +5,14 @@ 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.HashSet;
@RunWith(RobolectricTestRunner.class)
@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19
public class UncachedKeyringTest {
@ -17,7 +21,20 @@ public class UncachedKeyringTest {
public void testVerifySuccess() throws Exception {
UncachedKeyRing expectedKeyRing = KeyringBuilder.ring2();
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));
}
/**