@Test public void testDoServiceWithInterruption_Exception() throws Exception { final WaitService srv = LifecycleHelper.initAndStart(new WaitService(new TimeInterval(10L, TimeUnit.SECONDS))); Thread t = new Thread(new Runnable() { @Override public void run() { try { srv.doService(AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello")); fail(); } catch (ServiceException e) { } } }); t.start(); t.interrupt(); }
@Override public void doService(AdaptrisMessage msg) throws ServiceException { try { long waitMs = waitMs(); log.trace("Waiting for [{}] ms; waking up at approx. {}", waitMs, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis() + waitMs))); Thread.sleep(waitMs); } catch (InterruptedException e) { handleInterrupt(e); } }
WaitService extends ServiceImp { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { long waitMs = waitMs(); log.trace("Waiting for [{}] ms; waking up at approx. {}", waitMs, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis() + waitMs))); Thread.sleep(waitMs); } catch (InterruptedException e) { handleInterrupt(e); } } }
WaitService extends ServiceImp { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { long waitMs = waitMs(); log.trace("Waiting for [{}] ms; waking up at approx. {}", waitMs, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis() + waitMs))); Thread.sleep(waitMs); } catch (InterruptedException e) { handleInterrupt(e); } } WaitService();  WaitService(TimeInterval wait);  WaitService(TimeInterval wait, Boolean randomize);  WaitService(String uniqueId); }
WaitService extends ServiceImp { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { long waitMs = waitMs(); log.trace("Waiting for [{}] ms; waking up at approx. {}", waitMs, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis() + waitMs))); Thread.sleep(waitMs); } catch (InterruptedException e) { handleInterrupt(e); } } WaitService();  WaitService(TimeInterval wait);  WaitService(TimeInterval wait, Boolean randomize);  WaitService(String uniqueId); @Override void doService(AdaptrisMessage msg); TimeInterval getWaitInterval(); void setWaitInterval(TimeInterval interval); @Override void prepare(); Boolean getRandomize(); void setRandomize(Boolean b); Boolean getExceptionOnInterrupt(); void setExceptionOnInterrupt(Boolean b); }
WaitService extends ServiceImp { @Override public void doService(AdaptrisMessage msg) throws ServiceException { try { long waitMs = waitMs(); log.trace("Waiting for [{}] ms; waking up at approx. {}", waitMs, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis() + waitMs))); Thread.sleep(waitMs); } catch (InterruptedException e) { handleInterrupt(e); } } WaitService();  WaitService(TimeInterval wait);  WaitService(TimeInterval wait, Boolean randomize);  WaitService(String uniqueId); @Override void doService(AdaptrisMessage msg); TimeInterval getWaitInterval(); void setWaitInterval(TimeInterval interval); @Override void prepare(); Boolean getRandomize(); void setRandomize(Boolean b); Boolean getExceptionOnInterrupt(); void setExceptionOnInterrupt(Boolean b);  }