2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.store.impl;
10 import java.util.concurrent.ExecutionException;
12 import org.junit.Test;
15 * Base template for a test suite for testing DataChangeListener functionality.
17 public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataChangeListenerTest {
19 protected static final String FOO_SIBLING = "foo-sibling";
22 * Callback invoked when the test suite can modify task parameters.
24 * @param task Update task configuration as needed
26 abstract protected void customizeTask(DatastoreTestTask task);
29 public final void putTopLevelOneNested() throws Exception {
31 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR));
34 putTopLevelOneNested(task);
38 public final void existingTopWriteSibling() throws Exception {
39 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
40 tx -> tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build()));
43 existingTopWriteSibling(task);
46 protected abstract void existingTopWriteSibling(DatastoreTestTask task) throws InterruptedException, ExecutionException;
50 public final void existingTopWriteTwoNested() throws Exception {
51 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
53 tx.write(path(FOO,BAR), nestedList(BAR).build());
54 tx.write(path(FOO,BAZ), nestedList(BAZ).build());
58 existingTopWriteTwoNested(task);
61 protected abstract void existingTopWriteTwoNested(DatastoreTestTask task) throws InterruptedException, ExecutionException;
65 public final void existingOneNestedWriteAdditionalNested() throws Exception {
66 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
67 tx -> tx.write(path(FOO,BAZ), nestedList(BAZ).build()));
70 existingOneNestedWriteAdditionalNested(task);
73 protected abstract void existingOneNestedWriteAdditionalNested(DatastoreTestTask task) throws InterruptedException, ExecutionException;
75 protected abstract void putTopLevelOneNested(DatastoreTestTask task) throws Exception;
78 public final void replaceTopLevelNestedChanged() throws Exception {
79 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
80 writeOneTopMultipleNested(FOO, BAZ));
83 replaceTopLevelNestedChanged(task);
86 protected abstract void replaceTopLevelNestedChanged(DatastoreTestTask task) throws InterruptedException,
90 public final void putTopLevelWithTwoNested() throws Exception {
92 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR, BAZ));
95 putTopLevelWithTwoNested(task);
98 protected abstract void putTopLevelWithTwoNested(DatastoreTestTask task) throws InterruptedException,
102 public final void twoNestedExistsOneIsDeleted() throws Exception {
104 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR, BAZ)).test(
105 deleteNested(FOO, BAZ));
108 twoNestedExistsOneIsDeleted(task);
111 protected abstract void twoNestedExistsOneIsDeleted(DatastoreTestTask task) throws InterruptedException,
115 public final void nestedListExistsRootDeleted() throws Exception {
117 DatastoreTestTask task = newTestTask().cleanup(null).setup(writeOneTopMultipleNested(FOO, BAR, BAZ))
118 .test(DatastoreTestTask.simpleDelete(TOP_LEVEL));
121 nestedListExistsRootDeleted(task);
124 protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws InterruptedException,