@Test public void testSuccessfulPath() { TestableResilientEventHubReceiver receiver = new TestableResilientEventHubReceiver("connectionString", "name", "0", null, -1, null); receiver.receive(5000); receiver.receive(5000); String offset = EventHubMessage.parseAmqpMessage(receiver.receive(5000)).getOffset(); assertEquals("2", offset); }
@Test public void testRecoveryBadDelays() { TestableResilientEventHubReceiver receiver = new TestableResilientEventHubReceiver("connectionString", "name", "0", null, -1, null); receiver.setReceiveDelay(10); receiver.setReceiveNull(true); receiver.receive(5000); // receive null and delay is too short, recover receiver.receive(5000); // receive message 0 String offset = EventHubMessage.parseAmqpMessage(receiver.receive(5000)).getOffset(); assertEquals("1", offset); }
@Test public void testRecovery() { TestableResilientEventHubReceiver receiver = new TestableResilientEventHubReceiver("connectionString", "name", "0", null, -1, null); receiver.setReceiveFaultOffset(1); receiver.receive(5000); // receive message 0 receiver.receive(5000); // receive message 1, fault, then recovered receiver.receive(5000); // receive message 1 String offset = EventHubMessage.parseAmqpMessage(receiver.receive(5000)).getOffset(); assertEquals("2", offset); }