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 2021/02/28 17:30:30 UTC

[commons-crypto] branch master updated: Raise embedded if into parent if.

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


The following commit(s) were added to refs/heads/master by this push:
     new baa0d8f  Raise embedded if into parent if.
baa0d8f is described below

commit baa0d8fd73ee4756f1ae397afbdce8db0a9a2580
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Feb 28 12:30:26 2021 -0500

    Raise embedded if into parent if.
---
 .../crypto/stream/AbstractCipherStreamTest.java    | 46 ++++++++--------------
 .../commons/crypto/stream/CtrCryptoStreamTest.java |  6 +--
 2 files changed, 18 insertions(+), 34 deletions(-)

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 6b75cb7..0f370bd 100644
--- a/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/AbstractCipherStreamTest.java
@@ -138,10 +138,8 @@ public abstract class AbstractCipherStreamTest {
 
     protected void doSkipTest(final String cipherClass, final boolean withChannel)
             throws IOException {
-        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
-            if (!Crypto.isNativeCodeLoaded()) {
-                return; // Skip this test if no JNI
-            }
+        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass) && !Crypto.isNativeCodeLoaded()) {
+            return; // Skip this test if no JNI
         }
         try (@SuppressWarnings("resource") // The CryptoCipher returned by getCipherInstance() is closed by CryptoInputStream.
         InputStream in = newCryptoInputStream(
@@ -173,10 +171,8 @@ public abstract class AbstractCipherStreamTest {
 
     protected void doByteBufferRead(final String cipherClass, final boolean withChannel)
         throws Exception {
-        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
-            if (!Crypto.isNativeCodeLoaded()) {
-                return; // Skip this test if no JNI
-            }
+        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass) && !Crypto.isNativeCodeLoaded()) {
+            return; // Skip this test if no JNI
         }
         ByteBuffer buf = ByteBuffer.allocate(dataLen + 100);
         // Default buffer size, initial buffer position is 0
@@ -322,10 +318,8 @@ public abstract class AbstractCipherStreamTest {
     protected void doByteBufferWrite(final String cipherClass,
             final ByteArrayOutputStream baos, final boolean withChannel)
                 throws Exception {
-        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
-            if (!Crypto.isNativeCodeLoaded()) {
-                return; // Skip this test if no JNI
-            }
+        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass) && !Crypto.isNativeCodeLoaded()) {
+            return; // Skip this test if no JNI
         }
         baos.reset();
         CryptoOutputStream out = newCryptoOutputStream(baos,
@@ -349,10 +343,8 @@ public abstract class AbstractCipherStreamTest {
 
     protected void doExceptionTest(final String cipherClass, final ByteArrayOutputStream baos,
             final boolean withChannel) throws IOException {
-        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
-            if (!Crypto.isNativeCodeLoaded()) {
-                return; // Skip this test if no JNI
-            }
+        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass) && !Crypto.isNativeCodeLoaded()) {
+            return; // Skip this test if no JNI
         }
 
         // Test InvalidAlgorithmParameters
@@ -421,10 +413,8 @@ public abstract class AbstractCipherStreamTest {
 
     protected void doFieldGetterTest(final String cipherClass, final ByteArrayOutputStream baos,
         final boolean withChannel) throws Exception {
-        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
-            if (!Crypto.isNativeCodeLoaded()) {
-                return; // Skip this test if no JNI
-            }
+        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass) && !Crypto.isNativeCodeLoaded()) {
+            return; // Skip this test if no JNI
         }
 
         final CryptoCipher cipher = getCipher(cipherClass);
@@ -651,12 +641,10 @@ public abstract class AbstractCipherStreamTest {
     private void doReadWriteTestForInputStream(final int count,
             final String encCipherClass, final String decCipherClass, final byte[] iv)
             throws IOException {
-        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(encCipherClass)
+        if ((AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(encCipherClass)
                 ||
-            AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(decCipherClass)) {
-            if (!Crypto.isNativeCodeLoaded()) {
-                return; // Skip this test if no JNI
-            }
+            AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(decCipherClass)) && !Crypto.isNativeCodeLoaded()) {
+            return; // Skip this test if no JNI
         }
         // Created a cipher object of type encCipherClass;
         final CryptoCipher encCipher = getCipher(encCipherClass);
@@ -717,12 +705,10 @@ public abstract class AbstractCipherStreamTest {
     private void doReadWriteTestForReadableByteChannel(final int count,
             final String encCipherClass, final String decCipherClass, final byte[] iv)
             throws IOException {
-        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(encCipherClass)
+        if ((AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(encCipherClass)
                 ||
-            AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(decCipherClass)) {
-            if (!Crypto.isNativeCodeLoaded()) {
-                return; // Skip this test if no JNI
-            }
+            AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(decCipherClass)) && !Crypto.isNativeCodeLoaded()) {
+            return; // Skip this test if no JNI
         }
         // Creates a cipher object of type encCipherClass;
         final CryptoCipher encCipher = getCipher(encCipherClass);
diff --git a/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java
index 38a2eba..bc0b057 100644
--- a/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java
+++ b/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java
@@ -96,10 +96,8 @@ public class CtrCryptoStreamTest extends AbstractCipherStreamTest {
     @Override
     protected void doFieldGetterTest(final String cipherClass, final ByteArrayOutputStream baos,
             final boolean withChannel) throws Exception {
-        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass)) {
-            if (!Crypto.isNativeCodeLoaded()) {
-                return; // Skip this test if no JNI
-            }
+        if (AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME.equals(cipherClass) && !Crypto.isNativeCodeLoaded()) {
+            return; // Skip this test if no JNI
         }
 
         final StreamInput streamInput = new StreamInput(new ByteArrayInputStream(encData), 0);