BCHelper { public static MessageDigest getMessageDigest(String algorithm) throws NoSuchAlgorithmException { try { return MessageDigest.getInstance(algorithm, BouncyCastleProvider.PROVIDER_NAME); } catch (NoSuchProviderException e) { throw new NoSuchAlgorithmException(e.getMessage(), e); } }  static void registerProvider(); static MessageDigest getMessageDigest(String algorithm);  }
@Test(expectedExceptions = NoSuchAlgorithmException.class) public void triggerExceptionWhenProviderIsNotFound() throws Exception { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); BCHelper.getMessageDigest("SHA-512"); }