X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FBlockingTransactionChainListener.java;fp=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FBlockingTransactionChainListener.java;h=f9c301c1805b6a2a78574836d7a799487d9cf659;hb=2cf314976a3f81c7115f94c44fb37e967f8a4426;hp=0000000000000000000000000000000000000000;hpb=9d7a3392097e4c4a648327f77d7ca1a6aaf1b410;p=controller.git diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/BlockingTransactionChainListener.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/BlockingTransactionChainListener.java new file mode 100644 index 0000000000..f9c301c180 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/BlockingTransactionChainListener.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.md.sal.dom.broker.impl; + +import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; +import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; + +import com.google.common.util.concurrent.SettableFuture; + +/** + * Simple implementation of {@link TransactionChainListener} for testing. + * + * This transaction chain listener does not contain any logic, only update + * futures ({@link #getFailFuture()} and {@link #getSuccessFuture()} when + * transaction chain event is retrieved. + * + */ +class BlockingTransactionChainListener implements TransactionChainListener { + + private final SettableFuture failFuture = SettableFuture.create(); + private final SettableFuture successFuture = SettableFuture.create(); + + @Override + public void onTransactionChainFailed(TransactionChain chain, AsyncTransaction transaction, + Throwable cause) { + failFuture.set(cause); + } + + @Override + public void onTransactionChainSuccessful(TransactionChain chain) { + successFuture.set(null); + } + + public SettableFuture getFailFuture() { + return failFuture; + } + + public SettableFuture getSuccessFuture() { + return successFuture; + } + +}