aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/testsupport/PgpVerifyTestingHelper.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-06-21 21:31:25 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-06-21 21:31:25 +0200
commit4cc127e4604c664ee6a8607fc2404256f8949609 (patch)
tree71108127d7fc65d86c641ce94f713786f9fb4a78 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/testsupport/PgpVerifyTestingHelper.java
parent0c3a478a431e37566dad6dfe3e396ff6c2034765 (diff)
parent0af2b27cb3d286f3f4e2f830c78b307ca222ff31 (diff)
downloadopen-keychain-4cc127e4604c664ee6a8607fc2404256f8949609.tar.gz
open-keychain-4cc127e4604c664ee6a8607fc2404256f8949609.tar.bz2
open-keychain-4cc127e4604c664ee6a8607fc2404256f8949609.zip
Merge pull request #672 from artbristol/functional-testing
VERY basic test for save keyring
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/testsupport/PgpVerifyTestingHelper.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/testsupport/PgpVerifyTestingHelper.java40
1 files changed, 2 insertions, 38 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/testsupport/PgpVerifyTestingHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/testsupport/PgpVerifyTestingHelper.java
index e27ca578d..1ab5878cc 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/testsupport/PgpVerifyTestingHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/testsupport/PgpVerifyTestingHelper.java
@@ -1,19 +1,14 @@
package org.sufficientlysecure.keychain.testsupport;
import android.content.Context;
-import android.net.Uri;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult;
-import org.sufficientlysecure.keychain.pgp.WrappedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.util.InputData;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -25,7 +20,7 @@ public class PgpVerifyTestingHelper {
private final Context context;
public PgpVerifyTestingHelper(Context robolectricContext) {
- this.context=robolectricContext;
+ this.context = robolectricContext;
}
public int doTestFile(String testFileName) throws Exception {
@@ -37,7 +32,7 @@ public class PgpVerifyTestingHelper {
}
};
- byte[] sampleInputBytes = readFully(getClass().getResourceAsStream(testFileName));
+ byte[] sampleInputBytes = TestDataUtil.readFully(getClass().getResourceAsStream(testFileName));
InputStream sampleInput = new ByteArrayInputStream(sampleInputBytes);
@@ -51,35 +46,4 @@ public class PgpVerifyTestingHelper {
}
- static class ProviderHelperStub extends ProviderHelper {
- public ProviderHelperStub(Context context) {
- super(context);
- }
-
- @Override
- public WrappedPublicKeyRing getWrappedPublicKeyRing(Uri id) throws NotFoundException {
- try {
- byte[] data = readFully(getClass().getResourceAsStream("/public-key-for-sample.blob"));
- return new WrappedPublicKeyRing(data, false, 0);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- public static byte[] readFully(InputStream input) throws IOException
- {
- byte[] buffer = new byte[8192];
- int bytesRead;
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- while ((bytesRead = input.read(buffer)) != -1)
- {
- output.write(buffer, 0, bytesRead);
- }
- return output.toByteArray();
- }
-
-
-
-
}