    @Test
    public void shouldCreateInitializeAndPersistCredentialStore() throws Exception {

        final File storeFile = new File(tmp.getRoot(), "credential.store");

        Session session = mock(Session.class);
        when(session.readLine(anyString(), anyChar())).thenReturn("test");

        final CreateCredentialStore command = new CreateCredentialStore();

        command.credentialStoreService = credentialStoreService;
        command.iterationCount = 1000;
        command.location = storeFile.getAbsolutePath();
        command.algorithm = "masked-MD5-DES";
        command.session = session;
        command.persistConfiguration = true;
        command.force = true;

        final PrintStream original = System.out;
        try {
            final ByteArrayOutputStream capture = new ByteArrayOutputStream();

            System.setOut(new PrintStream(capture));

            command.execute();
        } finally {
            System.setOut(original);
        }

        assertThat(storeFile).exists().isFile();

        StoreInCredentialStore store = new StoreInCredentialStore();
        store.credentialStoreService = credentialStoreService;
        store.alias = "my.password";
        store.secret = "sec4et";
        store.execute();

        String credential = credentialStoreService.retrievePassword("my.password");
        assertNotNull(credential);
    }