use of akka.testkit.TestProbe in project controller by opendaylight.
the class ModuleShardBackendResolverTest method testRefreshBackendInfo.
@Test
public void testRefreshBackendInfo() throws Exception {
final CompletionStage<ShardBackendInfo> backendInfo = moduleShardBackendResolver.getBackendInfo(0L);
// handle first connect
contextProbe.expectMsgClass(ConnectClientRequest.class);
final TestProbe staleBackendProbe = new TestProbe(system, "staleBackend");
final ConnectClientSuccess msg = new ConnectClientSuccess(CLIENT_ID, 0L, staleBackendProbe.ref(), Collections.emptyList(), dataTree, 3);
contextProbe.reply(msg);
// get backend info
final ShardBackendInfo staleBackendInfo = TestUtils.getWithTimeout(backendInfo.toCompletableFuture());
// refresh
final CompletionStage<ShardBackendInfo> refreshed = moduleShardBackendResolver.refreshBackendInfo(0L, staleBackendInfo);
// stale backend info should be removed and new connect request issued to the context
contextProbe.expectMsgClass(ConnectClientRequest.class);
final TestProbe refreshedBackendProbe = new TestProbe(system, "refreshedBackend");
final ConnectClientSuccess msg2 = new ConnectClientSuccess(CLIENT_ID, 1L, refreshedBackendProbe.ref(), Collections.emptyList(), dataTree, 3);
contextProbe.reply(msg2);
final ShardBackendInfo refreshedBackendInfo = TestUtils.getWithTimeout(refreshed.toCompletableFuture());
Assert.assertEquals(staleBackendInfo.getCookie(), refreshedBackendInfo.getCookie());
Assert.assertEquals(refreshedBackendProbe.ref(), refreshedBackendInfo.getActor());
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class RemoteProxyTransactionTest method testForwardToRemoteModifyRead.
@Test
public void testForwardToRemoteModifyRead() throws Exception {
final TestProbe probe = createProbe();
final ReadTransactionRequest request = new ReadTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, false);
final ReadTransactionRequest received = testForwardToRemote(request, ReadTransactionRequest.class);
Assert.assertEquals(request.getTarget(), received.getTarget());
Assert.assertEquals(request.getPath(), received.getPath());
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class RemoteProxyTransactionTest method testForwardToRemoteModifyAbort.
@Test
public void testForwardToRemoteModifyAbort() 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 ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
Assert.assertEquals(request.getTarget(), received.getTarget());
Assert.assertTrue(received.getPersistenceProtocol().isPresent());
Assert.assertEquals(PersistenceProtocol.ABORT, received.getPersistenceProtocol().get());
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class RemoteProxyTransactionTest method testForwardToRemoteModifyPreCommit.
@Test
public void testForwardToRemoteModifyPreCommit() throws Exception {
final TestProbe probe = createProbe();
final TransactionPreCommitRequest request = new TransactionPreCommitRequest(TRANSACTION_ID, 0L, probe.ref());
final TransactionPreCommitRequest received = testForwardToRemote(request, TransactionPreCommitRequest.class);
Assert.assertEquals(request.getTarget(), received.getTarget());
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class RemoteProxyTransactionTest method testForwardToRemoteModifyDoCommit.
@Test
public void testForwardToRemoteModifyDoCommit() throws Exception {
final TestProbe probe = createProbe();
final TransactionDoCommitRequest request = new TransactionDoCommitRequest(TRANSACTION_ID, 0L, probe.ref());
final TransactionDoCommitRequest received = testForwardToRemote(request, TransactionDoCommitRequest.class);
Assert.assertEquals(request.getTarget(), received.getTarget());
}
Aggregations