use of org.eclipse.scout.rt.ui.html.res.BinaryResourceHolder in project scout.rt by eclipse.
the class DownloadHandlerStorageTest method testRemove.
@Test
public void testRemove() {
DownloadHandlerStorage storage = new DownloadHandlerStorage() {
@Override
protected long getRemovalTimeoutAfterFirstRequest() {
return 100L;
}
};
BinaryResource res = new BinaryResource("bar.txt", null);
BinaryResourceHolder holder = new BinaryResourceHolder(res);
storage.put(KEY, holder, OpenUriAction.DOWNLOAD);
assertEquals(1, storage.futureMap().size());
BinaryResourceHolderWithAction holderWithAction = storage.get(KEY);
assertEquals(OpenUriAction.DOWNLOAD, holderWithAction.getOpenUriAction());
assertEquals(res, holderWithAction.getHolder().get());
assertEquals("future should still be in futureMap", 1, storage.futureMap().size());
assertEquals(res, holderWithAction.getHolder().get());
SleepUtil.sleepElseLog(150, TimeUnit.MILLISECONDS);
assertEquals("futureMap must be cleared after timeout", 0, storage.futureMap().size());
assertNull(storage.get(KEY));
}
use of org.eclipse.scout.rt.ui.html.res.BinaryResourceHolder in project scout.rt by eclipse.
the class DownloadHandlerStorageTest method testRemove_AfterTimeout.
@Test
public void testRemove_AfterTimeout() {
DownloadHandlerStorage storage = new DownloadHandlerStorage() {
@Override
protected long getTTLForResource(BinaryResource res) {
return 10L;
}
};
BinaryResource res = new BinaryResource("bar.txt", null);
BinaryResourceHolder holder = new BinaryResourceHolder(res);
storage.put(KEY, holder, OpenUriAction.NEW_WINDOW);
SleepUtil.sleepElseLog(100, TimeUnit.MILLISECONDS);
assertNull(storage.get(KEY));
assertEquals("futureMap must be cleared after timeout", 0, storage.futureMap().size());
}
Aggregations