QosLink implements Link { public long sendNoTone(AnalogPin analogPin) throws IOException { return extractId(newAwaiter().waitForResponse( delegate.sendNoTone(analogPin))); } QosLink(Link link);  QosLink(Link link, long timeout, TimeUnit timeUnit); void close(); Link addListener(EventListener listener); Link removeListener(EventListener listener); Link addRplyListener(RplyListener listener); Link removeRplyListener(RplyListener listener); Link addCustomListener(CustomListener listener); Link removeCustomListener(CustomListener listener); long startListening(Pin pin); long stopListening(Pin pin); long switchAnalogPin(AnalogPin analogPin, int value); long switchDigitalPin(DigitalPin digitalPin, boolean value); long sendKeyPressEvent(char keychar, int keycode, int keylocation,
			int keymodifiers, int keymodifiersex); long sendTone(Tone tone); long sendNoTone(AnalogPin analogPin); long sendCustomMessage(String... messages); @Deprecated // quick fix for https://github.com/Ardulink/Ardulink-2/issues/43 Link getDelegate();  }
@Test public void canDoGuranteedDelivery() throws Exception { arduino.whenReceive(regex("alp:\\/\\/notn\\/3\\?id\\=(\\d)")) .thenRespond("alp: qosLink = newQosLink(connectionTo(arduino), 15, MINUTES); qosLink.sendNoTone(analogPin(3)); }
@Test public void doesThrowExceptionIfNotResponseReceivedWithinHalfAsecond() throws Exception { arduino.whenReceive(regex("alp:\\/\\/notn\\/3\\?id\\=(\\d)")) .thenDoNotRespond(); qosLink = newQosLink(connectionTo(arduino), 500, MILLISECONDS); exceptions.expect(IllegalStateException.class); exceptions.expectMessage(allOf(containsString("response"), containsString("500 MILLISECONDS"))); qosLink.sendNoTone(analogPin(3)); }
@Test public void doesThrowExceptionIfKoResponse() throws Exception { arduino.whenReceive(regex("alp:\\/\\/notn\\/3\\?id\\=(\\d)")) .thenRespond("alp: Connection connection = connectionTo(arduino); qosLink = newQosLink(connection, 500 + someMillisMore(), MILLISECONDS); exceptions.expect(IllegalStateException.class); exceptions.expectMessage(allOf(containsString("status"), containsString("not ok"))); qosLink.sendNoTone(analogPin(3)); }