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=736e29170364bf0af6a6f3ecdffcdcd69125311d;hp=acac104c7972bdad01efab6d5fff4a7f6b85c8d9;hb=7204c455a1636a7fc89bcd28fe9e9000eaa81b3b;hpb=a47dd7a5d21ca68804a6d0e2e3ca765f223c2ef4 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 acac104c79..736e291703 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 @@ -10,13 +10,15 @@ package org.opendaylight.controller.cluster.datastore; 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.mockito.Mockito; import org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload; -import org.opendaylight.controller.cluster.datastore.persisted.PreBoronShardDataTreeSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState; 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; @@ -39,7 +41,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { private SchemaContext carsSchemaContext; @Before - public void setUp(){ + public void setUp() { peopleSchemaContext = SchemaContextHelper.select(SchemaContextHelper.PEOPLE_YANG); carsSchemaContext = SchemaContextHelper.select(SchemaContextHelper.CARS_YANG); @@ -50,13 +52,13 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { @Deprecated @Test - public void testAppendRecoveredLogEntryDataTreeCandidatePayload(){ + public void testAppendRecoveredLogEntryDataTreeCandidatePayload() { final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { coordinator.appendRecoveredLogEntry(DataTreeCandidatePayload.create(createCar())); - } catch(final SchemaValidationFailedException e){ + } catch (final SchemaValidationFailedException e) { fail("SchemaValidationFailedException should not happen if pruning is done"); } @@ -70,7 +72,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { coordinator.startLogRecoveryBatch(10); try { coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar())); - } catch(final SchemaValidationFailedException e){ + } catch (final SchemaValidationFailedException e) { fail("SchemaValidationFailedException should not happen if pruning is done"); } @@ -78,7 +80,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { } @Test - public void testApplyRecoverySnapshot(){ + public void testApplyRecoverySnapshot() { final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); @@ -91,19 +93,19 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { @Test - public void testApplyCurrentLogRecoveryBatch(){ + public void testApplyCurrentLogRecoveryBatch() { final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { coordinator.applyCurrentLogRecoveryBatch(); - } catch(final IllegalArgumentException e){ + } catch (final IllegalArgumentException e) { fail("IllegalArgumentException should not happen - if the pruning modification delegate is passed"); } } - private DataTreeCandidateTip createCar(){ + private DataTreeCandidateTip createCar() { final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); dataTree.setSchemaContext(carsSchemaContext); @@ -116,7 +118,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { return dataTree.prepare(modification); } - private Optional> readCars(final ShardDataTree shardDataTree){ + private Optional> readCars(final ShardDataTree shardDataTree) { final TipProducingDataTree dataTree = shardDataTree.getDataTree(); // FIXME: this should not be called here dataTree.setSchemaContext(peopleSchemaContext); @@ -124,7 +126,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { return shardDataTree.readNode(CarsModel.BASE_PATH); } - private Optional> readPeople(final ShardDataTree shardDataTree){ + private Optional> readPeople(final ShardDataTree shardDataTree) { final TipProducingDataTree dataTree = shardDataTree.getDataTree(); // FIXME: this should not be called here dataTree.setSchemaContext(peopleSchemaContext); @@ -132,9 +134,10 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { return shardDataTree.readNode(PeopleModel.BASE_PATH); } - private static byte[] createSnapshot(){ + private static ShardSnapshotState createSnapshot() { final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); - dataTree.setSchemaContext(SchemaContextHelper.select(SchemaContextHelper.CARS_YANG, SchemaContextHelper.PEOPLE_YANG)); + dataTree.setSchemaContext(SchemaContextHelper.select(SchemaContextHelper.CARS_YANG, + SchemaContextHelper.PEOPLE_YANG)); DataTreeSnapshot snapshot = dataTree.takeSnapshot(); @@ -145,7 +148,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest { modification.ready(); dataTree.commit(dataTree.prepare(modification)); - return new PreBoronShardDataTreeSnapshot(dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY).get()) - .serialize(); + return new ShardSnapshotState(new MetadataShardDataTreeSnapshot(dataTree.takeSnapshot().readNode( + YangInstanceIdentifier.EMPTY).get())); } -} \ No newline at end of file +}