export: improve stream handling, performance

This commit is contained in:
Vincent Breitmoser
2015-09-28 04:20:33 +02:00
parent 46e24058ba
commit 5f1259f3f7
2 changed files with 28 additions and 3 deletions

View File

@@ -354,6 +354,22 @@ public class ExportTest {
"backup_" + KeyFormattingUtils.convertKeyIdToHex(mStaticRing1.getMasterKeyId()) + ".pub.asc",
result.getDecryptionMetadata().getFilename());
TestingUtils.assertArrayEqualsPrefix("exported data must start with ascii armor header",
"-----BEGIN PGP PUBLIC KEY BLOCK-----\n".getBytes(), result.getOutputBytes());
TestingUtils.assertArrayEqualsSuffix("exported data must end with ascii armor header",
"-----END PGP PUBLIC KEY BLOCK-----\n".getBytes(), result.getOutputBytes());
{
IteratorWithIOThrow<UncachedKeyRing> unc
= UncachedKeyRing.fromStream(new ByteArrayInputStream(result.getOutputBytes()));
assertTrue("export must have one key", unc.hasNext());
UncachedKeyRing ring = unc.next();
Assert.assertEquals("exported key has correct masterkeyid",
mStaticRing1.getMasterKeyId(), ring.getMasterKeyId());
assertFalse("export must have exactly one key", unc.hasNext());
}
}
}