LockService extends AbstractLockService<Token, TokenReadWriteLock> { public WriteLock getWriteLock(Object... objects) { return getWriteLock(Token.wrap(objects)); } private  LockService(); private  LockService(ConcurrentHashMap<Token, TokenReadWriteLock> locks); static LockService create(); static LockService noOp(); ReadLock getReadLock(Object... objects); WriteLock getWriteLock(Object... objects);  }
@Test public void testExclusiveWriteLockForUpgradedToken() throws InterruptedException { Token token = Token.wrap(TestData.getLong()); token.upgrade(); final WriteLock write2 = lockService.getWriteLock(token); write2.lock(); Thread b = new Thread(new Runnable() { @Override public void run() { Assert.assertFalse(write2.tryLock()); } }); b.start(); b.join(); }