From e1038a8bb36b10832d88320ccdc1095b2fe3bd40 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Fri, 2 Jun 2023 00:03:55 +0200 Subject: [PATCH] Replace more occurrences of new Date().getTime() with System.currentTimeMillis() --- ...tionOnKeyWithDifferentSignatureTypesTest.java | 2 +- .../org/pgpainless/sop/DetachedSignTest.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeExpirationOnKeyWithDifferentSignatureTypesTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeExpirationOnKeyWithDifferentSignatureTypesTest.java index 9acb08f6..c029a317 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeExpirationOnKeyWithDifferentSignatureTypesTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeExpirationOnKeyWithDifferentSignatureTypesTest.java @@ -155,7 +155,7 @@ public class ChangeExpirationOnKeyWithDifferentSignatureTypesTest { private void executeTestForKeys(PGPSecretKeyRing keys, SecretKeyRingProtector protector) throws PGPException { - Date expirationDate = new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 14); + Date expirationDate = new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24 * 14); // round date for test stability expirationDate = DateUtil.toSecondsPrecision(expirationDate); diff --git a/pgpainless-sop/src/test/java/org/pgpainless/sop/DetachedSignTest.java b/pgpainless-sop/src/test/java/org/pgpainless/sop/DetachedSignTest.java index 316c4a37..9238697a 100644 --- a/pgpainless-sop/src/test/java/org/pgpainless/sop/DetachedSignTest.java +++ b/pgpainless-sop/src/test/java/org/pgpainless/sop/DetachedSignTest.java @@ -59,8 +59,8 @@ public class DetachedSignTest { List verifications = sop.verify() .cert(cert) - .notAfter(new Date(new Date().getTime() + 10000)) - .notBefore(new Date(new Date().getTime() - 10000)) + .notAfter(new Date(System.currentTimeMillis() + 10000)) + .notBefore(new Date(System.currentTimeMillis() - 10000)) .signatures(signature) .data(data); @@ -81,8 +81,8 @@ public class DetachedSignTest { List verifications = sop.verify() .cert(cert) - .notAfter(new Date(new Date().getTime() + 10000)) - .notBefore(new Date(new Date().getTime() - 10000)) + .notAfter(new Date(System.currentTimeMillis() + 10000)) + .notBefore(new Date(System.currentTimeMillis() - 10000)) .signatures(signature) .data(data); @@ -101,8 +101,8 @@ public class DetachedSignTest { List verifications = sop.verify() .cert(cert) - .notAfter(new Date(new Date().getTime() + 10000)) - .notBefore(new Date(new Date().getTime() - 10000)) + .notAfter(new Date(System.currentTimeMillis() + 10000)) + .notBefore(new Date(System.currentTimeMillis() - 10000)) .signatures(signature) .data(data); @@ -120,7 +120,7 @@ public class DetachedSignTest { assertThrows(SOPGPException.NoSignature.class, () -> sop.verify() .cert(cert) - .notAfter(new Date(new Date().getTime() - 10000)) // Sig is older + .notAfter(new Date(System.currentTimeMillis() - 10000)) // Sig is older .signatures(signature) .data(data)); } @@ -134,7 +134,7 @@ public class DetachedSignTest { assertThrows(SOPGPException.NoSignature.class, () -> sop.verify() .cert(cert) - .notBefore(new Date(new Date().getTime() + 10000)) // Sig is younger + .notBefore(new Date(System.currentTimeMillis() + 10000)) // Sig is younger .signatures(signature) .data(data)); }