Repository: commons-crypto
Updated Branches:
  refs/heads/master 3cfaa0271 -> d4e04f5ef


[CRYPTO-52] Improve assertion message when test fails due to lack of JCE
Unlimited Strength Jurisdiction Policy Files. Applied patch and changed
@Before to @BeforeClass.

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

Branch: refs/heads/master
Commit: d4e04f5ef925d8e168869a08dfa2e2ccc37a53ba
Parents: 3cfaa02
Author: ggregory <ggreg...@apache.org>
Authored: Wed May 4 12:11:15 2016 -0700
Committer: ggregory <ggreg...@apache.org>
Committed: Wed May 4 12:11:15 2016 -0700

----------------------------------------------------------------------
 .../commons/crypto/cipher/JceCipherTest.java    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/d4e04f5e/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java 
b/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java
index 9a0f9cd..46bd634 100644
--- a/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java
+++ b/src/test/java/org/apache/commons/crypto/cipher/JceCipherTest.java
@@ -18,8 +18,17 @@
 
 package org.apache.commons.crypto.cipher;
 
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.Cipher;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
 public class JceCipherTest extends AbstractCipherTest {
 
+    private static final int MAX_KEY_LEN_LOWER_BOUND = 256;
+
     @Override
     public void init() {
         transformations = new CipherTransformation[] {
@@ -29,4 +38,15 @@ public class JceCipherTest extends AbstractCipherTest {
         cipherClass = JceCipher.class.getName();
     }
 
+    @BeforeClass
+    public void checkJceUnlimitedStrength() throws NoSuchAlgorithmException {
+        int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
+        Assert.assertTrue(String.format(
+                "Testing requires support for an AES key length of %d, but " +
+                "the detected maximum key length is %d.  This may indicate " +
+                "that the test environment is missing the JCE Unlimited " +
+                "Strength Jurisdiction Policy Files.",
+                MAX_KEY_LEN_LOWER_BOUND, maxKeyLen),
+                maxKeyLen >= MAX_KEY_LEN_LOWER_BOUND);
+    }
 }

Reply via email to