use of org.opendaylight.controller.config.persist.impl.PersisterAggregator.PersisterWithConfiguration in project controller by opendaylight.
the class PersisterAggregatorTest method testLoadFromPropertyFile.
@Test
public void testLoadFromPropertyFile() throws Exception {
PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(TestingPropertiesProvider.loadFile("test2.properties"));
List<PersisterWithConfiguration> persisters = persisterAggregator.getPersisterWithConfigurations();
assertEquals(1, persisters.size());
PersisterWithConfiguration persister = persisters.get(0);
assertEquals(XmlFileStorageAdapter.class.getName(), persister.getStorage().getClass().getName());
assertFalse(persister.isReadOnly());
}
use of org.opendaylight.controller.config.persist.impl.PersisterAggregator.PersisterWithConfiguration in project controller by opendaylight.
the class PersisterAggregatorTest method loadLastConfig.
@Test
public void loadLastConfig() throws Exception {
List<PersisterWithConfiguration> persisterWithConfigurations = new ArrayList<>();
PersisterWithConfiguration first = new PersisterWithConfiguration(mockPersister("p0"), false);
ConfigSnapshotHolder ignored = mockHolder("ignored");
// should be ignored
doReturn(Arrays.asList(ignored)).when(first.getStorage()).loadLastConfigs();
ConfigSnapshotHolder used = mockHolder("used");
PersisterWithConfiguration second = new PersisterWithConfiguration(mockPersister("p1"), false);
// should be used
doReturn(Arrays.asList(used)).when(second.getStorage()).loadLastConfigs();
PersisterWithConfiguration third = new PersisterWithConfiguration(mockPersister("p2"), false);
doReturn(Arrays.asList()).when(third.getStorage()).loadLastConfigs();
persisterWithConfigurations.add(first);
persisterWithConfigurations.add(second);
persisterWithConfigurations.add(third);
try (PersisterAggregator persisterAggregator = new PersisterAggregator(persisterWithConfigurations)) {
List<ConfigSnapshotHolder> configSnapshotHolderOptional = persisterAggregator.loadLastConfigs();
assertEquals(1, configSnapshotHolderOptional.size());
assertEquals(used, configSnapshotHolderOptional.get(0));
}
}
use of org.opendaylight.controller.config.persist.impl.PersisterAggregator.PersisterWithConfiguration in project controller by opendaylight.
the class PersisterAggregatorTest method testDummyAdapter.
@Test
public void testDummyAdapter() throws Exception {
PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(TestingPropertiesProvider.loadFile("test1.properties"));
List<PersisterWithConfiguration> persisters = persisterAggregator.getPersisterWithConfigurations();
assertEquals(1, persisters.size());
PersisterWithConfiguration persister = persisters.get(0);
assertEquals(DummyAdapter.class.getName(), persister.getStorage().getClass().getName());
assertFalse(persister.isReadOnly());
persisterAggregator.persistConfig(null);
persisterAggregator.loadLastConfigs();
persisterAggregator.persistConfig(null);
persisterAggregator.loadLastConfigs();
assertEquals(2, DummyAdapter.persist);
assertEquals(2, DummyAdapter.load);
assertEquals(1, DummyAdapter.props);
}
Aggregations