Search in sources :

Example 41 with TestProbe

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());
}
Also used : Response(org.opendaylight.controller.cluster.access.concepts.Response) TransactionModification(org.opendaylight.controller.cluster.access.commands.TransactionModification) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) TransactionWrite(org.opendaylight.controller.cluster.access.commands.TransactionWrite) TransactionDelete(org.opendaylight.controller.cluster.access.commands.TransactionDelete) TransactionMerge(org.opendaylight.controller.cluster.access.commands.TransactionMerge) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)

Example 42 with TestProbe

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);
}
Also used : Response(org.opendaylight.controller.cluster.access.concepts.Response) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 43 with TestProbe

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);
}
Also used : TestProbe(akka.testkit.TestProbe) PrimaryShardInfoFutureCache(org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache) ActorContext(org.opendaylight.controller.cluster.datastore.utils.ActorContext) Before(org.junit.Before)

Example 44 with TestProbe

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());
}
Also used : ConnectClientSuccess(org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess) TestProbe(akka.testkit.TestProbe) Test(org.junit.Test)

Example 45 with TestProbe

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);
}
Also used : TransactionAbortRequest(org.opendaylight.controller.cluster.access.commands.TransactionAbortRequest) TestProbe(akka.testkit.TestProbe) Test(org.junit.Test)

Aggregations

TestProbe (akka.testkit.TestProbe)51 Test (org.junit.Test)30 Before (org.junit.Before)13 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)10 ClientActorContext (org.opendaylight.controller.cluster.access.client.ClientActorContext)8 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)7 Response (org.opendaylight.controller.cluster.access.concepts.Response)5 ActorContext (org.opendaylight.controller.cluster.datastore.utils.ActorContext)5 AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)4 ConnectClientSuccess (org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess)4 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)4 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)4 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)3 ExistsTransactionRequest (org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest)3 ReadTransactionRequest (org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest)3 TransactionAbortRequest (org.opendaylight.controller.cluster.access.commands.TransactionAbortRequest)3 ActorRef (akka.actor.ActorRef)2 ArrayList (java.util.ArrayList)2 TransactionDoCommitRequest (org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest)2 TransactionPreCommitRequest (org.opendaylight.controller.cluster.access.commands.TransactionPreCommitRequest)2