Search in sources :

Example 1 with ClientActorContext

use of org.opendaylight.controller.cluster.access.client.ClientActorContext in project controller by opendaylight.

the class AbstractClientHandleTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    system = ActorSystem.apply();
    final TestProbe contextProbe = new TestProbe(system, "context");
    final TestProbe clientContextProbe = new TestProbe(system, "client-context");
    backendProbe = new TestProbe(system, "backend");
    // create handle dependencies
    final ActorContext actorContext = createActorContextMock(system, contextProbe.ref());
    final ClientActorContext clientContext = AccessClientUtil.createClientActorContext(system, clientContextProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
    client = new SimpleDataStoreClientBehavior(clientContext, actorContext, "shard");
    client.createLocalHistory();
    parent = new SingleClientHistory(client, HISTORY_ID);
    // connect client
    client.getConnection(0L);
    contextProbe.expectMsgClass(ConnectClientRequest.class);
    final long sequence = 0L;
    contextProbe.reply(new ConnectClientSuccess(CLIENT_ID, sequence, backendProbe.ref(), Collections.emptyList(), dataTree, 3));
    final InternalCommand<ShardBackendInfo> command = clientContextProbe.expectMsgClass(InternalCommand.class);
    command.execute(client);
    // data tree mock
    when(dataTree.takeSnapshot()).thenReturn(dataTreeSnapshot);
    handle = createHandle(parent);
}
Also used : ConnectClientSuccess(org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess) TestProbe(akka.testkit.TestProbe) ClientActorContext(org.opendaylight.controller.cluster.access.client.ClientActorContext) ActorContext(org.opendaylight.controller.cluster.datastore.utils.ActorContext) ClientActorContext(org.opendaylight.controller.cluster.access.client.ClientActorContext) Before(org.junit.Before)

Example 2 with ClientActorContext

use of org.opendaylight.controller.cluster.access.client.ClientActorContext in project controller by opendaylight.

the class AbstractProxyTransactionTest method createRemoteProxyTransactionTester.

@SuppressWarnings("checkstyle:hiddenField")
protected TransactionTester<RemoteProxyTransaction> createRemoteProxyTransactionTester() {
    final TestProbe clientContextProbe = new TestProbe(system, "remoteClientContext");
    final TestProbe backendProbe = new TestProbe(system, "remoteBackend");
    final AbstractClientHistory history = mock(AbstractClientHistory.class);
    final ClientActorContext 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(), 5);
    final AbstractClientConnection<ShardBackendInfo> connection = AccessClientUtil.createConnectedConnection(context, 0L, backend);
    final ProxyHistory proxyHistory = ProxyHistory.createClient(history, connection, HISTORY_ID);
    final RemoteProxyTransaction transaction = new RemoteProxyTransaction(proxyHistory, TRANSACTION_ID, false, false, false);
    return new TransactionTester<>(transaction, connection, backendProbe);
}
Also used : TestProbe(akka.testkit.TestProbe) ClientActorContext(org.opendaylight.controller.cluster.access.client.ClientActorContext)

Example 3 with ClientActorContext

use of org.opendaylight.controller.cluster.access.client.ClientActorContext in project controller by opendaylight.

the class AbstractProxyTransactionTest method createLocalProxy.

@SuppressWarnings("checkstyle:hiddenField")
protected TransactionTester<LocalReadWriteProxyTransaction> createLocalProxy() {
    final TestProbe backendProbe = new TestProbe(system, "backend2");
    final TestProbe clientContextProbe = new TestProbe(system, "clientContext2");
    final ClientActorContext 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 AbstractClientHistory history = mock(AbstractClientHistory.class);
    final ProxyHistory parent = ProxyHistory.createClient(history, connection, HISTORY_ID);
    final DataTreeSnapshot snapshot = mock(DataTreeSnapshot.class);
    when(snapshot.newModification()).thenReturn(mock(CursorAwareDataTreeModification.class));
    final LocalReadWriteProxyTransaction tx = new LocalReadWriteProxyTransaction(parent, TestUtils.TRANSACTION_ID, snapshot);
    return new TransactionTester<>(tx, connection, backendProbe);
}
Also used : TestProbe(akka.testkit.TestProbe) ClientActorContext(org.opendaylight.controller.cluster.access.client.ClientActorContext) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot) CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)

Example 4 with ClientActorContext

use of org.opendaylight.controller.cluster.access.client.ClientActorContext in project controller by opendaylight.

the class ClientLocalHistoryTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    system = ActorSystem.apply();
    final TestProbe clientContextProbe = new TestProbe(system, "client");
    final TestProbe actorContextProbe = new TestProbe(system, "actor-context");
    clientActorContext = AccessClientUtil.createClientActorContext(system, clientContextProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
    final ActorContext actorContextMock = createActorContextMock(system, actorContextProbe.ref());
    behavior = new SimpleDataStoreClientBehavior(clientActorContext, actorContextMock, SHARD_NAME);
    object = new ClientLocalHistory(behavior, HISTORY_ID);
}
Also used : TestProbe(akka.testkit.TestProbe) ClientActorContext(org.opendaylight.controller.cluster.access.client.ClientActorContext) ActorContext(org.opendaylight.controller.cluster.datastore.utils.ActorContext) Before(org.junit.Before)

Example 5 with ClientActorContext

use of org.opendaylight.controller.cluster.access.client.ClientActorContext 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)

Aggregations

TestProbe (akka.testkit.TestProbe)7 ClientActorContext (org.opendaylight.controller.cluster.access.client.ClientActorContext)7 Before (org.junit.Before)5 ActorContext (org.opendaylight.controller.cluster.datastore.utils.ActorContext)3 ConnectClientSuccess (org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess)1 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)1 DataTreeSnapshot (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot)1