use of ee.ria.xroad.signer.tokenmanager.merge.TokenMergeAddedCertificatesListener in project X-Road by nordic-institute.
the class TokenManagerMergeTest method shouldAddCertFromFile.
/**
* Test that a key added in the file appears in tokens after merge.
*
* @throws IOException
*/
@Test
public void shouldAddCertFromFile() throws IOException {
assertTrue("test setup failure", Files.exists(ADDED_KEY_FILE_PATH));
final int beforeCertCount = TokenManager.getAllCerts().size();
Files.copy(ADDED_KEY_FILE_PATH, testingFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
TokenMergeAddedCertificatesListener listenerMock = mock(TokenMergeAddedCertificatesListener.class);
TokenManager.merge(listenerMock);
assertEquals("cert amount should be original + 1", beforeCertCount + 1, TokenManager.getAllCerts().size());
verify(listenerMock, times(1)).mergeDone(certListArgumentCaptor.capture());
assertThat("Added certs count mismatch", certListArgumentCaptor.getValue().size(), is(1));
}
Aggregations