@Test
public void shouldProvideActualSecondsRemaining() throws Exception {
Node node = session.getRootNode().addNode("test");
node.addMixin("mix:lockable");
session.save();
String path = node.getPath();
int timeout = 4;
JcrLockManager lockManager = session.getWorkspace().getLockManager();
Lock lock = lockManager.lock(node.getPath(), false, false, timeout, null);
assertTrue(node.isLocked());
assertNotEquals(Long.MAX_VALUE, lock.getSecondsRemaining());
assertTrue(lock.getSecondsRemaining() <= timeout);
Thread.sleep(TimeUnit.SECONDS.toMillis(timeout / 2));
assertTrue(lock.getSecondsRemaining() <= timeout / 2);
session.logout();
session = repository.login();
lockManager = session.getWorkspace().getLockManager();
lock = lockManager.getLock(path);
assertTrue(lock.getSecondsRemaining() > 0);
assertNotEquals(Long.MAX_VALUE, lock.getSecondsRemaining());
assertTrue(lock.getSecondsRemaining() <= timeout);
}