Index: trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java =================================================================== --- trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java (revision 431486) +++ trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java (working copy) @@ -29,6 +29,7 @@ import java.util.Arrays; import javax.crypto.Cipher; +import javax.crypto.CipherSpi; import javax.crypto.KeyGenerator; import javax.crypto.SecretKeyFactory; import javax.crypto.ShortBufferException; @@ -433,5 +434,57 @@ } catch (NoSuchAlgorithmException e) { } } - + /** + * @tests javax.crypto.Cipher#Cipher(CipherSpi cipherSpi, Provider provider, String transformation) + */ + public void test_Ctor() throws Exception { + // regression test for Harmony-1184 + try { + new testCipher(null, null, "s"); + fail("NullPointerException expected"); + } catch (NullPointerException e) { + //expected + } + try { + new testCipher(new testCipherSpi(), null, "s"); + fail("NullPointerException expected for 'null' provider"); + } catch (NullPointerException e) { + //expected + } + try { + new testCipher(null, new testProvider(), "s"); + fail("NullPointerException expected for 'null' cipherSpi"); + } catch (NullPointerException e) { + //expected + } + } + class testCipher extends Cipher { + testCipher(CipherSpi c, Provider p, String s){ + super(c, p, s); + } + } + class testCipherSpi extends CipherSpi { + testCipherSpi() { + super(); + } + public byte[] engineDoFinal(byte[] input,int inputOffset,int inputLen) throws IllegalBlockSizeException,BadPaddingException {return null;} + public int engineDoFinal(byte[] input,int inputOffset,int inputLen,byte[] output,int outputOffset) throws ShortBufferException,IllegalBlockSizeException,BadPaddingException {return 0;} + public int engineUpdate(byte[] input,int inputOffset,int inputLen,byte[] output,int outputOffset) throws ShortBufferException {return 0;} + public byte[] engineUpdate(byte[] input,int inputOffset,int inputLen) {return null;} + public void engineInit(int opmode,Key key,AlgorithmParameters params,SecureRandom random) throws InvalidKeyException,InvalidAlgorithmParameterException {} + public void engineInit(int opmode,Key key,AlgorithmParameterSpec params,SecureRandom random) throws InvalidKeyException,InvalidAlgorithmParameterException {} + public void engineInit(int opmode,Key key,SecureRandom random) throws InvalidKeyException {} + public AlgorithmParameters engineGetParameters() {return null;} + public byte[] engineGetIV() {return null;} + public int engineGetOutputSize(int inputLen) {return 0;} + public int engineGetBlockSize() {return 0;} + public void engineSetPadding(String padding) throws NoSuchPaddingException {} + public void engineSetMode(String mode) throws NoSuchAlgorithmException {} + } + class testProvider extends Provider { + testProvider(){ + super("qwerty", 1.0, "qwerty"); + } + } + }