本文整理汇总了Java中akka.testkit.TestProbe.ref方法的典型用法代码示例。如果您正苦于以下问题:Java TestProbe.ref方法的具体用法?Java TestProbe.ref怎么用?Java TestProbe.ref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类akka.testkit.TestProbe
的用法示例。
在下文中一共展示了TestProbe.ref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLocalProxy
import akka.testkit.TestProbe; //导入方法依赖的package包/类
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);
}
示例2: testHandleForwardedRemoteReadRequest
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@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());
}
示例3: testHandleForwardedRemoteExistsRequest
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testHandleForwardedRemoteExistsRequest() throws Exception {
final TestProbe probe = createProbe();
final ExistsTransactionRequest request =
new ExistsTransactionRequest(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 ExistsTransactionSuccess);
final ExistsTransactionSuccess success = (ExistsTransactionSuccess) value;
Assert.assertTrue(success.getExists());
}
示例4: applyModifyTransactionRequest
import akka.testkit.TestProbe; //导入方法依赖的package包/类
private void applyModifyTransactionRequest(final boolean coordinated) {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder =
new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
final TransactionModification write = new TransactionWrite(PATH_1, DATA_1);
final TransactionModification merge = new TransactionMerge(PATH_2, DATA_2);
final TransactionModification delete = new TransactionDelete(PATH_3);
builder.addModification(write);
builder.addModification(merge);
builder.addModification(delete);
builder.setSequence(0L);
builder.setCommit(coordinated);
final ModifyTransactionRequest request = builder.build();
final Consumer<Response<?, ?>> callback = createCallbackMock();
transaction.replayModifyTransactionRequest(request, callback, Ticker.systemTicker().read());
verify(modification).write(PATH_1, DATA_1);
verify(modification).merge(PATH_2, DATA_2);
verify(modification).delete(PATH_3);
final CommitLocalTransactionRequest commitRequest =
getTester().expectTransactionRequest(CommitLocalTransactionRequest.class);
Assert.assertEquals(modification, commitRequest.getModification());
Assert.assertEquals(coordinated, commitRequest.isCoordinated());
}
示例5: testApplyModifyTransactionRequestNotAbort
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testApplyModifyTransactionRequestNotAbort() throws Exception {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder =
new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
builder.setSequence(0);
builder.setReady();
final ModifyTransactionRequest request = builder.build();
assertOperationThrowsException(() -> transaction.replayModifyTransactionRequest(request, createCallbackMock(),
Ticker.systemTicker().read()), VerifyException.class);
}
示例6: testForwardToRemoteAbort
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Override
@Test
public void testForwardToRemoteAbort() throws Exception {
final TestProbe probe = createProbe();
final TransactionAbortRequest request = new TransactionAbortRequest(TRANSACTION_ID, 0L, probe.ref());
testForwardToRemote(request, TransactionAbortRequest.class);
}
示例7: testForwardToRemoteModifyCommitSimple
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testForwardToRemoteModifyCommitSimple() throws Exception {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder =
new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
builder.setSequence(0L);
builder.setCommit(false);
final ModifyTransactionRequest request = builder.build();
final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
Assert.assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
Assert.assertEquals(request.getModifications(), received.getModifications());
Assert.assertEquals(request.getTarget(), received.getTarget());
}
示例8: testForwardToRemoteModifyCommit3Phase
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testForwardToRemoteModifyCommit3Phase() throws Exception {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder =
new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
builder.setSequence(0L);
builder.setCommit(true);
final ModifyTransactionRequest request = builder.build();
final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
Assert.assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
Assert.assertEquals(request.getModifications(), received.getModifications());
Assert.assertEquals(request.getTarget(), received.getTarget());
}
示例9: testForwardToRemoteAbort
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@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());
}
示例10: testRoutingLogic
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testRoutingLogic() {
List<Pair<ActorRef, Long>> pairList = new ArrayList<>();
TestProbe probe1 = new TestProbe(system);
TestProbe probe2 = new TestProbe(system);
TestProbe probe3 = new TestProbe(system);
ActorRef actor1 = probe1.ref();
ActorRef actor2 = probe2.ref();
ActorRef actor3 = probe3.ref();
pairList.add(new Pair<>(actor1, 1000L));
pairList.add(new Pair<>(actor2, 3000L));
pairList.add(new Pair<>(actor3, 2000L));
RoutingLogic logic = new LatestEntryRoutingLogic(pairList);
assertTrue(logic.select().equals(actor2));
}
示例11: testApplyModifyTransactionRequest
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testApplyModifyTransactionRequest() throws Exception {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder =
new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
builder.setSequence(0);
builder.setAbort();
final ModifyTransactionRequest request = builder.build();
transaction.replayModifyTransactionRequest(request, createCallbackMock(), Ticker.systemTicker().read());
getTester().expectTransactionRequest(AbortLocalTransactionRequest.class);
}
示例12: testForwardToRemoteModifyPreCommit
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@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());
}
示例13: testHandleForwardedRemotePreCommitRequest
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testHandleForwardedRemotePreCommitRequest() throws Exception {
final TestProbe probe = createProbe();
final TransactionPreCommitRequest request =
new TransactionPreCommitRequest(TRANSACTION_ID, 0L, probe.ref());
testHandleForwardedRemoteRequest(request);
}
示例14: setup
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
system = ActorSystem.apply();
probe = new TestProbe(system);
ctx = new ClientActorContext(probe.ref(), PERSISTENCE_ID, system,
CLIENT_ID, AccessClientUtil.newMockClientActorConfig());
}
示例15: testHandleForwardedRemoteAbortRequest
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testHandleForwardedRemoteAbortRequest() throws Exception {
final TestProbe probe = createProbe();
final TransactionAbortRequest request =
new TransactionAbortRequest(TRANSACTION_ID, 0L, probe.ref());
testHandleForwardedRemoteRequest(request);
}