Skip to content

Commit

Permalink
#302 Prepare new testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dvoraka committed Jan 13, 2018
1 parent c796ff7 commit 1aeb7c9
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import dvoraka.avservice.common.helper.replication.ReplicationHelper
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Subject
import spock.util.concurrent.PollingConditions


/**
* DefaultRemoteLock spec.
*/
class DefaultRemoteLockSpec extends Specification implements ReplicationHelper {

@Subject
Expand All @@ -26,11 +25,15 @@ class DefaultRemoteLockSpec extends Specification implements ReplicationHelper {
String testFilename = 'testFilename'
@Shared
String testOwner = 'testOwner'
@Shared
PollingConditions pollingConditions = new PollingConditions(timeout: 3)


def setup() {
serviceClient = Mock()

responseClient = Mock()
responseClient.isRunning() >> true

lock = new DefaultRemoteLock(serviceClient, responseClient, nodeId)
}
Expand All @@ -41,6 +44,10 @@ class DefaultRemoteLockSpec extends Specification implements ReplicationHelper {

then:
1 * responseClient.addNoResponseMessageListener(_)

pollingConditions.eventually {
lock.isRunning()
}
}

def "stop"() {
Expand All @@ -49,6 +56,10 @@ class DefaultRemoteLockSpec extends Specification implements ReplicationHelper {

then:
1 * responseClient.removeNoResponseMessageListener(_)

pollingConditions.eventually {
!lock.isRunning()
}
}

def "lock file unsuccessfully"() {
Expand Down

0 comments on commit 1aeb7c9

Please sign in to comment.