aremily commented on a change in pull request #99:
URL: https://github.com/apache/commons-crypto/pull/99#discussion_r416101439



##########
File path: 
src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java
##########
@@ -52,4 +75,115 @@ protected CtrCryptoOutputStream getCryptoOutputStream(
         }
         return new CtrCryptoOutputStream(baos, cipher, bufferSize, key, iv);
     }
+    
+    @Override
+    protected CtrCryptoOutputStream getCryptoOutputStream(final String 
transformation,
+            final Properties props, final ByteArrayOutputStream baos, final 
byte[] key, 
+            final AlgorithmParameterSpec params, final boolean withChannel) 
throws IOException {
+        if (withChannel) {
+            return new CtrCryptoOutputStream(props, Channels.newChannel(baos), 
key, 
+                    ((IvParameterSpec)params).getIV());
+        }
+        return new CtrCryptoOutputStream(props, baos, 
key,((IvParameterSpec)params).getIV());
+    }
+    
+    @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
+            }
+        }
+        
+        StreamInput streamInput = new StreamInput(new 
ByteArrayInputStream(encData), 0);
+        try {
+            streamInput.seek(0);
+            Assert.fail("Expected UnsupportedOperationException.");
+        } catch (UnsupportedOperationException ex) {
+               Assert.assertEquals(ex.getMessage(), "Seek is not supported by 
this implementation");

Review comment:
       In this case I believe it would be enough.  IIRC, I was following an 
existing pattern for other tests which covered cases where different exceptions 
were caught, wrapped into a common exception and thrown as that more general 
exception, which was then only differentiated by the message.  I don't think 
it's hurting anything but I have no issue with you removing it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to