@Test
public void testInitialization() throws Exception {

  CredentialProvider cr;
  File msFile = tmpFolder.newFile(Configuration.MASTER_KEY_FILENAME_DEFAULT);
  File mksFile = tmpFolder.newFile(Configuration.MASTER_KEYSTORE_FILENAME_DEFAULT);
  try {
    new CredentialProvider(null, null, true, null);
    Assert.fail("Expected an exception");
  } catch (Throwable t) {
    Assert.assertTrue(t instanceof IllegalArgumentException);
  }
  // Without master key persisted
  cr = new CredentialProvider("blahblah!", msFile, false, mksFile);
  Assert.assertNotNull(cr);
  Assert.assertNotNull(cr.getKeystoreService());
  // With master key persisted
  msFile.delete();
  mksFile.delete();
  createMasterKey();
  cr = new CredentialProvider(null, msFile, true, mksFile);
  Assert.assertNotNull(cr);
  Assert.assertNotNull(cr.getKeystoreService());
}