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);
}
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());
}
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);
}
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());
}
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);
}
Aggregations