### Question:
GlobalStoreLocker extends StoreLocker { @Override public void checkLock() throws StoreLockException { super.checkLock(); lockedFiles.add( storeLockFile ); } GlobalStoreLocker( FileSystemAbstraction fileSystemAbstraction, StoreLayout storeLayout ); @Override void checkLock();  }### Answer:
@Test public void failToLockSameFolderAcrossIndependentLockers() throws Exception { StoreLayout storeLayout = testDirectory.storeLayout(); try ( GlobalStoreLocker storeLocker = new GlobalStoreLocker( fileSystemRule.get(), storeLayout ) ) { storeLocker.checkLock(); try ( GlobalStoreLocker locker = new GlobalStoreLocker( fileSystemRule.get(), storeLayout ) ) { locker.checkLock(); fail("directory should be locked"); } catch ( StoreLockException expected ) { } try ( GlobalStoreLocker locker = new GlobalStoreLocker( fileSystemRule.get(), storeLayout ) ) { locker.checkLock(); fail("directory should be locked"); } catch ( StoreLockException expected ) { } } }
@Test public void allowToLockSameDirectoryIfItWasUnlocked() throws IOException { StoreLayout storeLayout = testDirectory.storeLayout(); try ( GlobalStoreLocker storeLocker = new GlobalStoreLocker( fileSystemRule.get(), storeLayout ) ) { storeLocker.checkLock(); } try ( GlobalStoreLocker storeLocker = new GlobalStoreLocker( fileSystemRule.get(), storeLayout ) ) { storeLocker.checkLock(); } }
@Test public void allowMultipleCallstoActuallyStoreLocker() throws IOException { StoreLayout storeLayout = testDirectory.storeLayout(); try ( GlobalStoreLocker storeLocker = new GlobalStoreLocker( fileSystemRule.get(), storeLayout ) ) { storeLocker.checkLock(); storeLocker.checkLock(); storeLocker.checkLock(); storeLocker.checkLock(); storeLocker.checkLock(); } }