Search in sources :

Example 1 with LdapEphemeralStore

use of com.zimbra.cs.ephemeral.LdapEphemeralStore in project zm-mailbox by Zimbra.

the class MigrateAttributesTest method testFallbackEphemeralStoreWhenMigrating.

@Test
public void testFallbackEphemeralStoreWhenMigrating() throws Exception {
    EphemeralStore destination = EphemeralStore.getFactory().getStore();
    EntrySource source = new DummyEntrySource(acct);
    Multimap<String, Object> deletedAttrs = LinkedListMultimap.create();
    List<String> attrsToMigrate = Arrays.asList(new String[] { Provisioning.A_zimbraAuthTokens, Provisioning.A_zimbraCsrfTokenData, Provisioning.A_zimbraLastLogonTimestamp });
    //DummyMigrationCallback will store attributes in InMemoryEphemeralStore, and track deletions in deletedAttrs map
    MigrationCallback callback = new DummyMigrationCallback(destination, deletedAttrs);
    AttributeMigration migration = new AttributeMigration(attrsToMigrate, source, callback, null);
    migration.beginMigration();
    //set to in-memory backend because fallback won't be enabled with default LDAP backend
    EphemeralStore.setFactory(InMemoryEphemeralStore.Factory.class);
    Factory factory = EphemeralStore.getFactory();
    EphemeralStore store = factory.getStore();
    //in-memory backend will be wrapped in a FallbackEphemeralStore, with LDAP as the fallback
    assertTrue(store instanceof FallbackEphemeralStore);
    FallbackEphemeralStore fallbackStore = (FallbackEphemeralStore) store;
    assertTrue(fallbackStore.getPrimaryStore() instanceof InMemoryEphemeralStore);
    assertTrue(fallbackStore.getSecondaryStore() instanceof LdapEphemeralStore);
    migration.endMigration();
    EphemeralStore.setFactory(InMemoryEphemeralStore.Factory.class);
    //when migration is finished, fallback won't be enabled anymore
    factory = EphemeralStore.getFactory();
    store = factory.getStore();
    assertTrue(store instanceof InMemoryEphemeralStore);
}
Also used : InMemoryEphemeralStore(com.zimbra.cs.ephemeral.InMemoryEphemeralStore) LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) Factory(com.zimbra.cs.ephemeral.EphemeralStore.Factory) MigrationCallback(com.zimbra.cs.ephemeral.migrate.AttributeMigration.MigrationCallback) EntrySource(com.zimbra.cs.ephemeral.migrate.AttributeMigration.EntrySource) FallbackEphemeralStore(com.zimbra.cs.ephemeral.FallbackEphemeralStore) FallbackEphemeralStore(com.zimbra.cs.ephemeral.FallbackEphemeralStore) LdapEphemeralStore(com.zimbra.cs.ephemeral.LdapEphemeralStore) EphemeralStore(com.zimbra.cs.ephemeral.EphemeralStore) InMemoryEphemeralStore(com.zimbra.cs.ephemeral.InMemoryEphemeralStore) Test(org.junit.Test)

Aggregations

EphemeralStore (com.zimbra.cs.ephemeral.EphemeralStore)1 Factory (com.zimbra.cs.ephemeral.EphemeralStore.Factory)1 FallbackEphemeralStore (com.zimbra.cs.ephemeral.FallbackEphemeralStore)1 InMemoryEphemeralStore (com.zimbra.cs.ephemeral.InMemoryEphemeralStore)1 LdapEphemeralStore (com.zimbra.cs.ephemeral.LdapEphemeralStore)1 EntrySource (com.zimbra.cs.ephemeral.migrate.AttributeMigration.EntrySource)1 MigrationCallback (com.zimbra.cs.ephemeral.migrate.AttributeMigration.MigrationCallback)1 Test (org.junit.Test)1