X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FDatastoreTestTask.java;fp=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FDatastoreTestTask.java;h=ed17aa55cfb852fa5724272f87f8d298f1f694cb;hp=63e1498c0efe20d697584bb40114528aab507e09;hb=c5f3be93482d6b06d95ebf22b2ef2723fd813f89;hpb=f1a918f69b787dd422a09e4e8fd83a1d52a72f83 diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java index 63e1498c0e..ed17aa55cf 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java @@ -10,10 +10,11 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.SettableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; @@ -25,9 +26,6 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.SettableFuture; - public class DatastoreTestTask { private final DOMStore store; @@ -50,8 +48,8 @@ public class DatastoreTestTask { } public DatastoreTestTask changeListener(final YangInstanceIdentifier path, final DataChangeScope scope, - final AsyncDataChangeListener> changeListener) { - this.changeListener = changeListener; + final AsyncDataChangeListener> listener) { + this.changeListener = listener; this.changePath = path; this.changeScope = scope; return this; @@ -63,27 +61,27 @@ public class DatastoreTestTask { return this; } - public DatastoreTestTask setup(final WriteTransactionCustomizer setup) { - this.setup = setup; + public DatastoreTestTask setup(final WriteTransactionCustomizer customizer) { + this.setup = customizer; return this; } - public DatastoreTestTask test(final WriteTransactionCustomizer write) { - this.write = write; + public DatastoreTestTask test(final WriteTransactionCustomizer customizer) { + this.write = customizer; return this; } - public DatastoreTestTask read(final ReadTransactionVerifier read) { - this.read = read; + public DatastoreTestTask read(final ReadTransactionVerifier customizer) { + this.read = customizer; return this; } - public DatastoreTestTask cleanup(final WriteTransactionCustomizer cleanup) { - this.cleanup = cleanup; + public DatastoreTestTask cleanup(final WriteTransactionCustomizer customizer) { + this.cleanup = customizer; return this; } - public void run() throws InterruptedException, ExecutionException, TimeoutException { + public void run() throws Exception { if (setup != null) { execute(setup); } @@ -113,25 +111,16 @@ public class DatastoreTestTask { } } - public AsyncDataChangeEvent> getChangeEvent() { - try { - return internalListener.receivedChange.get(10, TimeUnit.SECONDS); - } catch( Exception e ) { - fail( "Error getting the AsyncDataChangeEvent from the Future: " + e ); - } - - // won't get here - return null; + public AsyncDataChangeEvent> getChangeEvent() throws Exception { + return internalListener.receivedChange.get(10, TimeUnit.SECONDS); } - public void verifyNoChangeEvent() { + public void verifyNoChangeEvent() throws Exception { try { Object unexpected = internalListener.receivedChange.get(500, TimeUnit.MILLISECONDS); - fail( "Got unexpected AsyncDataChangeEvent from the Future: " + unexpected ); - } catch( TimeoutException e ) { + fail("Got unexpected AsyncDataChangeEvent from the Future: " + unexpected); + } catch (TimeoutException e) { // Expected - } catch( Exception e ) { - fail( "Error getting the AsyncDataChangeEvent from the Future: " + e ); } } @@ -156,8 +145,8 @@ public class DatastoreTestTask { private final class ChangeEventListener implements AsyncDataChangeListener> { - protected final SettableFuture>> receivedChange = SettableFuture - .create(); + protected final SettableFuture>> + receivedChange = SettableFuture.create(); @Override public void onDataChanged(final AsyncDataChangeEvent> change) {