public void testProductPlanBacklogItem() throws Exception { ActorInitializer initializer = new ActorInitializer(this.actorRegistry); initializer.putParameter("name", "Test Product"); initializer.putParameter("description", "A decsription."); ActorAgent product = this.actorRegistry.actorFor(Product.class, initializer); product.tell(new PlanBacklogItem( "A summary of the backlog item.", "A story about the backlog item.")); this.stayAlive(); this.actorRegistry.expectedMessages(2); this.actorRegistry.expectedMessage(PlanBacklogItem.class); this.actorRegistry.expectedMessage(BacklogItemPlanned.class); }
/** * @see co.vaughnvernon.actormodel.actor.Actor#self() */ @Override public ActorAgent self() { return this.registry().actorAgentFor(this); }
public LocalMailboxFuture( ActorRegistry anActorRegistry, LocalMailboxActorAgent aReceiverActorAgent, Message aMessage, FutureInterest aFutureInterest) { super(); this.setFutureInterest(aFutureInterest); this.setReceiverAgent(aReceiverActorAgent); ActorInitializer initializer = anActorRegistry.newActorInitializer(); initializer.putParameter("future", this); initializer.putParameter("registry", anActorRegistry); ActorAgent senderAgent = anActorRegistry.actorFor(LocalMailboxFutureActor.class, initializer); this.setSenderAgent(senderAgent); aReceiverActorAgent.sendTo(senderAgent, aMessage, true); }
public void testExecuteWhenMessage() throws Exception { System.out.println("testExecuteMessage()"); ActorAgent agent = actorRegistry.actorFor(TestAggregateActor.class); assertNotNull(agent); agent.tell(new TestMessage()); this.stayAlive(200); }
initializer.putParameter("description", "A decsription."); final ActorAgent product = this.actorRegistry.actorFor(Product.class, initializer); this.actorRegistry.findFirstMatching( Sprint.class, new Query("name", "Sprint 1")); this.actorRegistry.findFirstMatching( BacklogItem.class, new Query("summary", "A summary of the backlog item.")); this.actorRegistry.expectedMessages(6); this.actorRegistry.expectedMessage(PlanBacklogItem.class); this.actorRegistry.expectedMessage(BacklogItemPlanned.class); this.actorRegistry.expectedMessage(ScheduleSprint.class); this.actorRegistry.expectedMessage(SprintScheduled.class); this.actorRegistry.expectedMessage(CommitTo.class); this.actorRegistry.expectedMessage(BacklogItemCommitted.class);
/** * Constructs my default state. * @param anActorRegistry the ActorRegistry */ public ActorInitializer(ActorRegistry anActorRegistry) { super(); this.address = anActorRegistry.newAddress(); this.parameters = new HashMap<String,Object>(); this.registry = anActorRegistry; }
@Override protected void setUp() throws Exception { assertNotNull(this.actorRegistry); this.actorRegistry.expectedMessages(0); super.setUp(); }
@Override public void reactTo(Message aMessage) { this.future.setAnswer(((FutureValueMessage) aMessage).answer()); this.registry().deregister(this.future.sender()); this.future.futureInterest().completedWith(this.future); }
public void when(CommitTo aCommand) { this.sprint = aCommand.sprint(); ActorAgent sprint = this.registry().actorRegisteredAs(Sprint.class, this.sprint); sprint.tell(new BacklogItemCommitted(this.product, this.address(), this.sprint)); }
this.actorRegistry.log(message);
public void testExecuteEvent() throws Exception { System.out.println("testExecuteEvent()"); ActorAgent agent = actorRegistry.actorFor(TestActor.class); assertNotNull(agent); agent.tell(new TestEvent()); this.stayAlive(200); }
public void testExecuteMessage() throws Exception { System.out.println("testExecuteMessage()"); ActorAgent agent = actorRegistry.actorFor(TestActor.class); assertNotNull(agent); agent.tell(new TestMessage()); this.stayAlive(200); }
public void testProductScheduleSprint() throws Exception { ActorInitializer initializer = new ActorInitializer(this.actorRegistry); initializer.putParameter("name", "Test Product"); initializer.putParameter("description", "A decsription."); ActorAgent product = this.actorRegistry.actorFor(Product.class, initializer); product.tell(new ScheduleSprint( "Sprint 1", "The initial sprint.", this.daysFromNow(1), this.daysFromNow(15))); this.stayAlive(); this.actorRegistry.expectedMessages(2); this.actorRegistry.expectedMessage(ScheduleSprint.class); this.actorRegistry.expectedMessage(SprintScheduled.class); }
public void testExecuteCommand() throws Exception { System.out.println("testExecuteCommand()"); ActorAgent agent = actorRegistry.actorFor(TestActor.class); assertNotNull(agent); agent.tell(new TestCommand()); this.stayAlive(500); }
public void testExecuteWhenCommand() throws Exception { System.out.println("testExecuteCommand()"); ActorAgent agent = actorRegistry.actorFor(TestAggregateActor.class); assertNotNull(agent); agent.tell(new TestCommand()); this.stayAlive(100); }
public void testExecuteWhenEvent() throws Exception { System.out.println("testExecuteEvent()"); ActorAgent agent = actorRegistry.actorFor(TestAggregateActor.class); assertNotNull(agent); agent.tell(new TestEvent()); this.stayAlive(200); }
public void testExecuteHowManyAsksIn5Seconds() throws Exception { System.out.println("testExecuteHowManyAsksIn5Seconds()"); this.warmUp(); ActorAgent agent = actorRegistry.actorFor(TestActor.class); assertNotNull(agent); long beforeReceive = new Date().getTime(); FutureCountThread futureCountThread = new FutureCountThread(agent); futureCountThread.start(); this.stayAlive(5000L); futureCountThread.close(); this.stayAlive(1000L); long totalTime = new Date().getTime() - beforeReceive; System.out.println("Total milliseconds: " + totalTime); System.out.println("Ask count: " + futureCountThread.askCount()); System.out.println("Answer count: " + futureCountThread.answerCount()); assertEquals(futureCountThread.askCount(), futureCountThread.answerCount()); }
private void warmUp() { System.out.println("Warming up..."); ActorAgent agent = actorRegistry.actorFor(TestActor.class); FutureCountThread futureCountThread = new FutureCountThread(agent); futureCountThread.start(); this.stayAlive(5000L); futureCountThread.close(); this.stayAlive(100L); } }
public void testExecute15Actors() throws Exception { System.out.println("testExecute15Actors()"); this.warmUp(); final int maxActors = 15; final int millis = 1000; ActorAgent[] agents = new ActorAgent[maxActors]; FutureCountThread[] threads = new FutureCountThread[maxActors]; for (int i = 0; i < maxActors; ++i) { agents[i] = actorRegistry.actorFor(TestActor.class); threads[i] = new FutureCountThread(agents[i]); } long beforeReceive = new Date().getTime(); for (int i = 0; i < maxActors; ++i) { threads[i].start(); } this.stayAlive(millis); for (int i = 0; i < maxActors; ++i) { threads[i].close(); } this.stayAlive(500L); long totalTime = new Date().getTime() - beforeReceive; for (int i = 0; i < maxActors; ++i) { askCounter += threads[i].askCount(); answerCounter += threads[i].answerCount(); } System.out.println("Total milliseconds: " + totalTime); System.out.println("Ask count: " + askCounter + " Average/Second: " + (askCounter / (totalTime / 1000))); System.out.println("Answer count: " + answerCounter + " Average/Second: " + (answerCounter / (totalTime / 1000))); }
public void testExecuteWhenCommandFor5Seconds() throws Exception { System.out.println("testExecuteWhenCommandFor5Seconds()"); ActorAgent agent = actorRegistry.actorFor(TestAggregateActor.class); assertNotNull(agent); RawMessageThoughputCountThread rawMessageThroughput = new RawMessageThoughputCountThread(agent); long beforeReceive = new Date().getTime(); rawMessageThroughput.start(); this.stayAlive(5000L); rawMessageThroughput.close(); this.stayAlive(200L); long totalTime = new Date().getTime() - beforeReceive; System.out.println("Total milliseconds: " + totalTime); System.out.println("Message count: " + rawMessageThroughput.messageCount() + " Average/Second: " + (rawMessageThroughput.messageCount() / (totalTime / 1000))); assertTrue(rawMessageThroughput.messageCount() >= 1000000); }