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%2FShardDataTreeTest.java;h=81844fd554db7eeb1ddc0d77fe00efa33a78bae6;hb=5273c33b6f2051a7e3b1afcc4eeae4e457b6f26c;hp=ae3ae6f7920d5c845f228bdf833004b6357626ff;hpb=085b076786d299c235ab5561c9fa678fd6b8d726;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java index ae3ae6f792..81844fd554 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java @@ -1,10 +1,18 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.cluster.datastore; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import com.google.common.base.Optional; import java.util.concurrent.ExecutionException; +import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; @@ -16,39 +24,28 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class ShardDataTreeTest { - @Test - public void testWrite() throws ExecutionException, InterruptedException { - - SchemaContext schemaContext = SchemaContextHelper.full(); + SchemaContext fullSchema; - modify(new ShardDataTree(schemaContext), false, true, true); + @Before + public void setUp(){ + fullSchema = SchemaContextHelper.full(); } @Test - public void testWriteWithMissingSchema() throws ExecutionException, InterruptedException { - - SchemaContext schemaContext = SchemaContextHelper.select(SchemaContextHelper.ODL_DATASTORE_TEST_YANG, SchemaContextHelper.PEOPLE_YANG); - - modify(new ShardDataTree(schemaContext), false, false, true); + public void testWrite() throws ExecutionException, InterruptedException { + modify(new ShardDataTree(fullSchema), false, true, true); } @Test public void testMerge() throws ExecutionException, InterruptedException { - - SchemaContext schemaContext = SchemaContextHelper.full(); - - modify(new ShardDataTree(schemaContext), true, true, true); + modify(new ShardDataTree(fullSchema), true, true, true); } - @Test - public void testMergeWithMissingSchema() throws ExecutionException, InterruptedException { - SchemaContext schemaContext = SchemaContextHelper.select(SchemaContextHelper.ODL_DATASTORE_TEST_YANG, SchemaContextHelper.PEOPLE_YANG); + private void modify(ShardDataTree shardDataTree, boolean merge, boolean expectedCarsPresent, boolean expectedPeoplePresent) throws ExecutionException, InterruptedException { - modify(new ShardDataTree(schemaContext), true, false, true); - } + assertEquals(fullSchema, shardDataTree.getSchemaContext()); - private void modify(ShardDataTree shardDataTree, boolean merge, boolean expectedCarsPresent, boolean expectedPeoplePresent) throws ExecutionException, InterruptedException { ReadWriteShardDataTreeTransaction transaction = shardDataTree.newReadWriteTransaction("txn-1", null); DataTreeModification snapshot = transaction.getSnapshot(); @@ -83,18 +80,4 @@ public class ShardDataTreeTest { } - @Test(expected = IllegalArgumentException.class) - public void testAfterRecoveryDone() throws ExecutionException, InterruptedException { - SchemaContext schemaContext = SchemaContextHelper.select(SchemaContextHelper.ODL_DATASTORE_TEST_YANG, SchemaContextHelper.PEOPLE_YANG); - ShardDataTree shardDataTree = new ShardDataTree(schemaContext); - assertTrue("transaction factory must be the recovery transaction factory", - shardDataTree.getTransactionFactory() instanceof ShardDataTree.RecoveryShardDataTreeTransactionFactory); - shardDataTree.recoveryDone(); - assertTrue("transaction factory must be the regular transaction factory", - shardDataTree.getTransactionFactory() instanceof ShardDataTree.RegularShardDataTreeTransactionFactory); - - modify(shardDataTree, true, false, true); - - } - } \ No newline at end of file