use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class RequestTestCase method requireThatTimeoutCausesCancel.
@Test
public void requireThatTimeoutCausesCancel() {
MyTimer timer = new MyTimer();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(timer);
Request request = newRequest(driver);
request.setTimeout(10, TimeUnit.MILLISECONDS);
assertFalse(request.isCancelled());
timer.currentTime = 10;
assertTrue(request.isCancelled());
request.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class RequestTestCase method requireThatNullTimeoutManagerThrowsException.
@Test
public void requireThatNullTimeoutManagerThrowsException() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
Request request = newRequest(driver);
try {
request.setTimeoutManager(null);
fail();
} catch (NullPointerException e) {
}
request.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class RequestTestCase method requireThatCancelWorks.
@Test
public void requireThatCancelWorks() {
MyTimer timer = new MyTimer();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(timer);
Request request = newRequest(driver);
assertFalse(request.isCancelled());
request.cancel();
assertTrue(request.isCancelled());
request.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class AbstractApplicationTestCase method requireThatTerminationCanBeWaitedForWithoutTimeout.
@Test
public void requireThatTerminationCanBeWaitedForWithoutTimeout() throws InterruptedException {
TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class);
final MyApplication app = (MyApplication) driver.application();
final CountDownLatch latch = new CountDownLatch(1);
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
try {
app.awaitTermination();
} catch (InterruptedException e) {
e.printStackTrace();
}
latch.countDown();
}
});
assertFalse(latch.await(100, TimeUnit.MILLISECONDS));
assertTrue(driver.close());
assertTrue(latch.await(600, TimeUnit.SECONDS));
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class AbstractApplicationTestCase method requireThatTerminationCanBeWaitedForWithTimeout.
@Test
public void requireThatTerminationCanBeWaitedForWithTimeout() throws InterruptedException {
TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class);
final MyApplication app = (MyApplication) driver.application();
final CountDownLatch latch = new CountDownLatch(1);
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
try {
app.awaitTermination(600, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
latch.countDown();
}
});
assertFalse(latch.await(100, TimeUnit.MILLISECONDS));
assertTrue(driver.close());
assertTrue(latch.await(600, TimeUnit.SECONDS));
}
Aggregations