X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardRecoveryCoordinatorTest.java;h=acac104c7972bdad01efab6d5fff4a7f6b85c8d9;hp=4a8363c866d68977e0051c9bc9724a377fecce12;hb=a47dd7a5d21ca68804a6d0e2e3ca765f223c2ef4;hpb=ba87ed620f13823ee798fda4241a2c1db37e2f33 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java index 4a8363c866..acac104c79 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java @@ -14,8 +14,9 @@ import com.google.common.base.Optional; import java.io.IOException; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload; -import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils; +import org.opendaylight.controller.cluster.datastore.persisted.PreBoronShardDataTreeSnapshot; import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; @@ -42,14 +43,16 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { peopleSchemaContext = SchemaContextHelper.select(SchemaContextHelper.PEOPLE_YANG); carsSchemaContext = SchemaContextHelper.select(SchemaContextHelper.CARS_YANG); - peopleDataTree = new ShardDataTree(peopleSchemaContext, TreeType.OPERATIONAL); + final Shard mockShard = Mockito.mock(Shard.class); + + peopleDataTree = new ShardDataTree(mockShard, peopleSchemaContext, TreeType.OPERATIONAL); } @Deprecated @Test public void testAppendRecoveredLogEntryDataTreeCandidatePayload(){ final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, - peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); + null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { coordinator.appendRecoveredLogEntry(DataTreeCandidatePayload.create(createCar())); @@ -63,7 +66,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { @Test public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException { final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, - peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); + null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar())); @@ -77,7 +80,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { @Test public void testApplyRecoverySnapshot(){ final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, - peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); + null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); coordinator.applyRecoverySnapshot(createSnapshot()); @@ -90,7 +93,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { @Test public void testApplyCurrentLogRecoveryBatch(){ final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, - peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); + null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { @@ -140,18 +143,9 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { modification.merge(CarsModel.BASE_PATH, CarsModel.create()); modification.merge(PeopleModel.BASE_PATH, PeopleModel.create()); modification.ready(); - final DataTreeCandidateTip prepare = dataTree.prepare(modification); - - dataTree.commit(prepare); - - snapshot = dataTree.takeSnapshot(); - - modification = snapshot.newModification(); - - final Optional> optional = modification.readNode(YangInstanceIdentifier.EMPTY); - - final byte[] bytes = SerializationUtils.serializeNormalizedNode(optional.get()); + dataTree.commit(dataTree.prepare(modification)); - return bytes; + return new PreBoronShardDataTreeSnapshot(dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY).get()) + .serialize(); } } \ No newline at end of file