Package com.coditory.sherlock
Class RxSherlockStub
- java.lang.Object
-
- com.coditory.sherlock.RxSherlockStub
-
- All Implemented Interfaces:
RxSherlock
public final class RxSherlockStub extends java.lang.Object implements RxSherlock
Use to stubRxSherlockin tests.
-
-
Constructor Summary
Constructors Constructor Description RxSherlockStub()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>createLock()Creates a distributed lock.com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>createOverridingLock()Create a distributed overriding lock.com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock>createReentrantLock()Creates a distributed reentrant lock.io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult>forceReleaseAllLocks()Force releases all acquired locks.io.reactivex.Single<com.coditory.sherlock.connector.InitializationResult>initialize()Initializes underlying infrastructure.static RxSherlockStubwithAcquiredLocks()Make the stub produce acquired locks by defaultRxSherlockStubwithLock(RxDistributedLock lock)Make the stub produce return a predefined lock.static RxSherlockStubwithReleasedLocks()Make the stub produce released locks by default-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.coditory.sherlock.RxSherlock
createLock, createOverridingLock, createReentrantLock, forceReleaseLock
-
-
-
-
Method Detail
-
withReleasedLocks
public static RxSherlockStub withReleasedLocks()
Make the stub produce released locks by default- Returns:
- the instance
-
withAcquiredLocks
public static RxSherlockStub withAcquiredLocks()
Make the stub produce acquired locks by default- Returns:
- the instance
-
withLock
public RxSherlockStub withLock(RxDistributedLock lock)
Make the stub produce return a predefined lock.- Parameters:
lock- returned when creating a lock with the same id- Returns:
- the instance
-
initialize
public io.reactivex.Single<com.coditory.sherlock.connector.InitializationResult> initialize()
Description copied from interface:RxSherlockInitializes underlying infrastructure. If this method is not invoked explicitly then it can be invoked implicitly when acquiring or releasing a lock for the first time.Most often initialization is related with creating indexes and tables.
- Specified by:
initializein interfaceRxSherlock- Returns:
InitializationResult.SUCCESSif initialization was successful, otherwiseInitializationResult.FAILUREis returned
-
createLock
public com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock> createLock()
Description copied from interface:RxSherlockCreates a distributed lock. Created lock may be acquired only once by the same owner:assert lock.acquire() == true assert lock.acquire() == false- Specified by:
createLockin interfaceRxSherlock- Returns:
- the lock builder
-
createReentrantLock
public com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock> createReentrantLock()
Description copied from interface:RxSherlockCreates a distributed reentrant lock. Reentrant lock may be acquired multiple times by the same owner:assert reentrantLock.acquire() == true assert reentrantLock.acquire() == true- Specified by:
createReentrantLockin interfaceRxSherlock- Returns:
- the reentrant lock builder
-
createOverridingLock
public com.coditory.sherlock.DistributedLockBuilder<RxDistributedLock> createOverridingLock()
Description copied from interface:RxSherlockCreate a distributed overriding lock. Returned lock may acquire or release any other lock without checking its state:assert someLock.acquire() == true assert overridingLock.acquire() == trueIt could be used for administrative actions.
- Specified by:
createOverridingLockin interfaceRxSherlock- Returns:
- the overriding lock builder
-
forceReleaseAllLocks
public io.reactivex.Single<com.coditory.sherlock.connector.ReleaseResult> forceReleaseAllLocks()
Description copied from interface:RxSherlockForce releases all acquired locks.It could be used for administrative actions.
- Specified by:
forceReleaseAllLocksin interfaceRxSherlock- Returns:
ReleaseResult.SUCCESSif lock was released, otherwiseReleaseResult.FAILUREis returned
-
-