OdsFileWriterAdapter implements NamedOdsFileWriter { public synchronized void waitForData() { while (this.flushers.isEmpty() && this.isNotStopped()) { try { this.wait(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } } OdsFileWriterAdapter(final Logger logger, final NamedOdsFileWriter adaptee,
                         final Queue<OdsAsyncFlusher> flushers); static OdsFileWriterAdapter create(final Logger logger,
                                              final NamedOdsFileWriter adaptee); @Override void close(); @Override NamedOdsDocument document(); @Override synchronized void save(); @Override synchronized void update(final OdsAsyncFlusher flusher); synchronized void flushAdaptee(); synchronized boolean isNotStopped(); synchronized void waitForData();  }
@Test public void testInterruptAdapterInWait() throws Exception { final OdsFileWriterAdapter wal = this.wa; final Thread t = new Thread() { @Override public void run() { try { PowerMock.resetAll(); PowerMock.replayAll(); wal.waitForData(); PowerMock.verifyAll(); } catch (final RuntimeException e) { return; } Assert.fail(); } }; t.start(); Thread.sleep(100); t.interrupt(); t.join(); }
@Test public void testWaitForData() { this.flushers.add(this.f); PowerMock.resetAll(); PowerMock.replayAll(); this.wa.waitForData(); PowerMock.verifyAll(); }