GeneratedKeystoreProvider implements IKeystoreProvider { @Override public void writeTo(final OutputStream outputStream) { getKeyStore(); generatedProvider.writeTo(outputStream); } GeneratedKeystoreProvider(final String workingDirectory);  GeneratedKeystoreProvider(final String workingDirectory,
                                     final String keystorePass,
                                     final String certificatePass,
                                     final String alias); KeyStore getKeyStore(); @Override void writeTo(final OutputStream outputStream);  }
@Test public void testWriteTo() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); provider.getKeyStore(); provider.writeTo(baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); KeyStore keyStore = KeyStore.getInstance("PKCS12"); keyStore.load(bais, "kangaroo".toCharArray()); assertEquals("kangaroo", keyStore.aliases().nextElement()); }