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;
public class ShardDataTreeTest {
- @Test
- public void testWrite() throws ExecutionException, InterruptedException {
+ SchemaContext fullSchema;
- SchemaContext schemaContext = SchemaContextHelper.full();
-
- 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();
}
- @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