/** * Receive one message from the test actor and assert that it conforms to the * given class. Wait time is bounded by the given duration, with an * AssertionFailure being thrown in case of timeout. * * @return the received object */ public <T> T expectMsgClass(FiniteDuration max, Class<T> clazz) { return p.expectMsgClass(max, clazz); }
/** * Same as <code>expectMsgClass(remainingOrDefault(), clazz)</code>, but correctly treating the * timeFactor. */ public <T> T expectMsgClass(Class<T> clazz) { return p.expectMsgClass(clazz); }
/** * Receive one message from the test actor and assert that it conforms to the given class. Wait * time is bounded by the given duration, with an AssertionFailure being thrown in case of * timeout. * * @return the received object */ public <T> T expectMsgClass(FiniteDuration max, Class<T> clazz) { return p.expectMsgClass(max, clazz); }
/** * Receive one message from the test actor and assert that it conforms to the given class. Wait * time is bounded by the given duration, with an AssertionFailure being thrown in case of * timeout. * * @return the received object */ public <T> T expectMsgClass(FiniteDuration max, Class<T> clazz) { return p.expectMsgClass(max, clazz); }
/** * Same as <code>expectMsgClass(remaining(), clazz)</code>, but correctly * treating the timeFactor. */ public <T> T expectMsgClass(Class<T> clazz) { return p.expectMsgClass(clazz); }
/** * Same as <code>expectMsgClass(remainingOrDefault(), clazz)</code>, but correctly treating the * timeFactor. */ public <T> T expectMsgClass(Class<T> clazz) { return p.expectMsgClass(clazz); }
/** * Receive one message from the test actor and assert that it conforms to the * given class. Wait time is bounded by the given duration, with an * AssertionFailure being thrown in case of timeout. * * @return the received object */ public <T> T expectMsgClass(FiniteDuration max, Class<T> clazz) { return p.expectMsgClass(max, clazz); }
/** * Same as <code>expectMsgClass(remaining(), clazz)</code>, but correctly * treating the timeFactor. */ public <T> T expectMsgClass(Class<T> clazz) { return p.expectMsgClass(clazz); }
/** * Same as <code>expectMsgClass(remaining(), clazz)</code>, but correctly * treating the timeFactor. */ public <T> T expectMsgClass(Class<T> clazz) { return p.expectMsgClass(clazz); }
/** * Receive one message from the test actor and assert that it conforms to the * given class. Wait time is bounded by the given duration, with an * AssertionFailure being thrown in case of timeout. * * @return the received object */ public <T> T expectMsgClass(FiniteDuration max, Class<T> clazz) { return p.expectMsgClass(max, clazz); }
/** * Same as <code>expectMsgClass(remaining(), clazz)</code>, but correctly * treating the timeFactor. */ public <T> T expectMsgClass(Class<T> clazz) { return p.expectMsgClass(clazz); }
/** * Same as <code>expectMsgClass(remaining(), clazz)</code>, but correctly * treating the timeFactor. */ public <T> T expectMsgClass(Class<T> clazz) { return p.expectMsgClass(clazz); }
private MockedSnapshotStore.SaveRequest handleRecovery(final SelectedSnapshot savedState) { probe.expectMsgClass(MockedSnapshotStore.LoadRequest.class); //offer snapshot probe.reply(Optional.ofNullable(savedState)); final MockedSnapshotStore.SaveRequest nextSaveRequest = probe.expectMsgClass(MockedSnapshotStore.SaveRequest.class); probe.reply(Void.TYPE); //check old snapshots deleted probe.expectMsgClass(MockedSnapshotStore.DeleteByCriteriaRequest.class); probe.reply(Void.TYPE); return nextSaveRequest; }
@Test public void testRecoveryAfterRestartSaveSnapshotFail() { system.stop(mockedActor); mockedActor = system.actorOf(MockedActor.props(id, initialBehavior)); probe.watch(mockedActor); probe.expectMsgClass(MockedSnapshotStore.LoadRequest.class); probe.reply(Optional.empty()); probe.expectMsgClass(MockedSnapshotStore.SaveRequest.class); probe.reply(new RuntimeException("save failed")); probe.expectMsgClass(MockedSnapshotStore.DeleteByMetadataRequest.class); probe.expectTerminated(mockedActor, TIMEOUT); }
private void registerListeners() { for (final TestProbe listener : listeners) { notifier.tell(new RegisterRoleChangeListener(), listener.ref()); listener.expectMsgClass(RegisterRoleChangeListenerReply.class); } }
@Test public void testSendRequestReceiveResponse() { final Consumer<Response<?, ?>> callback = mock(Consumer.class); final Request<?, ?> request = createRequest(replyToProbe.ref()); connection.sendRequest(request, callback); final RequestEnvelope requestEnvelope = backendProbe.expectMsgClass(RequestEnvelope.class); Assert.assertEquals(request, requestEnvelope.getMessage()); final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(CLIENT_ID, 0L); final RequestSuccess<?, ?> message = new TransactionAbortSuccess(new TransactionIdentifier(historyId, 0L), 0L); final ResponseEnvelope<?> envelope = new SuccessEnvelope(message, 0L, 0L, 0L); connection.receiveResponse(envelope); verify(callback, timeout(1000)).accept(isA(TransactionAbortSuccess.class)); }
@Test public void testMessageSliceReplyWithNoState() { try (MessageSlicer slicer = newMessageSlicer("testMessageSliceReplyWithNoState", 1000)) { MessageSliceIdentifier messageSliceId = new MessageSliceIdentifier(IDENTIFIER, slicer.getId()); slicer.handleMessage(MessageSliceReply.success(messageSliceId, 1, testProbe.ref())); final AbortSlicing abortSlicing = testProbe.expectMsgClass(AbortSlicing.class); assertEquals("Identifier", messageSliceId, abortSlicing.getIdentifier()); } }
@Test public void testEnqueueCanTransmit() { final Request<?, ?> request = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 0L, probe.ref()); final Consumer<Response<?, ?>> callback = createConsumerMock(); final long now = now(); queue.enqueueOrForward(new ConnectionEntry(request, callback, now), now); final RequestEnvelope requestEnvelope = probe.expectMsgClass(RequestEnvelope.class); assertEquals(request, requestEnvelope.getMessage()); }
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()); } }
@Test public void testFirstMessageSliceWithInvalidIndex() { try (MessageAssembler assembler = newMessageAssembler("testFirstMessageSliceWithInvalidIndex")) { final MessageSliceIdentifier identifier = new MessageSliceIdentifier(IDENTIFIER, 1); final MessageSlice messageSlice = new MessageSlice(identifier, new byte[0], 2, 3, 1, testProbe.ref()); assembler.handleMessage(messageSlice, testProbe.ref()); final MessageSliceReply reply = testProbe.expectMsgClass(MessageSliceReply.class); assertFailedMessageSliceReply(reply, IDENTIFIER, true); assertFalse("MessageAssembler should not have state for " + identifier, assembler.hasState(identifier)); } }