commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject commons-crypto git commit: Ensure test still works if JNI cannot be loaded
Date Tue, 05 Jul 2016 15:45:33 GMT
Repository: commons-crypto
Updated Branches:
  refs/heads/master 8997a623e -> 929840b3a


Ensure test still works if JNI cannot be loaded

Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/929840b3
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/929840b3
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/929840b3

Branch: refs/heads/master
Commit: 929840b3a69c6b1ad13534c5132a9772d30155ed
Parents: 8997a62
Author: Sebb <sebb@apache.org>
Authored: Tue Jul 5 16:45:29 2016 +0100
Committer: Sebb <sebb@apache.org>
Committed: Tue Jul 5 16:45:29 2016 +0100

----------------------------------------------------------------------
 .../crypto/cipher/CryptoCipherFactoryTest.java   | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/929840b3/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java
index 9690cad..2544717 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java
@@ -28,19 +28,26 @@ public class CryptoCipherFactoryTest {
     public void testDefaultCipher() throws GeneralSecurityException {
         CryptoCipher defaultCipher = CryptoCipherFactory
                 .getCryptoCipher("AES/CBC/NoPadding");
-        Assert.assertEquals(OpenSslCipher.class.getName(), defaultCipher
-                .getClass().getName());
+        final String name = defaultCipher.getClass().getName();
+        if (OpenSsl.getLoadingFailureReason() == null) {
+            Assert.assertEquals(OpenSslCipher.class.getName(), name);
+        } else {
+            Assert.assertEquals(JceCipher.class.getName(), name);
+        }
     }
 
     @Test
     public void testEmptyCipher() throws GeneralSecurityException {
         Properties properties = new Properties();
-        properties.setProperty(
-                CryptoCipherFactory.CLASSES_KEY, "");
+        properties.setProperty(CryptoCipherFactory.CLASSES_KEY, ""); // TODO should this
really mean use the default?
         CryptoCipher defaultCipher = CryptoCipherFactory.getCryptoCipher(
                 "AES/CBC/NoPadding", properties);
-        Assert.assertEquals(OpenSslCipher.class.getName(), defaultCipher
-                .getClass().getName());
+        final String name = defaultCipher.getClass().getName();
+        if (OpenSsl.getLoadingFailureReason() == null) {
+            Assert.assertEquals(OpenSslCipher.class.getName(), name);
+        } else {
+            Assert.assertEquals(JceCipher.class.getName(), name);
+        }
     }
 
     @Test(expected = GeneralSecurityException.class)


Mime
View raw message