import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-
import com.google.common.base.Optional;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.controller.cluster.datastore.modification.ModificationPayload;
import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
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;
peopleSchemaContext = SchemaContextHelper.select(SchemaContextHelper.PEOPLE_YANG);
carsSchemaContext = SchemaContextHelper.select(SchemaContextHelper.CARS_YANG);
- peopleDataTree = new ShardDataTree(peopleSchemaContext);
+ peopleDataTree = new ShardDataTree(peopleSchemaContext, TreeType.OPERATIONAL);
}
@Test
public void testAppendRecoveredLogEntryDataTreeCandidatePayload(){
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo"));
+ final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
+ peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
coordinator.startLogRecoveryBatch(10);
try {
coordinator.appendRecoveredLogEntry(DataTreeCandidatePayload.create(createCar()));
coordinator.applyCurrentLogRecoveryBatch();
}
- @Test
- public void testAppendRecoveredLogEntryModificationPayload() throws IOException {
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo"));
- coordinator.startLogRecoveryBatch(10);
- try {
- final MutableCompositeModification modification = new MutableCompositeModification((short) 1);
- modification.addModification(new WriteModification(CarsModel.BASE_PATH, CarsModel.create()));
- coordinator.appendRecoveredLogEntry(new ModificationPayload(modification));
- } catch(final SchemaValidationFailedException e){
- fail("SchemaValidationFailedException should not happen if pruning is done");
- }
- }
-
@Test
public void testAppendRecoveredLogEntryCompositeModificationPayload() throws IOException {
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo"));
+ final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
+ peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
coordinator.startLogRecoveryBatch(10);
try {
final MutableCompositeModification modification = new MutableCompositeModification((short) 1);
@Test
public void testAppendRecoveredLogEntryCompositeModificationByteStringPayload() throws IOException {
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo"));
+ final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
+ peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
coordinator.startLogRecoveryBatch(10);
try {
final MutableCompositeModification modification = new MutableCompositeModification((short) 1);
@Test
public void testApplyRecoverySnapshot(){
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree , peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo"));
+ final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
+ peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
coordinator.startLogRecoveryBatch(10);
coordinator.applyRecoverySnapshot(createSnapshot());
@Test
public void testApplyCurrentLogRecoveryBatch(){
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo"));
+ final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
+ peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
coordinator.startLogRecoveryBatch(10);
try {
}
private DataTreeCandidateTip createCar(){
- final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create();
+ final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
dataTree.setSchemaContext(carsSchemaContext);
final DataTreeSnapshot snapshot = dataTree.takeSnapshot();
}
private static byte[] createSnapshot(){
- final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create();
+ final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
dataTree.setSchemaContext(SchemaContextHelper.select(SchemaContextHelper.CARS_YANG, SchemaContextHelper.PEOPLE_YANG));
DataTreeSnapshot snapshot = dataTree.takeSnapshot();