import static org.junit.Assert.assertNotNull;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.net.URI;
+import java.util.Collections;
+import java.util.concurrent.ExecutionException;
+import org.eclipse.jdt.annotation.NonNull;
+import org.junit.Test;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCursor;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import com.google.common.util.concurrent.CheckedFuture;
-import java.net.URI;
-import java.util.Collections;
-import javax.annotation.Nonnull;
-import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
* can be used.
*/
public abstract class AbstractDOMDataTreeServiceTestSuite {
- protected static final QNameModule TEST_MODULE = QNameModule.create(URI.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"), null);
+ protected static final QNameModule TEST_MODULE =
+ QNameModule.create(URI.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"));
protected static final YangInstanceIdentifier UNORDERED_CONTAINER_IID = YangInstanceIdentifier.create(
new NodeIdentifier(QName.create(TEST_MODULE, "lists")),
new NodeIdentifier(QName.create(TEST_MODULE, "unordered-container")));
- protected static final DOMDataTreeIdentifier UNORDERED_CONTAINER_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, UNORDERED_CONTAINER_IID);
+ protected static final DOMDataTreeIdentifier UNORDERED_CONTAINER_TREE
+ = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, UNORDERED_CONTAINER_IID);
/**
* Return a reference to the service used in this test. The instance
*
* @return {@link DOMDataTreeService} instance.
*/
- protected abstract @Nonnull DOMDataTreeService service();
+ protected abstract @NonNull DOMDataTreeService service();
/**
* A simple unbound producer. It write some basic things into the data store based on the
* test model.
- * @throws DOMDataTreeProducerException
- * @throws TransactionCommitFailedException
+ *
+ * @throws DOMDataTreeProducerException when this exceptional condition happens
*/
-
@Test
- public final void testBasicProducer() throws DOMDataTreeProducerException, TransactionCommitFailedException {
+ public final void testBasicProducer() throws DOMDataTreeProducerException, InterruptedException,
+ ExecutionException {
// Create a producer. It is an AutoCloseable resource, hence the try-with pattern
- try (final DOMDataTreeProducer prod = service().createProducer(Collections.singleton(UNORDERED_CONTAINER_TREE))) {
+ try (DOMDataTreeProducer prod =
+ service().createProducer(Collections.singleton(UNORDERED_CONTAINER_TREE))) {
assertNotNull(prod);
final DOMDataTreeCursorAwareTransaction tx = prod.createTransaction(true);
assertNotNull(tx);
- final DOMDataTreeWriteCursor cursor = tx.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, UNORDERED_CONTAINER_IID));
+ final DOMDataTreeWriteCursor cursor =
+ tx.createCursor(new DOMDataTreeIdentifier(
+ LogicalDatastoreType.OPERATIONAL, UNORDERED_CONTAINER_IID));
assertNotNull(cursor);
cursor.write(UNORDERED_CONTAINER_IID.getLastPathArgument(), ImmutableContainerNodeBuilder.create().build());
cursor.close();
- final CheckedFuture<Void, TransactionCommitFailedException> f = tx.submit();
+ final ListenableFuture<?> f = tx.commit();
assertNotNull(f);
- f.checkedGet();
+ f.get();
}
}