OpensslCipher { public static OpensslCipher getInstance(String transformation) throws NoSuchAlgorithmException, NoSuchPaddingException { return getInstance(transformation, null); } private  OpensslCipher(long context, int alg, int padding, long engine); static String getLoadingFailureReason(); static OpensslCipher getInstance(String transformation); static OpensslCipher getInstance(
      String transformation, String engineId); void init(int mode, byte[] key, byte[] iv); int update(ByteBuffer input, ByteBuffer output); int doFinal(ByteBuffer output); void clean(); native static String getLibraryName(); static final int ENCRYPT_MODE; static final int DECRYPT_MODE; }
@Test(timeout=120000) public void testGetInstance() throws Exception { Assume.assumeTrue(OpensslCipher.getLoadingFailureReason() == null); OpensslCipher cipher = OpensslCipher.getInstance("AES/CTR/NoPadding"); Assert.assertTrue(cipher != null); try { cipher = OpensslCipher.getInstance("AES2/CTR/NoPadding"); Assert.fail("Should specify correct algorithm."); } catch (NoSuchAlgorithmException e) { } try { cipher = OpensslCipher.getInstance("AES/CTR/NoPadding2"); Assert.fail("Should specify correct padding."); } catch (NoSuchPaddingException e) { } }