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;
13 import org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.WriteTransactionCustomizer;
14 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
17 * Base template for a test suite for testing DataChangeListener functionality.
19 public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataChangeListenerTest {
21 protected static final String FOO_SIBLING = "foo-sibling";
24 * Callback invoked when the test suite can modify task parameters.
26 * @param task Update task configuration as needed
28 abstract protected void customizeTask(DatastoreTestTask task);
31 public final void putTopLevelOneNested() throws Exception {
33 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR));
36 putTopLevelOneNested(task);
40 public final void existingTopWriteSibling() throws Exception {
41 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
42 new WriteTransactionCustomizer() {
44 public void customize(final DOMStoreReadWriteTransaction tx) {
45 tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build());
50 existingTopWriteSibling(task);
53 protected abstract void existingTopWriteSibling(DatastoreTestTask task) throws InterruptedException, ExecutionException;
57 public final void existingTopWriteTwoNested() throws Exception {
58 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
59 new WriteTransactionCustomizer() {
61 public void customize(final DOMStoreReadWriteTransaction tx) {
62 tx.write(path(FOO,BAR), nestedList(BAR).build());
63 tx.write(path(FOO,BAZ), nestedList(BAZ).build());
68 existingTopWriteTwoNested(task);
71 protected abstract void existingTopWriteTwoNested(DatastoreTestTask task) throws InterruptedException, ExecutionException;
75 public final void existingOneNestedWriteAdditionalNested() throws Exception {
76 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
77 new WriteTransactionCustomizer() {
79 public void customize(final DOMStoreReadWriteTransaction tx) {
80 tx.write(path(FOO,BAZ), nestedList(BAZ).build());
85 existingOneNestedWriteAdditionalNested(task);
88 protected abstract void existingOneNestedWriteAdditionalNested(DatastoreTestTask task) throws InterruptedException, ExecutionException;
90 protected abstract void putTopLevelOneNested(DatastoreTestTask task) throws Exception;
93 public final void replaceTopLevelNestedChanged() throws Exception {
94 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
95 writeOneTopMultipleNested(FOO, BAZ));
98 replaceTopLevelNestedChanged(task);
101 protected abstract void replaceTopLevelNestedChanged(DatastoreTestTask task) throws InterruptedException,
105 public final void putTopLevelWithTwoNested() throws Exception {
107 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR, BAZ));
110 putTopLevelWithTwoNested(task);
113 protected abstract void putTopLevelWithTwoNested(DatastoreTestTask task) throws InterruptedException,
117 public final void twoNestedExistsOneIsDeleted() throws Exception {
119 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR, BAZ)).test(
120 deleteNested(FOO, BAZ));
123 twoNestedExistsOneIsDeleted(task);
126 protected abstract void twoNestedExistsOneIsDeleted(DatastoreTestTask task) throws InterruptedException,
130 public final void nestedListExistsRootDeleted() throws Exception {
132 DatastoreTestTask task = newTestTask().cleanup(null).setup(writeOneTopMultipleNested(FOO, BAR, BAZ))
133 .test(DatastoreTestTask.simpleDelete(TOP_LEVEL));
136 nestedListExistsRootDeleted(task);
139 protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws InterruptedException,