OrientKeyStoreStorage extends ComponentSupport implements KeyStoreStorage { @Override public void load(final KeyStore keyStore, final char[] password) throws NoSuchAlgorithmException, CertificateException, IOException { OrientKeyStoreData entity = storageManager.load(keyStoreName); checkState(entity != null, "key store %s does not exist", keyStoreName); keyStore.load(new ByteArrayInputStream(entity.getBytes()), password); loadedVersion = entity.getEntityMetadata().getVersion(); log.debug("Loaded version {} of key store {}", loadedVersion, keyStoreName); } OrientKeyStoreStorage(final OrientKeyStoreStorageManager storageManager, final String keyStoreName); @VisibleForTesting String getKeyStoreName(); @Override boolean exists(); @Override boolean modified(); @Subscribe void onKeyStoreDataUpdated(final KeyStoreDataEvent event); @Override void load(final KeyStore keyStore, final char[] password); @Override void save(final KeyStore keyStore, final char[] password); @Override String toString();  }
@Test public void testLoad() throws Exception { OrientKeyStoreData entity = new OrientKeyStoreData(); entity.setName(KEY_STORE_NAME); entity.setBytes(serialize(newKeyStoreWithData())); entity.setEntityMetadata(newEntityMetadata("1")); when(storageManager.load(KEY_STORE_NAME)).thenReturn(entity); KeyStore keyStore = newKeyStore(); storage.load(keyStore, STORE_PASSWORD); assertThat(storage.modified(), is(false)); assertThat(keyStore.containsAlias(CERT_ALIAS), is(true)); }