当前位置: 首页>>代码示例>>Java>>正文


Java TestProbe.expectMsgClass方法代码示例

本文整理汇总了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];
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-with-akka,代码行数:15,代码来源:BaseAkkaTestCase.java

示例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());
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:RoleChangeNotifierTest.java

示例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);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:28,代码来源:AbstractClientHandleTest.java

示例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);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:AbstractDataStoreClientBehaviorTest.java

示例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);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:7,代码来源:RoleChangeNotifierTest.java


注:本文中的akka.testkit.TestProbe.expectMsgClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。