本文整理汇总了Java中akka.testkit.TestProbe.expectMsgClass方法的典型用法代码示例。如果您正苦于以下问题:Java TestProbe.expectMsgClass方法的具体用法?Java TestProbe.expectMsgClass怎么用?Java TestProbe.expectMsgClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类akka.testkit.TestProbe
的用法示例。
在下文中一共展示了TestProbe.expectMsgClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expectActor
import akka.testkit.TestProbe; //导入方法依赖的package包/类
public ActorRef expectActor(JavaTestKit kit, String path) {
final ActorRef[] actor = {null};
kit.new AwaitCond(kit.duration("3 seconds"), kit.duration("150 millis"), "No actor found with " + path) {
@Override
protected boolean cond() {
TestProbe probe = new TestProbe(system);
system.actorSelection(path).tell(new akka.actor.Identify(101), probe.ref());
ActorIdentity i = probe.expectMsgClass(kit.duration("100 millis"), ActorIdentity.class);
actor[0] = i.getRef();
return i.getRef() != null;
}
};
return actor[0];
}
示例2: checkListenerRoleChangeNotification
import akka.testkit.TestProbe; //导入方法依赖的package包/类
private void checkListenerRoleChangeNotification(final RoleChanged roleChanged) {
for (final TestProbe listener : listeners) {
final RoleChangeNotification received = listener.expectMsgClass(RoleChangeNotification.class);
Assert.assertEquals(roleChanged.getMemberId(), received.getMemberId());
Assert.assertEquals(roleChanged.getOldRole(), received.getOldRole());
Assert.assertEquals(roleChanged.getNewRole(), received.getNewRole());
}
}
示例3: setUp
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@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);
}
示例4: testOnCommand
import akka.testkit.TestProbe; //导入方法依赖的package包/类
@Test
public void testOnCommand() throws Exception {
final TestProbe probe = new TestProbe(system);
final GetClientRequest request = new GetClientRequest(probe.ref());
final AbstractDataStoreClientBehavior nextBehavior = behavior.onCommand(request);
final Status.Success success = probe.expectMsgClass(Status.Success.class);
Assert.assertEquals(behavior, success.status());
Assert.assertSame(behavior, nextBehavior);
}
示例5: registerListeners
import akka.testkit.TestProbe; //导入方法依赖的package包/类
private void registerListeners() {
for (final TestProbe listener : listeners) {
notifier.tell(new RegisterRoleChangeListener(), listener.ref());
listener.expectMsgClass(RegisterRoleChangeListenerReply.class);
}
}