package org.opendaylight.controller.cluster.datastore;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.base.Optional;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShardRecoveryCoordinatorTest extends AbstractTest {
+ private static final Logger FOO_LOGGER = LoggerFactory.getLogger("foo");
private ShardDataTree peopleDataTree;
private SchemaContext peopleSchemaContext;
private SchemaContext carsSchemaContext;
+ private ShardRecoveryCoordinator coordinator;
@Before
public void setUp() {
final Shard mockShard = Mockito.mock(Shard.class);
peopleDataTree = new ShardDataTree(mockShard, peopleSchemaContext, TreeType.OPERATIONAL);
+ coordinator = ShardRecoveryCoordinator.create(peopleDataTree, "foobar", FOO_LOGGER);
+ coordinator.startLogRecoveryBatch(10);
}
@Test
public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException {
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
- null, "foobar", LoggerFactory.getLogger("foo"));
- coordinator.startLogRecoveryBatch(10);
try {
coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar()));
} catch (final SchemaValidationFailedException e) {
@Test
public void testApplyRecoverySnapshot() {
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
- null, "foobar", LoggerFactory.getLogger("foo"));
- coordinator.startLogRecoveryBatch(10);
-
coordinator.applyRecoverySnapshot(createSnapshot());
- assertEquals(false, readCars(peopleDataTree).isPresent());
- assertEquals(true, readPeople(peopleDataTree).isPresent());
+ assertFalse(readCars(peopleDataTree).isPresent());
+ assertTrue(readPeople(peopleDataTree).isPresent());
}
@Test
public void testApplyCurrentLogRecoveryBatch() {
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
- null, "foobar", LoggerFactory.getLogger("foo"));
- coordinator.startLogRecoveryBatch(10);
-
try {
coordinator.applyCurrentLogRecoveryBatch();
} catch (final IllegalArgumentException e) {