|
@@ -16,12 +16,27 @@ ZnockClient class >> newWithInterceptor: aZnock [
|
|
|
|
|
|
{ #category : #'private protocol' }
|
|
{ #category : #'private protocol' }
|
|
ZnockClient >> executeRequestResponse [
|
|
ZnockClient >> executeRequestResponse [
|
|
- ^ (interceptor consumeExpectationFor: self)
|
|
|
|
- ifNotNil: [ :expectation |
|
|
|
|
- response := expectation response.
|
|
|
|
- (response respondsTo: #signal) ifTrue: [ response signal ].
|
|
|
|
- response contents ]
|
|
|
|
- ifNil: [ super executeRequestResponse ]
|
|
|
|
|
|
+ | expectation |
|
|
|
|
+ expectation := interceptor consumeExpectationFor: self.
|
|
|
|
+ expectation ifNil: [ ^ super executeRequestResponse ].
|
|
|
|
+ expectation delay ifNotNil: [ :delay | self fakeDelay: delay ].
|
|
|
|
+ self fakeResponse: expectation response.
|
|
|
|
+ ^ response contents
|
|
|
|
+]
|
|
|
|
+
|
|
|
|
+{ #category : #'private protocol' }
|
|
|
|
+ZnockClient >> fakeDelay: aDuration [
|
|
|
|
+ | localTimeout |
|
|
|
|
+ localTimeout := self timeout seconds.
|
|
|
|
+ localTimeout <= aDuration
|
|
|
|
+ ifTrue: [ localTimeout asDelay wait. ConnectionTimedOut signal: 'Znock timeout' ]
|
|
|
|
+ ifFalse: [ aDuration asDelay wait ]
|
|
|
|
+]
|
|
|
|
+
|
|
|
|
+{ #category : #'private protocol' }
|
|
|
|
+ZnockClient >> fakeResponse: aZnResponse [
|
|
|
|
+ response := aZnResponse.
|
|
|
|
+ (response respondsTo: #signal) ifTrue: [ response signal ]
|
|
]
|
|
]
|
|
|
|
|
|
{ #category : #accessing }
|
|
{ #category : #accessing }
|