Bug 4105: Add dynamic module/shard config for entity-owners shard
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeTest.java
index ae3ae6f7920d5c845f228bdf833004b6357626ff..81844fd554db7eeb1ddc0d77fe00efa33a78bae6 100644 (file)
@@ -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