@Test public void testWaitUntilStartTimeThrowsNumberFormatException() throws Throwable { DailyTaskAdaptor dailyTaskAdaptor = new DailyTaskAdaptor(); Configuration cfg = new SimpleConfiguration(); dailyTaskAdaptor.setConfiguration(cfg); try { dailyTaskAdaptor.waitUntilStartTime(); fail("Expected NumberFormatException to be thrown"); } catch (NumberFormatException ex) { assertEquals("For input string: \":0\"", ex.getMessage(), "ex.getMessage()"); assertSame(cfg, dailyTaskAdaptor.getConfiguration(), "dailyTaskAdaptor.getConfiguration()"); } }
protected void waitUntilStartTime() { Date when = getWhen(); while (running()) { Date now = new GregorianCalendar().getTime(); if (now.before (when)) { long sleepTime = when.getTime() - now.getTime(); if (sleepTime <= 0) { ISOUtil.sleep(1000); continue; } getLog().info ("sleeping", sleepTime/1000 + " secs until " + when.toString() ); try { Thread.sleep (sleepTime); } catch (InterruptedException e) { when = getWhen(); } } else break; } }
DailyTaskAdaptor extends QBeanSupport implements Runnable { protected void waitUntilStartTime() { Date when = getWhen(); while (running()) { Date now = new GregorianCalendar().getTime(); if (now.before (when)) { long sleepTime = when.getTime() - now.getTime(); if (sleepTime <= 0) { ISOUtil.sleep(1000); continue; } getLog().info ("sleeping", sleepTime/1000 + " secs until " + when.toString() ); try { Thread.sleep (sleepTime); } catch (InterruptedException e) { when = getWhen(); } } else break; } } }
DailyTaskAdaptor extends QBeanSupport implements Runnable { protected void waitUntilStartTime() { Date when = getWhen(); while (running()) { Date now = new GregorianCalendar().getTime(); if (now.before (when)) { long sleepTime = when.getTime() - now.getTime(); if (sleepTime <= 0) { ISOUtil.sleep(1000); continue; } getLog().info ("sleeping", sleepTime/1000 + " secs until " + when.toString() ); try { Thread.sleep (sleepTime); } catch (InterruptedException e) { when = getWhen(); } } else break; } } DailyTaskAdaptor(); }
DailyTaskAdaptor extends QBeanSupport implements Runnable { protected void waitUntilStartTime() { Date when = getWhen(); while (running()) { Date now = new GregorianCalendar().getTime(); if (now.before (when)) { long sleepTime = when.getTime() - now.getTime(); if (sleepTime <= 0) { ISOUtil.sleep(1000); continue; } getLog().info ("sleeping", sleepTime/1000 + " secs until " + when.toString() ); try { Thread.sleep (sleepTime); } catch (InterruptedException e) { when = getWhen(); } } else break; } } DailyTaskAdaptor(); void run(); Date getWhen(); }
DailyTaskAdaptor extends QBeanSupport implements Runnable { protected void waitUntilStartTime() { Date when = getWhen(); while (running()) { Date now = new GregorianCalendar().getTime(); if (now.before (when)) { long sleepTime = when.getTime() - now.getTime(); if (sleepTime <= 0) { ISOUtil.sleep(1000); continue; } getLog().info ("sleeping", sleepTime/1000 + " secs until " + when.toString() ); try { Thread.sleep (sleepTime); } catch (InterruptedException e) { when = getWhen(); } } else break; } } DailyTaskAdaptor(); void run(); Date getWhen();  }