Search in sources :

Example 6 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class DirectTransactionCommitCohortTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    system = ActorSystem.apply();
    final TestProbe clientContextProbe = new TestProbe(system, "clientContext");
    final ClientActorContext context = AccessClientUtil.createClientActorContext(system, clientContextProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
    transaction = createTransactionTester(new TestProbe(system, "backend"), context, history);
    final AbstractProxyTransaction proxy = transaction.getTransaction();
    proxy.seal();
    cohort = new DirectTransactionCommitCohort(history, TRANSACTION_ID, proxy);
}
Also used : TestProbe(akka.testkit.TestProbe) ClientActorContext(org.opendaylight.controller.cluster.access.client.ClientActorContext) Before(org.junit.Before)

Example 7 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class LocalProxyTransactionTest method testForwardToRemoteAbort.

@Override
@Test
public void testForwardToRemoteAbort() throws Exception {
    final TestProbe probe = createProbe();
    final AbortLocalTransactionRequest request = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
    final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
    Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.ABORT, modifyRequest.getPersistenceProtocol().get());
}
Also used : AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) TestProbe(akka.testkit.TestProbe) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 8 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class LocalProxyTransactionTest method testForwardToRemoteCommit.

@Override
@Test
public void testForwardToRemoteCommit() throws Exception {
    final TestProbe probe = createProbe();
    final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
    final CommitLocalTransactionRequest request = new CommitLocalTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), modification, null, true);
    doAnswer(LocalProxyTransactionTest::applyToCursorAnswer).when(modification).applyToCursor(any());
    final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
    verify(modification).applyToCursor(any());
    Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.THREE_PHASE, modifyRequest.getPersistenceProtocol().get());
    checkModifications(modifyRequest);
}
Also used : TestProbe(akka.testkit.TestProbe) CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) Test(org.junit.Test)

Example 9 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class LocalProxyTransactionTest method testHandleForwardedRemoteReadRequest.

@Test
public void testHandleForwardedRemoteReadRequest() throws Exception {
    final TestProbe probe = createProbe();
    final ReadTransactionRequest request = new ReadTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, true);
    final Consumer<Response<?, ?>> callback = createCallbackMock();
    setupExecuteInActor();
    transaction.handleReplayedRemoteRequest(request, callback, Ticker.systemTicker().read());
    final ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
    verify(callback).accept(captor.capture());
    final Response<?, ?> value = captor.getValue();
    Assert.assertTrue(value instanceof ReadTransactionSuccess);
    final ReadTransactionSuccess success = (ReadTransactionSuccess) value;
    Assert.assertTrue(success.getData().isPresent());
    Assert.assertEquals(DATA_1, success.getData().get());
}
Also used : Response(org.opendaylight.controller.cluster.access.concepts.Response) TestProbe(akka.testkit.TestProbe) ReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest) ReadTransactionSuccess(org.opendaylight.controller.cluster.access.commands.ReadTransactionSuccess) Test(org.junit.Test)

Example 10 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class LocalProxyTransactionTest method testForwardToLocalPurge.

@Test
public void testForwardToLocalPurge() throws Exception {
    final TestProbe probe = createProbe();
    final TransactionPurgeRequest request = new TransactionPurgeRequest(TRANSACTION_ID, 0L, probe.ref());
    testForwardToLocal(request, TransactionPurgeRequest.class);
}
Also used : TransactionPurgeRequest(org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest) 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