@@ -19,36 +19,46 @@ GemStoneRepositoryProviderTest >> pickTwoElementsFrom: aQuery [
19
19
]
20
20
21
21
{ #category : ' initialization' }
22
- GemStoneRepositoryProviderTest >> setUpRepositoryWith : aConflictCheckingStrategy [
22
+ GemStoneRepositoryProviderTest >> setUpRepositoryProvidedBy: aGemStoneRepositoryProvider with : aConflictCheckingStrategy [
23
23
24
- extraterrestrials := GemStoneRepositoryProvider new
24
+ extraterrestrials := aGemStoneRepositoryProvider
25
25
createRepositoryStoringObjectsOfType: Extraterrestrial
26
26
checkingConflictsAccordingTo: aConflictCheckingStrategy.
27
27
extraterrestrials configureWith: [ :repository |
28
- repository
29
- indexByEquality: ' firstName' typed: String ;
30
- indexByEquality: ' lastName' typed: String
28
+ repository
29
+ indexByEquality: ' firstName' typed: String ;
30
+ indexByEquality: ' lastName' typed: String
31
31
].
32
32
ships := GemStoneRepositoryProvider new
33
33
createRepositoryStoringObjectsOfType: Spaceship
34
34
checkingConflictsAccordingTo: aConflictCheckingStrategy
35
35
]
36
36
37
+ { #category : ' initialization' }
38
+ GemStoneRepositoryProviderTest >> setUpRepositoryWith: aConflictCheckingStrategy [
39
+
40
+ self setUpRepositoryProvidedBy: GemStoneRepositoryProvider new with: aConflictCheckingStrategy
41
+ ]
42
+
43
+ { #category : ' initialization' }
44
+ GemStoneRepositoryProviderTest >> setUpSemaphorizedRepositoryWaitingOn: aSemaphore [
45
+
46
+ self
47
+ setUpRepositoryProvidedBy: ( SemaphorizedGemStoneRepositoryProvider waitingOn: aSemaphore )
48
+ with: DoNotCheckForConflictsStrategy new
49
+ ]
50
+
37
51
{ #category : ' tests' }
38
52
GemStoneRepositoryProviderTest >> testExceptionsAbortTransactionsUntilHandled [
39
53
40
54
self assert: self extraterrestrials findAll isEmpty.
41
-
42
- self extraterrestrials transact: [
43
- [
55
+ [
44
56
self extraterrestrials store: self silvesterStallone.
45
57
self assertTheOnlyOneInTheRepositoryIsSilvesterStallone.
46
58
1 / 0
47
- ]
48
- on: ZeroDivide
49
- do: [ :ex | ex return ]
50
- ].
51
-
59
+ ]
60
+ on: ZeroDivide
61
+ do: [ :ex | ex return ].
52
62
self assertTheOnlyOneInTheRepositoryIsSilvesterStallone
53
63
]
54
64
@@ -500,6 +510,40 @@ GemStoneRepositoryProviderTest >> testTransactionLevelWithUnhandledException [
500
510
self assert: System transactionLevel equals: baseLevel
501
511
]
502
512
513
+ { #category : ' tests' }
514
+ GemStoneRepositoryProviderTest >> testUpdateWithWhileAbbortTransactionsAreSignaled [
515
+
516
+ | stallone semaphore previous |
517
+
518
+ previous := System transactionMode.
519
+ [
520
+ System transactionMode: #manualBegin .
521
+ semaphore := Semaphore new .
522
+ self setUpSemaphorizedRepositoryWaitingOn: semaphore.
523
+ stallone := self silvesterStallone.
524
+ self extraterrestrials store: stallone.
525
+ self
526
+ assert: self extraterrestrials findAll size equals: 1 ;
527
+ assert: ( self extraterrestrials findAll includes: stallone ).
528
+ [
529
+ self
530
+ updateExtraterrestrialMatching: [ :extraterrestrial | extraterrestrial firstName = ' Silvester' ]
531
+ with: self johnLock
532
+ ] fork.
533
+ Processor yield.
534
+ System inTransaction ifFalse: [ System abortTransaction ].
535
+ semaphore signal .
536
+ Processor yield.
537
+ self assert: self extraterrestrials findAll size equals: 1 .
538
+ self extraterrestrials
539
+ withOneMatching: [ :extraterrestrial | extraterrestrial firstName = ' John' ]
540
+ do: [ :john | self assert: john lastName equals: ' Lock' ]
541
+ else: [ self fail ].
542
+ self assert: ( self extraterrestrials findAllMatching: [ :extraterrestrial |
543
+ extraterrestrial lastName = ' Stallone' ] ) isEmpty
544
+ ] ensure : [ System transactionMode: previous ]
545
+ ]
546
+
503
547
{ #category : ' utility' }
504
548
GemStoneRepositoryProviderTest >> withAllSpaceshipsMatching: aMatchingCriteria do: aOneArgBlock [
505
549
0 commit comments