X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmodification%2FMutableCompositeModificationTest.java;h=f8116aa78d72f4b08597cee693d592ca8c32ed87;hb=88f572234e790cec60537ad6b8e6c7debc43e641;hp=7a21c8cdc5eea9ea208c651286423c63b107a13b;hpb=0eb621d29daaf08979c356e2148e99c48458e169;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java index 7a21c8cdc5..f8116aa78d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java @@ -1,28 +1,43 @@ package org.opendaylight.controller.cluster.datastore.modification; import com.google.common.base.Optional; -import junit.framework.Assert; import org.junit.Test; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + public class MutableCompositeModificationTest extends AbstractModificationTest { - @Test - public void testApply() throws Exception { + @Test + public void testApply() throws Exception { + + MutableCompositeModification compositeModification = new MutableCompositeModification(); + compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, + ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext())); - MutableCompositeModification compositeModification = new MutableCompositeModification(); - compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext())); + DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction(); + compositeModification.apply(transaction); + commitTransaction(transaction); - DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction(); - compositeModification.apply(transaction); - commitTransaction(transaction); + Optional> data = readData(TestModel.TEST_PATH); - Optional> data = readData(TestModel.TEST_PATH); + assertNotNull(data.get()); + assertEquals(TestModel.TEST_QNAME, data.get().getNodeType()); + } - Assert.assertNotNull(data.get()); - Assert.assertEquals(TestModel.TEST_QNAME, data.get().getNodeType()); - } + @Test + public void testEverySerializedCompositeModificationObjectMustBeDifferent(){ + MutableCompositeModification compositeModification = new MutableCompositeModification(); + compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, + ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext())); + Object one = compositeModification.toSerializable(); + try{Thread.sleep(10);}catch(Exception err){} + Object two = compositeModification.toSerializable(); + assertNotEquals(one,two); + } }