use of akka.testkit.TestProbe in project controller by opendaylight.
the class LocalReadWriteProxyTransactionTest method applyModifyTransactionRequest.
private void applyModifyTransactionRequest(final boolean coordinated) {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
final TransactionModification write = new TransactionWrite(PATH_1, DATA_1);
final TransactionModification merge = new TransactionMerge(PATH_2, DATA_2);
final TransactionModification delete = new TransactionDelete(PATH_3);
builder.addModification(write);
builder.addModification(merge);
builder.addModification(delete);
builder.setSequence(0L);
builder.setCommit(coordinated);
final ModifyTransactionRequest request = builder.build();
final Consumer<Response<?, ?>> callback = createCallbackMock();
transaction.replayModifyTransactionRequest(request, callback, Ticker.systemTicker().read());
verify(modification).write(PATH_1, DATA_1);
verify(modification).merge(PATH_2, DATA_2);
verify(modification).delete(PATH_3);
final CommitLocalTransactionRequest commitRequest = getTester().expectTransactionRequest(CommitLocalTransactionRequest.class);
Assert.assertEquals(modification, commitRequest.getModification());
Assert.assertEquals(coordinated, commitRequest.isCoordinated());
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class LocalReadWriteProxyTransactionTest method testApplyModifyTransactionRequestAbort.
@Test
public void testApplyModifyTransactionRequestAbort() throws Exception {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
builder.setSequence(0L);
builder.setAbort();
final ModifyTransactionRequest request = builder.build();
final Consumer<Response<?, ?>> callback = createCallbackMock();
transaction.replayModifyTransactionRequest(request, callback, Ticker.systemTicker().read());
getTester().expectTransactionRequest(AbortLocalTransactionRequest.class);
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class ModuleShardBackendResolverTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
system = ActorSystem.apply();
contextProbe = new TestProbe(system, "context");
final ActorContext actorContext = createActorContextMock(system, contextProbe.ref());
moduleShardBackendResolver = new ModuleShardBackendResolver(CLIENT_ID, actorContext);
when(actorContext.getShardStrategyFactory()).thenReturn(shardStrategyFactory);
when(shardStrategyFactory.getStrategy(YangInstanceIdentifier.EMPTY)).thenReturn(shardStrategy);
final PrimaryShardInfoFutureCache cache = new PrimaryShardInfoFutureCache();
when(actorContext.getPrimaryShardInfoCache()).thenReturn(cache);
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class ModuleShardBackendResolverTest method testGetBackendInfo.
@Test
public void testGetBackendInfo() throws Exception {
final CompletionStage<ShardBackendInfo> i = moduleShardBackendResolver.getBackendInfo(0L);
contextProbe.expectMsgClass(ConnectClientRequest.class);
final TestProbe backendProbe = new TestProbe(system, "backend");
final ConnectClientSuccess msg = new ConnectClientSuccess(CLIENT_ID, 0L, backendProbe.ref(), Collections.emptyList(), dataTree, 3);
contextProbe.reply(msg);
final CompletionStage<ShardBackendInfo> stage = moduleShardBackendResolver.getBackendInfo(0L);
final ShardBackendInfo shardBackendInfo = TestUtils.getWithTimeout(stage.toCompletableFuture());
Assert.assertEquals(0L, shardBackendInfo.getCookie().longValue());
Assert.assertEquals(dataTree, shardBackendInfo.getDataTree().get());
Assert.assertEquals("default", shardBackendInfo.getShardName());
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class RemoteProxyTransactionTest method testForwardToRemoteAbort.
@Override
@Test
public void testForwardToRemoteAbort() throws Exception {
final TestProbe probe = createProbe();
final TransactionAbortRequest request = new TransactionAbortRequest(TRANSACTION_ID, 0L, probe.ref());
testForwardToRemote(request, TransactionAbortRequest.class);
}
Aggregations