@Test public void sendT03Packet() { final Map<String, String> customSettings = Maps.newHashMap(); customSettings.put(SIMULATED_REJECT_ERROR_CODE, InterledgerErrorCode.T03_CONNECTOR_BUSY_CODE); this.link = new LoopbackLink( () -> OPERATOR_ADDRESS, LinkSettings.builder().linkType(LoopbackLink.LINK_TYPE).customSettings(customSettings).build(), packetRejector ); link.setLinkId(LinkId.of("foo")); link.sleepAndReject(preparePacket(), 1).handle( fulfillPacket -> { logger.error("interledgerRejectPacket={}", fulfillPacket); fail("Expected a Reject"); }, rejectPacket -> assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.T03_CONNECTOR_BUSY) ); }
@VisibleForTesting InterledgerResponsePacket sleepAndReject(InterledgerPreparePacket preparePacket, int sleepDuraction) { try { Thread.sleep(sleepDuraction); } catch (InterruptedException e) { throw new RuntimeException(e); } return packetRejector.reject(this.getLinkId(), preparePacket, InterledgerErrorCode.T03_CONNECTOR_BUSY, "Loopback set to exceed timeout via simulate_timeout=T03"); }
LoopbackLink extends AbstractLink<LinkSettings> implements Link<LinkSettings> { @VisibleForTesting InterledgerResponsePacket sleepAndReject(InterledgerPreparePacket preparePacket, int sleepDuraction) { try { Thread.sleep(sleepDuraction); } catch (InterruptedException e) { throw new RuntimeException(e); } return packetRejector.reject(this.getLinkId(), preparePacket, InterledgerErrorCode.T03_CONNECTOR_BUSY, "Loopback set to exceed timeout via simulate_timeout=T03"); } }
LoopbackLink extends AbstractLink<LinkSettings> implements Link<LinkSettings> { @VisibleForTesting InterledgerResponsePacket sleepAndReject(InterledgerPreparePacket preparePacket, int sleepDuraction) { try { Thread.sleep(sleepDuraction); } catch (InterruptedException e) { throw new RuntimeException(e); } return packetRejector.reject(this.getLinkId(), preparePacket, InterledgerErrorCode.T03_CONNECTOR_BUSY, "Loopback set to exceed timeout via simulate_timeout=T03"); } LoopbackLink(
      final Supplier<InterledgerAddress> operatorAddressSupplier,
      final LinkSettings linkSettings,
      final PacketRejector packetRejector
  ); }
LoopbackLink extends AbstractLink<LinkSettings> implements Link<LinkSettings> { @VisibleForTesting InterledgerResponsePacket sleepAndReject(InterledgerPreparePacket preparePacket, int sleepDuraction) { try { Thread.sleep(sleepDuraction); } catch (InterruptedException e) { throw new RuntimeException(e); } return packetRejector.reject(this.getLinkId(), preparePacket, InterledgerErrorCode.T03_CONNECTOR_BUSY, "Loopback set to exceed timeout via simulate_timeout=T03"); } LoopbackLink(
      final Supplier<InterledgerAddress> operatorAddressSupplier,
      final LinkSettings linkSettings,
      final PacketRejector packetRejector
  ); @Override void registerLinkHandler(LinkHandler ilpDataHandler); @Override InterledgerResponsePacket sendPacket(final InterledgerPreparePacket preparePacket); @Override String toString(); }
LoopbackLink extends AbstractLink<LinkSettings> implements Link<LinkSettings> { @VisibleForTesting InterledgerResponsePacket sleepAndReject(InterledgerPreparePacket preparePacket, int sleepDuraction) { try { Thread.sleep(sleepDuraction); } catch (InterruptedException e) { throw new RuntimeException(e); } return packetRejector.reject(this.getLinkId(), preparePacket, InterledgerErrorCode.T03_CONNECTOR_BUSY, "Loopback set to exceed timeout via simulate_timeout=T03"); } LoopbackLink(
      final Supplier<InterledgerAddress> operatorAddressSupplier,
      final LinkSettings linkSettings,
      final PacketRejector packetRejector
  ); @Override void registerLinkHandler(LinkHandler ilpDataHandler); @Override InterledgerResponsePacket sendPacket(final InterledgerPreparePacket preparePacket); @Override String toString(); static final String LINK_TYPE_STRING; static final LinkType LINK_TYPE; static final InterledgerFulfillment LOOPBACK_FULFILLMENT; static final String SIMULATED_REJECT_ERROR_CODE; }