use of akka.testkit.TestProbe in project controller by opendaylight.
the class AbstractDataStoreClientBehaviorTest method setUp.
@Before
public void setUp() throws Exception {
system = ActorSystem.apply();
clientActorProbe = new TestProbe(system, "client");
actorContextProbe = new TestProbe(system, "actor-context");
final ActorContext context = createActorContextMock(system, actorContextProbe.ref());
clientContext = AccessClientUtil.createClientActorContext(system, clientActorProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
behavior = createBehavior(clientContext, context);
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class AbstractDataStoreClientBehaviorTest method testGetConnection.
@Test
public void testGetConnection() throws Exception {
// set up data tree mock
final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
when(modification.readNode(YangInstanceIdentifier.EMPTY)).thenReturn(Optional.empty());
final DataTreeSnapshot snapshot = mock(DataTreeSnapshot.class);
when(snapshot.newModification()).thenReturn(modification);
final DataTree dataTree = mock(DataTree.class);
when(dataTree.takeSnapshot()).thenReturn(snapshot);
final TestProbe backendProbe = new TestProbe(system, "backend");
final long shard = 0L;
behavior.createTransaction().read(YangInstanceIdentifier.EMPTY);
final AbstractClientConnection<ShardBackendInfo> connection = behavior.getConnection(shard);
// check cached connection for same shard
Assert.assertSame(connection, behavior.getConnection(shard));
final ConnectClientRequest connectClientRequest = actorContextProbe.expectMsgClass(ConnectClientRequest.class);
Assert.assertEquals(CLIENT_ID, connectClientRequest.getTarget());
final long sequence = 0L;
Assert.assertEquals(sequence, connectClientRequest.getSequence());
actorContextProbe.reply(new ConnectClientSuccess(CLIENT_ID, sequence, backendProbe.ref(), Collections.emptyList(), dataTree, 3));
Assert.assertEquals(clientActorProbe.ref(), connection.localActor());
// capture and execute command passed to client context
final InternalCommand<ShardBackendInfo> command = clientActorProbe.expectMsgClass(InternalCommand.class);
command.execute(behavior);
// check, whether command was reaplayed
verify(modification).readNode(YangInstanceIdentifier.EMPTY);
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class AbstractProxyTransactionTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
system = ActorSystem.apply();
clientContextProbe = new TestProbe(system, "clientContext");
backendProbe = new TestProbe(system, "backend");
context = AccessClientUtil.createClientActorContext(system, clientContextProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
final ShardBackendInfo backend = new ShardBackendInfo(backendProbe.ref(), 0L, ABIVersion.BORON, "default", UnsignedLong.ZERO, Optional.empty(), 3);
final AbstractClientConnection<ShardBackendInfo> connection = AccessClientUtil.createConnectedConnection(context, 0L, backend);
final ProxyHistory parent = ProxyHistory.createClient(history, connection, HISTORY_ID);
transaction = createTransaction(parent, TestUtils.TRANSACTION_ID, snapshot);
tester = new TransactionTester<>(transaction, connection, backendProbe);
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class AbstractProxyTransactionTest method testForwardToRemotePurge.
@Test
public void testForwardToRemotePurge() throws Exception {
final TestProbe probe = new TestProbe(system);
final TransactionPurgeRequest request = new TransactionPurgeRequest(TRANSACTION_ID, 0L, probe.ref());
testForwardToRemote(request, TransactionPurgeRequest.class);
}
use of akka.testkit.TestProbe in project controller by opendaylight.
the class ClientTransactionCommitCohortTest 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);
transactions = new ArrayList<>();
for (int i = 0; i < TRANSACTIONS; i++) {
transactions.add(createTransactionTester(new TestProbe(system, "backend" + i), context, history));
}
final Collection<AbstractProxyTransaction> proxies = transactions.stream().map(TransactionTester::getTransaction).collect(Collectors.toList());
proxies.forEach(AbstractProxyTransaction::seal);
cohort = new ClientTransactionCommitCohort(history, TRANSACTION_ID, proxies);
}
Aggregations