6f07390ba207afe5aad2b5b5c50aad8883123d57
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / AbstractShardTest.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.datastore;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13 import static org.junit.Assert.fail;
14 import static org.mockito.Matchers.any;
15 import static org.mockito.Mockito.doAnswer;
16 import static org.mockito.Mockito.doReturn;
17 import static org.mockito.Mockito.mock;
18 import static org.opendaylight.controller.cluster.datastore.DataStoreVersions.CURRENT_VERSION;
19 import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulCanCommit;
20 import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulCommit;
21 import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.successfulPreCommit;
22 import akka.actor.ActorRef;
23 import akka.actor.PoisonPill;
24 import akka.actor.Props;
25 import akka.dispatch.Dispatchers;
26 import akka.japi.Creator;
27 import akka.pattern.Patterns;
28 import akka.testkit.TestActorRef;
29 import akka.util.Timeout;
30 import com.google.common.base.Optional;
31 import com.google.common.primitives.UnsignedLong;
32 import com.google.common.util.concurrent.FutureCallback;
33 import com.google.common.util.concurrent.ListenableFuture;
34 import com.google.common.util.concurrent.Uninterruptibles;
35 import java.io.IOException;
36 import java.util.Collections;
37 import java.util.HashMap;
38 import java.util.Map;
39 import java.util.Set;
40 import java.util.concurrent.CountDownLatch;
41 import java.util.concurrent.ExecutionException;
42 import java.util.concurrent.TimeUnit;
43 import java.util.concurrent.TimeoutException;
44 import java.util.concurrent.atomic.AtomicInteger;
45 import org.junit.After;
46 import org.junit.Assert;
47 import org.junit.Before;
48 import org.opendaylight.controller.cluster.access.concepts.MemberName;
49 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
50 import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder;
51 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
52 import org.opendaylight.controller.cluster.datastore.messages.BatchedModifications;
53 import org.opendaylight.controller.cluster.datastore.messages.ForwardedReadyTransaction;
54 import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
55 import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
56 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
57 import org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload;
58 import org.opendaylight.controller.cluster.datastore.persisted.PreBoronShardDataTreeSnapshot;
59 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
60 import org.opendaylight.controller.cluster.raft.Snapshot;
61 import org.opendaylight.controller.cluster.raft.TestActorFactory;
62 import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
63 import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
64 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
65 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
66 import org.opendaylight.yangtools.concepts.Identifier;
67 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
68 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
69 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
70 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
71 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
72 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
73 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
74 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
75 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
76 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
77 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
78 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
79 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
80 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
81 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
82 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
83 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
84 import scala.concurrent.Await;
85 import scala.concurrent.Future;
86 import scala.concurrent.duration.Duration;
87
88 /**
89  * Abstract base for shard unit tests.
90  *
91  * @author Thomas Pantelis
92  */
93 public abstract class AbstractShardTest extends AbstractActorTest{
94     protected static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext();
95
96     private static final AtomicInteger NEXT_SHARD_NUM = new AtomicInteger();
97
98     protected final ShardIdentifier shardID = ShardIdentifier.create("inventory", MemberName.forName("member-1"),
99         "config" + NEXT_SHARD_NUM.getAndIncrement());
100
101     protected final Builder dataStoreContextBuilder = DatastoreContext.newBuilder().
102             shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000).
103             shardHeartbeatIntervalInMillis(100);
104
105     protected final TestActorFactory actorFactory = new TestActorFactory(getSystem());
106
107     @Before
108     public void setUp() {
109         InMemorySnapshotStore.clear();
110         InMemoryJournal.clear();
111     }
112
113     @After
114     public void tearDown() {
115         InMemorySnapshotStore.clear();
116         InMemoryJournal.clear();
117         actorFactory.close();
118     }
119
120     protected DatastoreContext newDatastoreContext() {
121         return dataStoreContextBuilder.build();
122     }
123
124     protected Props newShardProps() {
125         return newShardBuilder().props();
126     }
127
128     protected Shard.Builder newShardBuilder() {
129         return Shard.builder().id(shardID).datastoreContext(newDatastoreContext()).schemaContext(SCHEMA_CONTEXT);
130     }
131
132     protected void testRecovery(final Set<Integer> listEntryKeys) throws Exception {
133         // Create the actor and wait for recovery complete.
134
135         final int nListEntries = listEntryKeys.size();
136
137         final CountDownLatch recoveryComplete = new CountDownLatch(1);
138
139         @SuppressWarnings("serial")
140         final Creator<Shard> creator = new Creator<Shard>() {
141             @Override
142             public Shard create() throws Exception {
143                 return new Shard(newShardBuilder()) {
144                     @Override
145                     protected void onRecoveryComplete() {
146                         try {
147                             super.onRecoveryComplete();
148                         } finally {
149                             recoveryComplete.countDown();
150                         }
151                     }
152                 };
153             }
154         };
155
156         final TestActorRef<Shard> shard = TestActorRef.create(getSystem(),
157                 Props.create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()), "testRecovery");
158
159         assertEquals("Recovery complete", true, recoveryComplete.await(5, TimeUnit.SECONDS));
160
161         // Verify data in the data store.
162
163         final NormalizedNode<?, ?> outerList = readStore(shard, TestModel.OUTER_LIST_PATH);
164         assertNotNull(TestModel.OUTER_LIST_QNAME.getLocalName() + " not found", outerList);
165         assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " value is not Iterable",
166                 outerList.getValue() instanceof Iterable);
167         for(final Object entry: (Iterable<?>) outerList.getValue()) {
168             assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " entry is not MapEntryNode",
169                     entry instanceof MapEntryNode);
170             final MapEntryNode mapEntry = (MapEntryNode)entry;
171             final Optional<DataContainerChild<? extends PathArgument, ?>> idLeaf =
172                     mapEntry.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.ID_QNAME));
173             assertTrue("Missing leaf " + TestModel.ID_QNAME.getLocalName(), idLeaf.isPresent());
174             final Object value = idLeaf.get().getValue();
175             assertTrue("Unexpected value for leaf "+ TestModel.ID_QNAME.getLocalName() + ": " + value,
176                     listEntryKeys.remove(value));
177         }
178
179         if(!listEntryKeys.isEmpty()) {
180             fail("Missing " + TestModel.OUTER_LIST_QNAME.getLocalName() + " entries with keys: " +
181                     listEntryKeys);
182         }
183
184         assertEquals("Last log index", nListEntries,
185                 shard.underlyingActor().getShardMBean().getLastLogIndex());
186         assertEquals("Commit index", nListEntries,
187                 shard.underlyingActor().getShardMBean().getCommitIndex());
188         assertEquals("Last applied", nListEntries,
189                 shard.underlyingActor().getShardMBean().getLastApplied());
190
191         shard.tell(PoisonPill.getInstance(), ActorRef.noSender());
192     }
193
194     protected void verifyLastApplied(final TestActorRef<Shard> shard, final long expectedValue) {
195         long lastApplied = -1;
196         for(int i = 0; i < 20 * 5; i++) {
197             lastApplied = shard.underlyingActor().getShardMBean().getLastApplied();
198             if(lastApplied == expectedValue) {
199                 return;
200             }
201             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
202         }
203
204         Assert.fail(String.format("Expected last applied: %d, Actual: %d", expectedValue, lastApplied));
205     }
206
207     protected TipProducingDataTree createDelegatingMockDataTree() throws Exception {
208         TipProducingDataTree actual = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION);
209         final TipProducingDataTree mock = mock(TipProducingDataTree.class);
210
211         doAnswer(invocation -> {
212             actual.validate(invocation.getArgumentAt(0, DataTreeModification.class));
213             return null;
214         }).when(mock).validate(any(DataTreeModification.class));
215
216         doAnswer(invocation -> {
217             return actual.prepare(invocation.getArgumentAt(0, DataTreeModification.class));
218         }).when(mock).prepare(any(DataTreeModification.class));
219
220         doAnswer(invocation -> {
221             actual.commit(invocation.getArgumentAt(0, DataTreeCandidate.class));
222             return null;
223         }).when(mock).commit(any(DataTreeCandidate.class));
224
225         doAnswer(invocation -> {
226             actual.setSchemaContext(invocation.getArgumentAt(0, SchemaContext.class));
227             return null;
228         }).when(mock).setSchemaContext(any(SchemaContext.class));
229
230         doAnswer(invocation -> {
231             return actual.takeSnapshot();
232         }).when(mock).takeSnapshot();
233
234         doAnswer(invocation -> {
235             return actual.getRootPath();
236         }).when(mock).getRootPath();
237
238         return mock;
239     }
240
241     protected ShardDataTreeCohort mockShardDataTreeCohort() {
242         ShardDataTreeCohort cohort = mock(ShardDataTreeCohort.class);
243         DataTreeCandidate candidate = mockCandidate("candidate");
244         successfulCanCommit(cohort);
245         successfulPreCommit(cohort, candidate);
246         successfulCommit(cohort);
247         doReturn(candidate).when(cohort).getCandidate();
248         return cohort;
249     }
250
251     protected Map<TransactionIdentifier, CapturingShardDataTreeCohort> setupCohortDecorator(final Shard shard,
252             final TransactionIdentifier... transactionIDs) {
253         final Map<TransactionIdentifier, CapturingShardDataTreeCohort> cohortMap = new HashMap<>();
254         for(TransactionIdentifier id: transactionIDs) {
255             cohortMap.put(id, new CapturingShardDataTreeCohort());
256         }
257
258         shard.getCommitCoordinator().setCohortDecorator(new ShardCommitCoordinator.CohortDecorator() {
259             @Override
260             public ShardDataTreeCohort decorate(final Identifier transactionID, final ShardDataTreeCohort actual) {
261                 CapturingShardDataTreeCohort cohort = cohortMap.get(transactionID);
262                 cohort.setDelegate(actual);
263                 return cohort;
264             }
265         });
266
267         return cohortMap;
268     }
269
270     protected BatchedModifications prepareBatchedModifications(final TransactionIdentifier transactionID,
271                                                                final MutableCompositeModification modification) {
272         return prepareBatchedModifications(transactionID, modification, false);
273     }
274
275     protected static BatchedModifications prepareBatchedModifications(final TransactionIdentifier transactionID,
276                                                              final MutableCompositeModification modification,
277                                                              final boolean doCommitOnReady) {
278         final BatchedModifications batchedModifications = new BatchedModifications(transactionID, CURRENT_VERSION);
279         batchedModifications.addModification(modification);
280         batchedModifications.setReady(true);
281         batchedModifications.setDoCommitOnReady(doCommitOnReady);
282         batchedModifications.setTotalMessagesSent(1);
283         return batchedModifications;
284     }
285
286     protected static BatchedModifications prepareBatchedModifications(final TransactionIdentifier transactionID,
287             final YangInstanceIdentifier path, final NormalizedNode<?, ?> data, final boolean doCommitOnReady) {
288         final MutableCompositeModification modification = new MutableCompositeModification();
289         modification.addModification(new WriteModification(path, data));
290         return prepareBatchedModifications(transactionID, modification, doCommitOnReady);
291     }
292
293     protected static ForwardedReadyTransaction prepareForwardedReadyTransaction(final TestActorRef<Shard> shard,
294             final TransactionIdentifier transactionID, final YangInstanceIdentifier path,
295             final NormalizedNode<?, ?> data, final boolean doCommitOnReady) {
296         ReadWriteShardDataTreeTransaction rwTx = shard.underlyingActor().getDataStore().
297                 newReadWriteTransaction(transactionID);
298         rwTx.getSnapshot().write(path, data);
299         return new ForwardedReadyTransaction(transactionID, CURRENT_VERSION, rwTx, doCommitOnReady);
300     }
301
302     public static NormalizedNode<?,?> readStore(final TestActorRef<? extends Shard> shard, final YangInstanceIdentifier id)
303             throws ExecutionException, InterruptedException {
304         return shard.underlyingActor().getDataStore().readNode(id).orNull();
305     }
306
307     public static NormalizedNode<?,?> readStore(final DataTree store, final YangInstanceIdentifier id) {
308         return store.takeSnapshot().readNode(id).orNull();
309     }
310
311     public void writeToStore(final TestActorRef<Shard> shard, final YangInstanceIdentifier id,
312             final NormalizedNode<?,?> node) throws InterruptedException, ExecutionException {
313         Future<Object> future = Patterns.ask(shard, newBatchedModifications(nextTransactionId(), id, node, true, true, 1),
314                 new Timeout(5, TimeUnit.SECONDS));
315         try {
316             Await.ready(future, Duration.create(5, TimeUnit.SECONDS));
317         } catch(TimeoutException e) {
318             throw new ExecutionException(e);
319         }
320     }
321
322     public static void writeToStore(final ShardDataTree store, final YangInstanceIdentifier id,
323             final NormalizedNode<?,?> node) throws Exception {
324         BatchedModifications batched = newBatchedModifications(nextTransactionId(), id, node, true, true, 1);
325         DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
326         batched.apply(modification);
327         store.commit(modification);
328     }
329
330     public void mergeToStore(final ShardDataTree store, final YangInstanceIdentifier id,
331             final NormalizedNode<?,?> node) throws Exception {
332         final BatchedModifications batched = new BatchedModifications(nextTransactionId(), CURRENT_VERSION);
333         batched.addModification(new MergeModification(id, node));
334         batched.setReady(true);
335         batched.setDoCommitOnReady(true);
336         batched.setTotalMessagesSent(1);
337
338         DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
339         batched.apply(modification);
340         store.commit(modification);
341     }
342
343     public static void writeToStore(final DataTree store, final YangInstanceIdentifier id,
344             final NormalizedNode<?,?> node) throws DataValidationFailedException {
345         final DataTreeModification transaction = store.takeSnapshot().newModification();
346
347         transaction.write(id, node);
348         transaction.ready();
349         store.validate(transaction);
350         final DataTreeCandidate candidate = store.prepare(transaction);
351         store.commit(candidate);
352     }
353
354     DataTree setupInMemorySnapshotStore() throws DataValidationFailedException {
355         final DataTree testStore = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
356         testStore.setSchemaContext(SCHEMA_CONTEXT);
357
358         writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
359
360         final NormalizedNode<?, ?> root = readStore(testStore, YangInstanceIdentifier.EMPTY);
361
362         InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create(
363                 new PreBoronShardDataTreeSnapshot(root).serialize(),
364                 Collections.<ReplicatedLogEntry>emptyList(), 0, 1, -1, -1));
365         return testStore;
366     }
367
368     static CommitTransactionPayload payloadForModification(final DataTree source, final DataTreeModification mod,
369             final TransactionIdentifier transactionId) throws DataValidationFailedException, IOException {
370         source.validate(mod);
371         final DataTreeCandidate candidate = source.prepare(mod);
372         source.commit(candidate);
373         return CommitTransactionPayload.create(transactionId, candidate);
374     }
375
376     static BatchedModifications newBatchedModifications(final TransactionIdentifier transactionID,
377             final YangInstanceIdentifier path, final NormalizedNode<?, ?> data, final boolean ready, final boolean doCommitOnReady,
378             final int messagesSent) {
379         final BatchedModifications batched = new BatchedModifications(transactionID, CURRENT_VERSION);
380         batched.addModification(new WriteModification(path, data));
381         batched.setReady(ready);
382         batched.setDoCommitOnReady(doCommitOnReady);
383         batched.setTotalMessagesSent(messagesSent);
384         return batched;
385     }
386
387     @SuppressWarnings("unchecked")
388     static void verifyOuterListEntry(final TestActorRef<Shard> shard, final Object expIDValue) throws Exception {
389         final NormalizedNode<?, ?> outerList = readStore(shard, TestModel.OUTER_LIST_PATH);
390         assertNotNull(TestModel.OUTER_LIST_QNAME.getLocalName() + " not found", outerList);
391         assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " value is not Iterable",
392                 outerList.getValue() instanceof Iterable);
393         final Object entry = ((Iterable<Object>)outerList.getValue()).iterator().next();
394         assertTrue(TestModel.OUTER_LIST_QNAME.getLocalName() + " entry is not MapEntryNode",
395                 entry instanceof MapEntryNode);
396         final MapEntryNode mapEntry = (MapEntryNode)entry;
397         final Optional<DataContainerChild<? extends PathArgument, ?>> idLeaf =
398                 mapEntry.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.ID_QNAME));
399         assertTrue("Missing leaf " + TestModel.ID_QNAME.getLocalName(), idLeaf.isPresent());
400         assertEquals(TestModel.ID_QNAME.getLocalName() + " value", expIDValue, idLeaf.get().getValue());
401     }
402
403     public static DataTreeCandidateTip mockCandidate(final String name) {
404         final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name);
405         final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node");
406         doReturn(ModificationType.WRITE).when(mockCandidateNode).getModificationType();
407         doReturn(Optional.of(ImmutableNodes.containerNode(CarsModel.CARS_QNAME))).when(mockCandidateNode).getDataAfter();
408         doReturn(CarsModel.BASE_PATH).when(mockCandidate).getRootPath();
409         doReturn(mockCandidateNode).when(mockCandidate).getRootNode();
410         return mockCandidate;
411     }
412
413     static DataTreeCandidateTip mockUnmodifiedCandidate(final String name) {
414         final DataTreeCandidateTip mockCandidate = mock(DataTreeCandidateTip.class, name);
415         final DataTreeCandidateNode mockCandidateNode = mock(DataTreeCandidateNode.class, name + "-node");
416         doReturn(ModificationType.UNMODIFIED).when(mockCandidateNode).getModificationType();
417         doReturn(YangInstanceIdentifier.EMPTY).when(mockCandidate).getRootPath();
418         doReturn(mockCandidateNode).when(mockCandidate).getRootNode();
419         return mockCandidate;
420     }
421
422     static void commitTransaction(final DataTree store, final DataTreeModification modification) throws DataValidationFailedException {
423         modification.ready();
424         store.validate(modification);
425         store.commit(store.prepare(modification));
426     }
427
428     @SuppressWarnings("serial")
429     public static final class DelegatingShardCreator implements Creator<Shard> {
430         private final Creator<Shard> delegate;
431
432         DelegatingShardCreator(final Creator<Shard> delegate) {
433             this.delegate = delegate;
434         }
435
436         @Override
437         public Shard create() throws Exception {
438             return delegate.create();
439         }
440     }
441
442     public static class CapturingShardDataTreeCohort extends ShardDataTreeCohort {
443         private volatile ShardDataTreeCohort delegate;
444         private FutureCallback<Void> canCommit;
445         private FutureCallback<DataTreeCandidate> preCommit;
446         private FutureCallback<UnsignedLong> commit;
447
448         public void setDelegate(ShardDataTreeCohort delegate) {
449             this.delegate = delegate;
450         }
451
452         public FutureCallback<Void> getCanCommit() {
453             assertNotNull("canCommit was not invoked", canCommit);
454             return canCommit;
455         }
456
457         public FutureCallback<DataTreeCandidate> getPreCommit() {
458             assertNotNull("preCommit was not invoked", preCommit);
459             return preCommit;
460         }
461
462         public FutureCallback<UnsignedLong> getCommit() {
463             assertNotNull("commit was not invoked", commit);
464             return commit;
465         }
466
467         @Override
468         public TransactionIdentifier getIdentifier() {
469             return delegate.getIdentifier();
470         }
471
472         @Override
473         DataTreeCandidateTip getCandidate() {
474             return delegate.getCandidate();
475         }
476
477         @Override
478         DataTreeModification getDataTreeModification() {
479             return delegate.getDataTreeModification();
480         }
481
482         @Override
483         public void canCommit(FutureCallback<Void> callback) {
484             canCommit = mockFutureCallback(callback);
485             delegate.canCommit(canCommit);
486         }
487
488         @Override
489         public void preCommit(FutureCallback<DataTreeCandidate> callback) {
490             preCommit = mockFutureCallback(callback);
491             delegate.preCommit(preCommit);
492         }
493
494         @Override
495         public void commit(FutureCallback<UnsignedLong> callback) {
496             commit = mockFutureCallback(callback);
497             delegate.commit(commit);
498         }
499
500         @SuppressWarnings("unchecked")
501         private <T> FutureCallback<T> mockFutureCallback(final FutureCallback<T> actual ) {
502             FutureCallback<T> mock = mock(FutureCallback.class);
503             doAnswer(invocation -> {
504                 actual.onFailure(invocation.getArgumentAt(0, Throwable.class));
505                 return null;
506             }).when(mock).onFailure(any(Throwable.class));
507
508             doAnswer(invocation -> {
509                 actual.onSuccess((T) invocation.getArgumentAt(0, Throwable.class));
510                 return null;
511             }).when(mock).onSuccess((T) any(Object.class));
512
513             return mock;
514         }
515
516         @Override
517         public ListenableFuture<Void> abort() {
518             return delegate.abort();
519         }
520
521         @Override
522         public boolean isFailed() {
523             return delegate.isFailed();
524         }
525
526         @Override
527         public State getState() {
528             return delegate.getState();
529         }
530     }
531 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.