@Test
public void testAddCACertificateToTrustStoreBadStore() throws Exception {

    thrown.expect(CryptoException.class);
    thrown.expectMessage("Unable to add");
    // Create an uninitialized key store
    KeyStore tmpKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    // Ensure that crypto is using that store
    KeyStore saveKeyStore = (KeyStore) setField(crypto, "trustStore", tmpKeyStore);
    try {
        crypto.addCACertificateToTrustStore(testCACert, "alias");
    } finally {
        // Ensure we set it back so that subsequent tests will not be affected
        setField(crypto, "trustStore", saveKeyStore);
    }
}