You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/12/12 12:50:17 UTC

[commons-crypto] 04/05: Add missing tests

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit 772fb99f019e435245565aa6612fae667bccaa26
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Dec 12 07:49:01 2022 -0500

    Add missing tests
---
 .../org/apache/commons/crypto/utils/EnumTest.java  | 27 ++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/crypto/utils/EnumTest.java b/src/test/java/org/apache/commons/crypto/utils/EnumTest.java
index dca4b60..194de85 100644
--- a/src/test/java/org/apache/commons/crypto/utils/EnumTest.java
+++ b/src/test/java/org/apache/commons/crypto/utils/EnumTest.java
@@ -17,8 +17,13 @@
 */
 package org.apache.commons.crypto.utils;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.apache.commons.crypto.cipher.CryptoCipher;
 import org.apache.commons.crypto.cipher.CryptoCipherFactory;
 import org.apache.commons.crypto.cipher.CryptoCipherFactory.CipherProvider;
+import org.apache.commons.crypto.random.CryptoRandom;
 import org.apache.commons.crypto.random.CryptoRandomFactory;
 import org.apache.commons.crypto.random.CryptoRandomFactory.RandomProvider;
 import org.junit.jupiter.api.Test;
@@ -28,17 +33,31 @@ import org.junit.jupiter.api.Test;
  */
 public class EnumTest {
 
+    private void checkImplClass(final CipherProvider value) {
+        final Class<? extends CryptoCipher> implClass = value.getImplClass();
+        assertTrue(CryptoCipher.class.isAssignableFrom(implClass), implClass.toString());
+        assertEquals(value.getClassName(), implClass.getName());
+    }
+
+    private void checkImplClass(final RandomProvider value) {
+        final Class<? extends CryptoRandom> implClass = value.getImplClass();
+        assertTrue(CryptoRandom.class.isAssignableFrom(implClass), implClass.toString());
+        assertEquals(value.getClassName(), implClass.getName());
+    }
+
     @Test
-    public void testRandom() throws Exception {
-        for (final RandomProvider value : CryptoRandomFactory.RandomProvider.values()) {
+    public void testCipher() throws Exception {
+        for (final CipherProvider value : CryptoCipherFactory.CipherProvider.values()) {
             ReflectionUtils.getClassByName(value.getClassName());
+            checkImplClass(value);
         }
     }
 
     @Test
-    public void testCipher() throws Exception {
-        for (final CipherProvider value : CryptoCipherFactory.CipherProvider.values()) {
+    public void testRandom() throws Exception {
+        for (final RandomProvider value : CryptoRandomFactory.RandomProvider.values()) {
             ReflectionUtils.getClassByName(value.getClassName());
+            checkImplClass(value);
         }
     }