use of com.zimbra.cs.ephemeral.FallbackEphemeralStore 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);
}
Aggregations