@Override public Statement apply(final Statement base, final Description description) { if (supports(usedMode)) { return new Statement() { @Override public void evaluate() throws Throwable { applyConfig(description); try { base.evaluate(); } finally { closeConfig(); } } }; } else { LOGGER.log(Level.WARNING, "Skip {0} not applicable with socket mode {1}", new Object[] { description, usedMode }); return SKIP; } }
/** * Set delay for processing messages. * * Only used in DIRECT mode. * * @param delayInMillis delay in milliseconds * @return this rule * @throws IllegalArgumentException, if the value is smaller then 0 or * DIRECT is not within the supported modes. */ public NetworkRule setDelay(int delayInMillis) { if (0 > delayInMillis) { throw new IllegalArgumentException("delays must be at least 0, not " + delayInMillis + "!"); } if (!supports(Mode.DIRECT)) { throw new IllegalArgumentException("delays could only be used for DIRECT DatagramSockets!"); } this.delayInMillis = delayInMillis; return this; }