You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2016/06/25 13:47:18 UTC
commons-crypto git commit: Use the AbstractCipherTest constants
Repository: commons-crypto
Updated Branches:
refs/heads/master 25455430f -> 7b9402712
Use the AbstractCipherTest constants
Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/7b940271
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/7b940271
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/7b940271
Branch: refs/heads/master
Commit: 7b9402712c3b8d61697a94538b41008f17d64fdc
Parents: 2545543
Author: Sebb <se...@apache.org>
Authored: Sat Jun 25 14:47:14 2016 +0100
Committer: Sebb <se...@apache.org>
Committed: Sat Jun 25 14:47:14 2016 +0100
----------------------------------------------------------------------
.../crypto/stream/AbstractCipherStreamTest.java | 51 +++++++++-----------
.../stream/PositionedCryptoInputStreamTest.java | 11 ++---
2 files changed, 28 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/7b940271/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
index bb587f4..34274e4 100644
--- a/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
@@ -33,9 +33,8 @@ import java.util.Random;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
+import org.apache.commons.crypto.cipher.AbstractCipherTest;
import org.apache.commons.crypto.cipher.CryptoCipher;
-import org.apache.commons.crypto.cipher.JceCipher;
-import org.apache.commons.crypto.cipher.OpensslCipher;
import org.apache.commons.crypto.utils.ReflectionUtils;
import org.junit.Assert;
import org.junit.Before;
@@ -53,8 +52,6 @@ public abstract class AbstractCipherStreamTest {
protected static int defaultBufferSize = 8192;
protected static int smallBufferSize = 1024;
- private final String jceCipherClass = JceCipher.class.getName();
- private final String opensslCipherClass = OpensslCipher.class.getName();
protected String transformation;
public abstract void setUp() throws IOException;
@@ -72,32 +69,32 @@ public abstract class AbstractCipherStreamTest {
/** Test skip. */
@Test(timeout = 120000)
public void testSkip() throws Exception {
- doSkipTest(jceCipherClass, false);
- doSkipTest(opensslCipherClass, false);
+ doSkipTest(AbstractCipherTest.JCE_CIPHER_CLASSNAME, false);
+ doSkipTest(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, false);
- doSkipTest(jceCipherClass, true);
- doSkipTest(opensslCipherClass, true);
+ doSkipTest(AbstractCipherTest.JCE_CIPHER_CLASSNAME, true);
+ doSkipTest(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, true);
}
/** Test byte buffer read with different buffer size. */
@Test(timeout = 120000)
public void testByteBufferRead() throws Exception {
- doByteBufferRead(jceCipherClass, false);
- doByteBufferRead(opensslCipherClass, false);
+ doByteBufferRead(AbstractCipherTest.JCE_CIPHER_CLASSNAME, false);
+ doByteBufferRead(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, false);
- doByteBufferRead(jceCipherClass, true);
- doByteBufferRead(opensslCipherClass, true);
+ doByteBufferRead(AbstractCipherTest.JCE_CIPHER_CLASSNAME, true);
+ doByteBufferRead(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, true);
}
/** Test byte buffer write. */
@Test(timeout = 120000)
public void testByteBufferWrite() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- doByteBufferWrite(jceCipherClass, baos, false);
- doByteBufferWrite(opensslCipherClass, baos, false);
+ doByteBufferWrite(AbstractCipherTest.JCE_CIPHER_CLASSNAME, baos, false);
+ doByteBufferWrite(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, baos, false);
- doByteBufferWrite(jceCipherClass, baos, true);
- doByteBufferWrite(opensslCipherClass, baos, true);
+ doByteBufferWrite(AbstractCipherTest.JCE_CIPHER_CLASSNAME, baos, true);
+ doByteBufferWrite(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, baos, true);
}
private void doSkipTest(String cipherClass, boolean withChannel)
@@ -242,7 +239,7 @@ public abstract class AbstractCipherStreamTest {
CryptoCipher cipher = null;
try {
cipher = (CryptoCipher) ReflectionUtils.newInstance(
- ReflectionUtils.getClassByName(jceCipherClass), props,
+ ReflectionUtils.getClassByName(AbstractCipherTest.JCE_CIPHER_CLASSNAME), props,
transformation);
} catch (ClassNotFoundException cnfe) {
throw new IOException("Illegal crypto cipher!");
@@ -309,20 +306,20 @@ public abstract class AbstractCipherStreamTest {
@Test
public void testReadWrite() throws Exception {
- doReadWriteTest(0, jceCipherClass, jceCipherClass, iv);
- doReadWriteTest(0, opensslCipherClass, opensslCipherClass, iv);
- doReadWriteTest(count, jceCipherClass, jceCipherClass, iv);
- doReadWriteTest(count, opensslCipherClass, opensslCipherClass, iv);
- doReadWriteTest(count, jceCipherClass, opensslCipherClass, iv);
- doReadWriteTest(count, opensslCipherClass, jceCipherClass, iv);
+ doReadWriteTest(0, AbstractCipherTest.JCE_CIPHER_CLASSNAME, AbstractCipherTest.JCE_CIPHER_CLASSNAME, iv);
+ doReadWriteTest(0, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, iv);
+ doReadWriteTest(count, AbstractCipherTest.JCE_CIPHER_CLASSNAME, AbstractCipherTest.JCE_CIPHER_CLASSNAME, iv);
+ doReadWriteTest(count, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, iv);
+ doReadWriteTest(count, AbstractCipherTest.JCE_CIPHER_CLASSNAME, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, iv);
+ doReadWriteTest(count, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, AbstractCipherTest.JCE_CIPHER_CLASSNAME, iv);
// Overflow test, IV: xx xx xx xx xx xx xx xx ff ff ff ff ff ff ff ff
for (int i = 0; i < 8; i++) {
iv[8 + i] = (byte) 0xff;
}
- doReadWriteTest(count, jceCipherClass, jceCipherClass, iv);
- doReadWriteTest(count, opensslCipherClass, opensslCipherClass, iv);
- doReadWriteTest(count, jceCipherClass, opensslCipherClass, iv);
- doReadWriteTest(count, opensslCipherClass, jceCipherClass, iv);
+ doReadWriteTest(count, AbstractCipherTest.JCE_CIPHER_CLASSNAME, AbstractCipherTest.JCE_CIPHER_CLASSNAME, iv);
+ doReadWriteTest(count, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, iv);
+ doReadWriteTest(count, AbstractCipherTest.JCE_CIPHER_CLASSNAME, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, iv);
+ doReadWriteTest(count, AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, AbstractCipherTest.JCE_CIPHER_CLASSNAME, iv);
}
private void doReadWriteTest(int count, String encCipherClass,
http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/7b940271/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
index a9c11e4..758c095 100644
--- a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java
@@ -18,9 +18,8 @@
package org.apache.commons.crypto.stream;
+import org.apache.commons.crypto.cipher.AbstractCipherTest;
import org.apache.commons.crypto.cipher.CryptoCipher;
-import org.apache.commons.crypto.cipher.JceCipher;
-import org.apache.commons.crypto.cipher.OpensslCipher;
import org.apache.commons.crypto.stream.input.Input;
import org.apache.commons.crypto.utils.ReflectionUtils;
import org.junit.Assert;
@@ -53,8 +52,6 @@ public class PositionedCryptoInputStreamTest {
int lengthLess = length - 1;
int lengthMore = length + 1;
- private final String jceCipherClass = JceCipher.class.getName();
- private final String opensslCipherClass = OpensslCipher.class.getName();
private String transformation = "AES/CTR/NoPadding";
@Before
@@ -70,7 +67,7 @@ public class PositionedCryptoInputStreamTest {
CryptoCipher cipher = null;
try {
cipher = (CryptoCipher) ReflectionUtils.newInstance(
- ReflectionUtils.getClassByName(jceCipherClass), props,
+ ReflectionUtils.getClassByName(AbstractCipherTest.JCE_CIPHER_CLASSNAME), props,
transformation);
} catch (ClassNotFoundException cnfe) {
throw new IOException("Illegal crypto cipher!");
@@ -98,8 +95,8 @@ public class PositionedCryptoInputStreamTest {
@Test
public void doTest() throws Exception {
- testCipher(jceCipherClass);
- testCipher(opensslCipherClass);
+ testCipher(AbstractCipherTest.JCE_CIPHER_CLASSNAME);
+ testCipher(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME);
}
private void testCipher(String cipherClass) throws Exception {