diff options
| author | J08nY | 2018-05-28 21:45:19 +0200 |
|---|---|---|
| committer | J08nY | 2018-05-28 21:45:19 +0200 |
| commit | 298ffc18e590d07eb04d2c5c2b1d553f8fba71bd (patch) | |
| tree | 3eccc379deb68a920951cc29c7bcb17368933fde /src/cz/crcs/ectester/standalone/test | |
| parent | a4e52b21b1dad5f96df409c44e5b4d611bba01b9 (diff) | |
| download | ECTester-298ffc18e590d07eb04d2c5c2b1d553f8fba71bd.tar.gz ECTester-298ffc18e590d07eb04d2c5c2b1d553f8fba71bd.tar.zst ECTester-298ffc18e590d07eb04d2c5c2b1d553f8fba71bd.zip | |
Implement tracking and writing of exceptions in standalone tests.
Diffstat (limited to '')
4 files changed, 24 insertions, 22 deletions
diff --git a/src/cz/crcs/ectester/standalone/test/base/KeyAgreementTestable.java b/src/cz/crcs/ectester/standalone/test/base/KeyAgreementTestable.java index ffcfc67..1447373 100644 --- a/src/cz/crcs/ectester/standalone/test/base/KeyAgreementTestable.java +++ b/src/cz/crcs/ectester/standalone/test/base/KeyAgreementTestable.java @@ -87,8 +87,7 @@ public class KeyAgreementTestable extends StandaloneTestable<KeyAgreementTestabl ka.init(privateKey); } } catch (InvalidKeyException | InvalidAlgorithmParameterException e) { - ok = false; - hasRun = true; + failOnException(e); return; } @@ -96,17 +95,15 @@ public class KeyAgreementTestable extends StandaloneTestable<KeyAgreementTestabl try { ka.doPhase(publicKey, true); } catch (IllegalStateException | InvalidKeyException e) { - ok = false; - hasRun = true; + failOnException(e); return; } stage = KeyAgreementStage.GenerateSecret; try { secret = ka.generateSecret(); - } catch (IllegalStateException | UnsupportedOperationException isex) { - ok = false; - hasRun = true; + } catch (IllegalStateException | UnsupportedOperationException e) { + failOnException(e); return; } diff --git a/src/cz/crcs/ectester/standalone/test/base/KeyGeneratorTestable.java b/src/cz/crcs/ectester/standalone/test/base/KeyGeneratorTestable.java index b561b8b..c05d6e3 100644 --- a/src/cz/crcs/ectester/standalone/test/base/KeyGeneratorTestable.java +++ b/src/cz/crcs/ectester/standalone/test/base/KeyGeneratorTestable.java @@ -47,8 +47,7 @@ public class KeyGeneratorTestable extends StandaloneTestable<KeyGeneratorTestabl kpg.initialize(keysize); } } catch (InvalidAlgorithmParameterException e) { - ok = false; - hasRun = true; + failOnException(e); return; } diff --git a/src/cz/crcs/ectester/standalone/test/base/SignatureTestable.java b/src/cz/crcs/ectester/standalone/test/base/SignatureTestable.java index 873757b..b8db7b8 100644 --- a/src/cz/crcs/ectester/standalone/test/base/SignatureTestable.java +++ b/src/cz/crcs/ectester/standalone/test/base/SignatureTestable.java @@ -65,8 +65,7 @@ public class SignatureTestable extends StandaloneTestable<SignatureTestable.Sign try { sig.initSign(signKey); } catch (InvalidKeyException e) { - ok = false; - hasRun = true; + failOnException(e); return; } @@ -74,8 +73,7 @@ public class SignatureTestable extends StandaloneTestable<SignatureTestable.Sign try { sig.update(data); } catch (SignatureException e) { - ok = false; - hasRun = true; + failOnException(e); return; } @@ -83,8 +81,7 @@ public class SignatureTestable extends StandaloneTestable<SignatureTestable.Sign try { signature = sig.sign(); } catch (SignatureException e) { - ok = false; - hasRun = true; + failOnException(e); return; } @@ -92,8 +89,7 @@ public class SignatureTestable extends StandaloneTestable<SignatureTestable.Sign try { sig.initVerify(verifyKey); } catch (InvalidKeyException e) { - ok = false; - hasRun = true; + failOnException(e); return; } @@ -101,8 +97,7 @@ public class SignatureTestable extends StandaloneTestable<SignatureTestable.Sign try { sig.update(data); } catch (SignatureException e) { - ok = false; - hasRun = true; + failOnException(e); return; } @@ -110,11 +105,11 @@ public class SignatureTestable extends StandaloneTestable<SignatureTestable.Sign try { verified = sig.verify(signature); } catch (SignatureException e) { - ok = false; - hasRun = true; + failOnException(e); + return; } - ok = true; + ok = verified; } catch (Exception ex) { ok = false; error = true; diff --git a/src/cz/crcs/ectester/standalone/test/base/StandaloneTestable.java b/src/cz/crcs/ectester/standalone/test/base/StandaloneTestable.java index 8654e94..47bffc1 100644 --- a/src/cz/crcs/ectester/standalone/test/base/StandaloneTestable.java +++ b/src/cz/crcs/ectester/standalone/test/base/StandaloneTestable.java @@ -7,8 +7,19 @@ import cz.crcs.ectester.common.test.BaseTestable; */ public abstract class StandaloneTestable<T extends Enum<T>> extends BaseTestable { protected T stage; + protected Exception exception; public T getStage() { return stage; } + + public Exception getException() { + return exception; + } + + protected void failOnException(Exception ex) { + ok = false; + hasRun = true; + exception = ex; + } } |
