CryptoException extends RuntimeException { public int getCode() { return code; } CryptoException();  CryptoException(String message);  CryptoException(int code, final String message);  CryptoException(NoSuchAlgorithmException e);  CryptoException(InvalidKeyException e);  CryptoException(NoSuchProviderException e);  CryptoException(SignatureException e);  CryptoException(FileNotFoundException e);  CryptoException(IOException e);  CryptoException(CertificateException e);  CryptoException(InvalidKeySpecException e);  CryptoException(OperatorCreationException e);  CryptoException(PKCSException e);  CryptoException(CMSException e); int getCode(); static final int CRYPTO_ERROR; static final int CERT_HASH_MISMATCH; }
@Test public void testCryptoExceptions() { CryptoException ex = new CryptoException(); assertNotNull(ex); assertEquals(ex.getCode(), CryptoException.CRYPTO_ERROR); assertNotNull(new CryptoException(new NoSuchAlgorithmException())); assertNotNull(new CryptoException(new InvalidKeyException())); assertNotNull(new CryptoException(new NoSuchProviderException())); assertNotNull(new CryptoException(new SignatureException())); assertNotNull(new CryptoException(new FileNotFoundException())); assertNotNull(new CryptoException(new IOException())); assertNotNull(new CryptoException(new CertificateException())); assertNotNull(new CryptoException(new InvalidKeySpecException())); assertNotNull(new CryptoException(new OperatorCreationException("unit-test"))); assertNotNull(new CryptoException(new PKCSException("unit-test"))); assertNotNull(new CryptoException(new CMSException("unit-test"))); ex = new CryptoException(CryptoException.CERT_HASH_MISMATCH, "X.509 Certificate hash mismatch"); assertEquals(ex.getCode(), CryptoException.CERT_HASH_MISMATCH); }