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 InterruptedException, ExecutionException {
25 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR));
28 putTopLevelOneNested(task);
32 public final void existingTopWriteSibling() throws InterruptedException, ExecutionException {
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 InterruptedException, ExecutionException {
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 InterruptedException, ExecutionException {
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 InterruptedException,
86 public final void replaceTopLevelNestedChanged() throws InterruptedException, ExecutionException {
87 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
88 writeOneTopMultipleNested(FOO, BAZ));
91 replaceTopLevelNestedChanged(task);
94 protected abstract void replaceTopLevelNestedChanged(DatastoreTestTask task) throws InterruptedException,
98 public final void putTopLevelWithTwoNested() throws InterruptedException, ExecutionException {
100 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR, BAZ));
103 putTopLevelWithTwoNested(task);
106 protected abstract void putTopLevelWithTwoNested(DatastoreTestTask task) throws InterruptedException,
110 public final void twoNestedExistsOneIsDeleted() throws InterruptedException, ExecutionException {
112 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR, BAZ)).test(
113 deleteNested(FOO, BAZ));
116 twoNestedExistsOneIsDeleted(task);
119 protected abstract void twoNestedExistsOneIsDeleted(DatastoreTestTask task) throws InterruptedException,
123 public final void nestedListExistsRootDeleted() throws InterruptedException, ExecutionException {
125 DatastoreTestTask task = newTestTask().cleanup(null).setup(writeOneTopMultipleNested(FOO, BAR, BAZ))
126 .test(DatastoreTestTask.simpleDelete(TOP_LEVEL));
129 nestedListExistsRootDeleted(task);
132 protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws InterruptedException,