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;
16 public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataChangeListenerTest {
18 protected static final String FOO_SIBLING = "foo-sibling";
20 abstract protected void customizeTask(DatastoreTestTask task);
23 public final void putTopLevelOneNested() throws Exception {
25 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR));
28 putTopLevelOneNested(task);
32 public final void existingTopWriteSibling() throws Exception {
33 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
34 new WriteTransactionCustomizer() {
36 public void customize(final DOMStoreReadWriteTransaction tx) {
37 tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build());
42 existingTopWriteSibling(task);
45 protected abstract void existingTopWriteSibling(DatastoreTestTask task) throws InterruptedException, ExecutionException;
49 public final void existingTopWriteTwoNested() throws Exception {
50 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
51 new WriteTransactionCustomizer() {
53 public void customize(final DOMStoreReadWriteTransaction tx) {
54 tx.write(path(FOO,BAR), nestedList(BAR).build());
55 tx.write(path(FOO,BAZ), nestedList(BAZ).build());
60 existingTopWriteTwoNested(task);
63 protected abstract void existingTopWriteTwoNested(DatastoreTestTask task) throws InterruptedException, ExecutionException;
67 public final void existingOneNestedWriteAdditionalNested() throws Exception {
68 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
69 new WriteTransactionCustomizer() {
71 public void customize(final DOMStoreReadWriteTransaction tx) {
72 tx.write(path(FOO,BAZ), nestedList(BAZ).build());
77 existingOneNestedWriteAdditionalNested(task);
80 protected abstract void existingOneNestedWriteAdditionalNested(DatastoreTestTask task) throws InterruptedException, ExecutionException;
82 protected abstract void putTopLevelOneNested(DatastoreTestTask task) throws Exception;
85 public final void replaceTopLevelNestedChanged() throws Exception {
86 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
87 writeOneTopMultipleNested(FOO, BAZ));
90 replaceTopLevelNestedChanged(task);
93 protected abstract void replaceTopLevelNestedChanged(DatastoreTestTask task) throws InterruptedException,
97 public final void putTopLevelWithTwoNested() throws Exception {
99 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR, BAZ));
102 putTopLevelWithTwoNested(task);
105 protected abstract void putTopLevelWithTwoNested(DatastoreTestTask task) throws InterruptedException,
109 public final void twoNestedExistsOneIsDeleted() throws Exception {
111 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR, BAZ)).test(
112 deleteNested(FOO, BAZ));
115 twoNestedExistsOneIsDeleted(task);
118 protected abstract void twoNestedExistsOneIsDeleted(DatastoreTestTask task) throws InterruptedException,
122 public final void nestedListExistsRootDeleted() throws Exception {
124 DatastoreTestTask task = newTestTask().cleanup(null).setup(writeOneTopMultipleNested(FOO, BAR, BAZ))
125 .test(DatastoreTestTask.simpleDelete(TOP_LEVEL));
128 nestedListExistsRootDeleted(task);
131 protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws InterruptedException,