BUG-5280: add CommitTransactionPayload
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / ShardRecoveryCoordinatorTest.java
index 5cb74090dbc8c7acf27a25e18f2bb9add4b26c5a..4a8363c866d68977e0051c9bc9724a377fecce12 100644 (file)
@@ -11,8 +11,10 @@ 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.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload;
 import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel;
@@ -29,7 +31,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFai
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.LoggerFactory;
 
-public class ShardRecoveryCoordinatorTest {
+public class ShardRecoveryCoordinatorTest extends AbstractTest {
 
     private ShardDataTree peopleDataTree;
     private SchemaContext peopleSchemaContext;
@@ -43,6 +45,7 @@ public class ShardRecoveryCoordinatorTest {
         peopleDataTree = new ShardDataTree(peopleSchemaContext, TreeType.OPERATIONAL);
     }
 
+    @Deprecated
     @Test
     public void testAppendRecoveredLogEntryDataTreeCandidatePayload(){
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
@@ -57,6 +60,20 @@ public class ShardRecoveryCoordinatorTest {
         coordinator.applyCurrentLogRecoveryBatch();
     }
 
+    @Test
+    public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException {
+        final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
+                peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
+        coordinator.startLogRecoveryBatch(10);
+        try {
+            coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar()));
+        } catch(final SchemaValidationFailedException e){
+            fail("SchemaValidationFailedException should not happen if pruning is done");
+        }
+
+        coordinator.applyCurrentLogRecoveryBatch();
+    }
+
     @Test
     public void testApplyRecoverySnapshot(){
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,