title: junit java.security.NoSuchAlgorithmException: Cannot find any provider supporting
body: <p>I'm using JUnit 4 [C:\eclipse\plugins\org.junit_4.11.0.v201303080030\junit.jar] in combination with Eclipse (MARS, Version: Mars Milestone 3 (4.5.0M3) Build id: 20141113-0320.</p>
  
  <p>I have some tests that test a simple class and which work well. But now arrived at the point where I wanted to test my encryption class, which implements the following encrypt function:</p>
  
  <pre><code>public String encrypt(String data) {
  
      try {
  
          SecretKeySpec KS = new SecretKeySpec(mKeyData, "Blowfish");
  
          Cipher cipher = Cipher.getInstance("Blowfish/CBC/ZeroBytePadding"); // PKCS5Padding
          cipher.init(Cipher.ENCRYPT_MODE, KS, new IvParameterSpec(mIv));
          return bytesToHex(cipher.doFinal(data.getBytes()));       
  
      } catch (InvalidKeyException e) {
          e.printStackTrace();
      } catch (NoSuchAlgorithmException e) {
          e.printStackTrace();
      } catch (NoSuchPaddingException e) {
          e.printStackTrace();
      } catch (IllegalBlockSizeException e) {
          e.printStackTrace();
      } catch (BadPaddingException e) {
          e.printStackTrace();
      } catch (InvalidAlgorithmParameterException e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>The Crypto class is not sub classed...</p>
  
  <pre><code>public class Crypto {
  </code></pre>
  
  <p>So to test this Class and more the encrypt function I have designed the following unit test:</p>
  
  <pre><code>package my.junit4.example;
  
  import static org.junit.Assert.*;
  
  import org.junit.Test;
  
  public class CryptoTest {
  
      @Test
      public void testEncryption() {
  
          Crypto myCrypto = new Crypto();
  
          String encodedString = myCrypto.encrypt("Secret");
  
          assertTrue("The decrypted encrypted word should deliver the original string", encodedString.equals(myCrypto.decrypt(encodedString)));
      }
  }
  </code></pre>
  
  <p>This test is failing with a stack trace:</p>
  
  <pre><code>java.security.NoSuchAlgorithmException: Cannot find any provider supporting Blowfish/CBC/ZeroBytePaddingnull
  at javax.crypto.Cipher.getInstance(Cipher.java:535)     at
  my.junit.example.encrypt(Crypto.java:35)    at
  my.junit.example.CryptoTest.testEncrypt(CryptoTest.java:14)     at
  </code></pre>
  
  <p>This didn't make much sense to me. But being relatively new to JUnit I suspect the issue is with me not understanding how to formulate these tests. The code works well encryption - decryption in my debugger is giving me the desired outcome. But how can I get this to work with JUnit. What obvious mistake I have made?</p>