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%2Fmodification%2FMutableCompositeModificationTest.java;h=f8116aa78d72f4b08597cee693d592ca8c32ed87;hp=e30936b3272da5e5cfb975dd803bf3ea241213db;hb=531621aac4cff9d39cbd8668a53bdeba8a0e6d81;hpb=c1362c86eb19e92e6c64d10099a45deb499c6db1 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 e30936b327..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))); + 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()); - } -} \ No newline at end of file + @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); + } +}