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


Java ActorRef.tell方法代码示例

本文整理汇总了Java中akka.actor.ActorRef.tell方法的典型用法代码示例。如果您正苦于以下问题:Java ActorRef.tell方法的具体用法?Java ActorRef.tell怎么用?Java ActorRef.tell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在akka.actor.ActorRef的用法示例。


在下文中一共展示了ActorRef.tell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddShardReplicaWithFindPrimaryTimeout

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void testAddShardReplicaWithFindPrimaryTimeout() throws Exception {
    LOG.info("testAddShardReplicaWithFindPrimaryTimeout starting");
    datastoreContextBuilder.shardInitializationTimeout(100, TimeUnit.MILLISECONDS);
    new JavaTestKit(getSystem()) {
        {
            MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder()
                    .put("astronauts", Arrays.asList("member-2")).build());

            final ActorRef newReplicaShardManager = actorFactory
                    .createActor(newTestShardMgrBuilder(mockConfig).shardActor(mockShardActor).props()
                            .withDispatcher(Dispatchers.DefaultDispatcherId()), shardMgrID);

            newReplicaShardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
            MockClusterWrapper.sendMemberUp(newReplicaShardManager, "member-2",
                    AddressFromURIString.parse("akka://[email protected]:5").toString());

            newReplicaShardManager.tell(new AddShardReplica("astronauts"), getRef());
            Status.Failure resp = expectMsgClass(duration("5 seconds"), Status.Failure.class);
            assertEquals("Failure obtained", true, resp.cause() instanceof RuntimeException);
        }
    };

    LOG.info("testAddShardReplicaWithFindPrimaryTimeout ending");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:26,代码来源:ShardManagerTest.java

示例2: testA1CreateBatchWithInvalidOrgId

import akka.actor.ActorRef; //导入方法依赖的package包/类
public void testA1CreateBatchWithInvalidOrgId(){
  
  TestKit probe = new TestKit(system);
  ActorRef subject = system.actorOf(props);
  Request reqObj = new Request();
  reqObj.setOperation(ActorOperations.CREATE_BATCH.getValue());
  HashMap<String, Object> innerMap = new HashMap<>();
  innerMap.put(JsonKey.COURSE_ID, courseId);
  innerMap.put(JsonKey.NAME, "DUMMY_COURSE_NAME1");
  innerMap.put(JsonKey.ENROLLMENT_TYPE, "invite-only");
  innerMap.put(JsonKey.START_DATE , (String)format.format(new Date()));
  innerMap.put(JsonKey.HASHTAGID ,hashTagId );
  Calendar now =  Calendar.getInstance();
  now.add(Calendar.DAY_OF_MONTH, 5);
  Date after5Days = now.getTime();
  innerMap.put(JsonKey.END_DATE , (String)format.format(after5Days));
  List<String> orgList = new ArrayList<>();
  orgList.add("12589");
  innerMap.put(JsonKey.COURSE_CREATED_FOR, orgList);
  reqObj.getRequest().put(JsonKey.BATCH, innerMap);
  subject.tell(reqObj, probe.getRef());
  probe.expectMsgClass(duration("1000 second"),ProjectCommonException.class);
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:24,代码来源:CourseBatchManagementActorTest.java

示例3: testWithInvalidCourseBatchId

import akka.actor.ActorRef; //导入方法依赖的package包/类
public void testWithInvalidCourseBatchId() {
  TestKit probe = new TestKit(system);
  ActorRef subject = system.actorOf(props);

  Request reqObj = new Request();
  reqObj.setRequestId("1");
  reqObj.setOperation(ActorOperations.ENROLL_COURSE.getValue());
  reqObj.put(JsonKey.COURSE_ID, "do_212282810555342848180");
  reqObj.put(JsonKey.USER_ID, "USR");
  reqObj.put(JsonKey.BATCH_ID,batchId+0123);
  HashMap<String, Object> innerMap = new HashMap<>();
  innerMap.put(JsonKey.COURSE, reqObj.getRequest());
  innerMap.put(JsonKey.USER_ID, "USR");
  reqObj.setRequest(innerMap);

  subject.tell(reqObj, probe.getRef());
  probe.expectMsgClass(duration("100 second"), ProjectCommonException.class);
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:19,代码来源:CourseEnrollmentActorTest.java

示例4: onReceiveOfMessageCoffeeHouseShouldLogMessage

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void onReceiveOfMessageCoffeeHouseShouldLogMessage() {
    new JavaTestKit(system) {{
        ActorRef coffeeHouse = system.actorOf(Props.create(CoffeeHouse.class));
        coffeeHouse.tell("Brew Coffee", getRef());
        new ExpectMsg<String>("Some [Cc]offee response") {
            @Override
            protected String match(Object msg) {
                if (msg.toString().matches(".*[Cc]offee.*")) {
                    return "match";
                } else {
                    throw noMatch();
                }
            }
        }.get();
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-student,代码行数:18,代码来源:CoffeeHouseTest.java

示例5: shouldRestartWaiterAndResendPrepareCoffeeToBaristaOnFailure

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void shouldRestartWaiterAndResendPrepareCoffeeToBaristaOnFailure() {
    new JavaTestKit(system) {{
        createActor(CoffeeHouse.class, "resend-prepare-coffee", () -> new CoffeeHouse(Integer.MAX_VALUE) {
            @Override
            protected ActorRef createBarista() {
                return getRef();
            }

            @Override
            protected ActorRef createWaiter() { //stubbing out the waiter actor to always throw exception
                return context().actorOf(Props.create(AbstractActor.class, () -> new AbstractActor() {{
                    receive(
                            ReceiveBuilder.matchAny(o -> {
                                throw new Waiter.FrustratedException(new Coffee.Akkaccino(), system.deadLetters());
                            }).build());
                }}), "waiter");
            }
        });
        ActorRef waiter = expectActor(this, "/user/resend-prepare-coffee/waiter");
        waiter.tell("Blow up", ActorRef.noSender());
        expectMsgEquals(new Barista.PrepareCoffee(new Coffee.Akkaccino(), system.deadLetters()));
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-old,代码行数:25,代码来源:CoffeeHouseTest.java

示例6: test7UpdateClientKeyFailureInvalidKey

import akka.actor.ActorRef; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void test7UpdateClientKeyFailureInvalidKey(){
  TestKit probe = new TestKit(system);
  ActorRef subject = system.actorOf(props);

  Request actorMessage = new Request();
  Map<String, Object> request = new HashMap<>();
  request.put(JsonKey.CLIENT_ID , clientId);
  request.put(JsonKey.MASTER_KEY, "test");
  actorMessage.setRequest(request);
  actorMessage.setOperation(ActorOperations.UPDATE_CLIENT_KEY.getValue());

  subject.tell(actorMessage, probe.getRef());
  ProjectCommonException res = probe.expectMsgClass(duration("10 second"),ProjectCommonException.class);
  if(null != res){
    Assert.assertEquals(ResponseMessage.Message.INVALID_REQUESTED_DATA, res.getMessage());
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:20,代码来源:ClientManagementActorTest.java

示例7: Z14TestuserLoginWithValidEmail

import akka.actor.ActorRef; //导入方法依赖的package包/类
@SuppressWarnings({"deprecation", "unchecked"})
@Test
public void Z14TestuserLoginWithValidEmail(){
  TestKit probe = new TestKit(system);
  ActorRef subject = system.actorOf(props);
  Request reqObj = new Request();
  reqObj.setOperation(ActorOperations.LOGIN.getValue());
  Map<String, Object> innerMap = new HashMap<>();
  innerMap.put(JsonKey.USERNAME, "[email protected]");
  innerMap.put(JsonKey.PASSWORD, "password");
  innerMap.put(JsonKey.SOURCE, "web");
  Map<String, Object> request = new HashMap<String, Object>();
  request.put(JsonKey.USER, innerMap);
  reqObj.setRequest(request);

  subject.tell(reqObj, probe.getRef());
  Response response = probe.expectMsgClass(duration("200 second"), Response.class);
  authToken =  (String) ((Map<String,Object>)response.get(JsonKey.RESPONSE)).get(JsonKey.ACCESSTOKEN);
  System.out.println("Auth token :: "+authToken);
  if(null != response){
    Assert.assertEquals(response.getResponseCode().getResponseCode(), ResponseCode.OK.getResponseCode());
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:24,代码来源:UserManagementActorTest.java

示例8: onTerminationOfGuestCoffeeHouseShouldRemoveGuestFromBookkeeper

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void onTerminationOfGuestCoffeeHouseShouldRemoveGuestFromBookkeeper() {
    new JavaTestKit(system) {{
        ActorRef coffeeHouse = system.actorOf(CoffeeHouse.props(1), "guest-removed");
        coffeeHouse.tell(new CoffeeHouse.CreateGuest(new Coffee.Akkaccino(), Integer.MAX_VALUE), ActorRef.noSender());
        ActorRef guest = expectActor(this, "/user/guest-removed/$*");
        interceptDebugLogMessage(this, ".*[Rr]emoved.*", 1, () -> {
            coffeeHouse.tell(new CoffeeHouse.ApproveCoffee(new Coffee.Akkaccino(), guest), ActorRef.noSender());
        });
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-with-akka,代码行数:12,代码来源:CoffeeHouseTest.java

示例9: sendingPrepareCoffeeShouldResultInCoffeePreparedResponse

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void sendingPrepareCoffeeShouldResultInCoffeePreparedResponse() {
    new JavaTestKit(system) {{
        ActorRef barista = system.actorOf(Barista.props(duration("100 milliseconds"), 100));
        new Within(duration("50 milliseconds"), duration("1000 milliseconds")) {
            @Override
            protected void run() {
                barista.tell(new Barista.PrepareCoffee(new Coffee.Akkaccino(), system.deadLetters()), getRef());
                expectMsgEquals(new Barista.CoffeePrepared(new Coffee.Akkaccino(), system.deadLetters()));
            }
        };
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-old,代码行数:14,代码来源:BaristaTest.java

示例10: sendingApproveCoffeeShouldResultInLoggingStatusMessageWhenLimitReached

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void sendingApproveCoffeeShouldResultInLoggingStatusMessageWhenLimitReached() {
    new JavaTestKit(system) {{
        ActorRef coffeeHouse = system.actorOf(CoffeeHouse.props(1), "caffeine-limit");
        coffeeHouse.tell(new CoffeeHouse.CreateGuest(new Coffee.Akkaccino(), Integer.MAX_VALUE), ActorRef.noSender());
        ActorRef guest = expectActor(this, "/user/caffeine-limit/$*");
        interceptInfoLogMessage(this, ".*[Ss]orry.*", 1, () -> coffeeHouse.tell(
                new CoffeeHouse.ApproveCoffee(new Coffee.Akkaccino(), guest), ActorRef.noSender()));
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-old,代码行数:11,代码来源:CoffeeHouseTest.java

示例11: getCourseByIdOnReceiveTest

import akka.actor.ActorRef; //导入方法依赖的package包/类
public void getCourseByIdOnReceiveTest() {
    TestKit probe = new TestKit(system);
    ActorRef subject = system.actorOf(props);

    Request reqObj = new Request();
    reqObj.setOperation(ActorOperations.GET_COURSE_BY_ID.getValue());
    HashMap<String, Object> innerMap = new HashMap<>();
    innerMap.put(JsonKey.ID, "NTP course id_71");
    innerMap.put(JsonKey.REQUESTED_BY, "user-001");
    reqObj.setRequest(innerMap);
    subject.tell(reqObj, probe.getRef());
    Response res = probe.expectMsgClass(Response.class);

}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:15,代码来源:CourseSearchActorTest.java

示例12: shouldSendComplaintWhenWrongDrinkIsSent

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void shouldSendComplaintWhenWrongDrinkIsSent() {
    new JavaTestKit(system) {{
        ActorRef guest = createGuest(this, getRef());
        guest.tell(new Waiter.CoffeeServed(new Coffee.MochaPlay()), ActorRef.noSender());
        expectMsgEquals(new Waiter.Complaint((new Coffee.Akkaccino())));
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-with-akka,代码行数:9,代码来源:GuestTest.java

示例13: sendingApproveCoffeeShouldForwardPrepareCoffeeIfCaffeineLimitNotReached

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void sendingApproveCoffeeShouldForwardPrepareCoffeeIfCaffeineLimitNotReached() {
    new JavaTestKit(system) {{
        ActorRef coffeeHouse = createActor(CoffeeHouse.class, "prepare-coffee", () -> new CoffeeHouse(Integer.MAX_VALUE) {
            @Override
            protected ActorRef createBarista() {
                return getRef();
            }
        });
        coffeeHouse.tell(new CoffeeHouse.CreateGuest(new Coffee.Akkaccino(), Integer.MAX_VALUE), ActorRef.noSender());
        ActorRef guest = expectActor(this, "/user/prepare-coffee/$*");
        coffeeHouse.tell(new CoffeeHouse.ApproveCoffee(new Coffee.Akkaccino(), guest), getRef());
        expectMsgEquals(new Barista.PrepareCoffee(new Coffee.Akkaccino(), guest));
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-student,代码行数:16,代码来源:CoffeeHouseTest.java

示例14: TestGUpdateUserAddressInfo

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void TestGUpdateUserAddressInfo() {
  TestKit probe = new TestKit(system);
  ActorRef subject = system.actorOf(props);

  Request reqObj = new Request();
  reqObj.setOperation(ActorOperations.UPDATE_USER.getValue());
  Map<String, Object> innerMap = new HashMap<>();
  innerMap.put(JsonKey.LAST_NAME, "user_last_name_twice");
  List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  Map<String, Object> address = new HashMap<String, Object>();
  address.put(JsonKey.ADDRESS_LINE1, "addr line1");
  innerMap.put(JsonKey.USER_ID, userId);
  address.put(JsonKey.CITY, "new city");
  address.put(JsonKey.ID, addressId);
  list.add(address);
  innerMap.put(JsonKey.ADDRESS, list);
  Map<String, Object> request = new HashMap<String, Object>();
  request.put(JsonKey.USER, innerMap);
  reqObj.setRequest(request);

  subject.tell(reqObj, probe.getRef());
  probe.expectMsgClass(duration("200 second"), Response.class);
  try {
    Thread.sleep(3000);
  } catch (InterruptedException e) {
    e.printStackTrace();
  }

}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:31,代码来源:UserManagementActorTest.java

示例15: sendingApproveCoffeeShouldResultInLoggingStatusMessageWhenLimitReached

import akka.actor.ActorRef; //导入方法依赖的package包/类
@Test
public void sendingApproveCoffeeShouldResultInLoggingStatusMessageWhenLimitReached() {
    new JavaTestKit(system) {{
        ActorRef coffeeHouse = system.actorOf(CoffeeHouse.props(1), "caffeine-limit");
        coffeeHouse.tell(new CoffeeHouse.CreateGuest(new Coffee.Akkaccino()), ActorRef.noSender());
        ActorRef guest = expectActor(this, "/user/caffeine-limit/$*");
        interceptInfoLogMessage(this, ".*[Ss]orry.*", 1, () -> coffeeHouse.tell(
                new CoffeeHouse.ApproveCoffee(new Coffee.Akkaccino(), guest), ActorRef.noSender()));
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-with-akka,代码行数:11,代码来源:CoffeeHouseTest.java


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