@Test public void testConstructorWithoutV8() { ConcurrentV8 concurrentV8 = new ConcurrentV8(); assertNotNull(concurrentV8.getV8()); concurrentV8.release(); }
@Test public void testLockNotAquiredAfterCreation() { ConcurrentV8 concurrentV8 = new ConcurrentV8(); assertFalse(concurrentV8.getV8().getLocker().hasLock()); concurrentV8.release(); }
@Test public void testLockNotAcquiredAfterExecution() { ConcurrentV8 concurrentV8 = new ConcurrentV8(); concurrentV8.run(new V8Runnable() { @Override public void run(final V8 runtime) { runtime.executeScript("foo = 7;"); } }); assertFalse(concurrentV8.getV8().getLocker().hasLock()); concurrentV8.release(); }
@Test public void testLockNotAquiredAfterException() { ConcurrentV8 concurrentV8 = new ConcurrentV8(); try { concurrentV8.run(new V8Runnable() { @Override public void run(final V8 runtime) { runtime.executeScript("throw 'my exception';"); } }); } catch (Exception e) { // do nothing } assertFalse(concurrentV8.getV8().getLocker().hasLock()); concurrentV8.release(); }