Skip to content

Commit 7c62f8f

Browse files
authored
Merge pull request #37 from ba-st/36-Dependency-resolution-not-working-correctly-when-hot-swapping-a-system-with-dependents
Reset dependencies cache before resolving all subsystem dependencies.
2 parents fe80525 + 9d1e8b6 commit 7c62f8f

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

source/BaselineOfKepler/BaselineOfKepler.class.st

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ BaselineOfKepler >> baselineKepler: spec [
3535
group: 'Dependent-SUnit-Extensions' with: 'Kepler-SUnit-Model'.
3636

3737
spec
38-
package: 'Kepler-System-Tests' with: [ spec requires: 'Core' ];
38+
package: 'Kepler-System-Tests' with: [ spec requires: #('Core' 'Buoy-SUnit') ];
3939
group: 'Tests' with: 'Kepler-System-Tests';
4040
package: 'Kepler-Time-Tests' with: [ spec requires: 'Kepler-Time' ];
4141
group: 'Tests' with: 'Kepler-Time-Tests';

source/Kepler-System-Tests/CompositeSystemTest.class.st

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ CompositeSystemTest >> testCannotRegisterAnAlreadyStartedSystem [
1717
startUp.
1818

1919
self
20-
assert: (composite >> #CustomerManagementSystem) isStarted;
20+
assert: ( composite >> #CustomerManagementSystem ) isStarted;
2121
should: [ CompositeSystem new register: composite >> #CustomerManagementSystem ]
2222
raise: SystemControlError
23-
withExceptionDo: [ :error | self assert: error messageText equals: 'Cannot register a subsystem not stopped (CMS)' ]
23+
withMessageText: 'Cannot register a subsystem not stopped (CMS)'
2424
]
2525

2626
{ #category : #tests }
@@ -97,7 +97,7 @@ CompositeSystemTest >> testGettingSystemImplementingInterface [
9797
self
9898
should: [ system >> #ProjectManagementSystem ]
9999
raise: SystemControlError
100-
withExceptionDo: [ :error | self assert: error messageText equals: 'System implementing "Project Management" not found.' ]
100+
withMessageText: 'System implementing "Project Management" not found.'
101101
]
102102

103103
{ #category : #tests }
@@ -182,7 +182,7 @@ CompositeSystemTest >> testSendingMessagesToSystemWithUnresolvedSystemDependency
182182
self
183183
should: [ system >> #ProjectManagementSystem addProjectNamed: 'Fail' for: 'Pedro' ]
184184
raise: SystemControlError
185-
withExceptionDo: [ :error | self assert: error messageText equals: 'Unresolved system dependency to "Customer Querying"' ]
185+
withMessageText: 'Unresolved system dependency to "Customer Querying"'
186186
]
187187

188188
{ #category : #tests }
@@ -219,7 +219,7 @@ CompositeSystemTest >> testSystemMissingDependenciesWillNotStart [
219219
self
220220
should: [ composite startUp ]
221221
raise: SystemControlError
222-
withExceptionDo: [ :error | self assert: error messageText equals: 'System implementing "Customer Querying" not found.' ]
222+
withMessageText: 'System implementing "Customer Querying" not found.'
223223
]
224224

225225
{ #category : #tests }
@@ -253,5 +253,5 @@ CompositeSystemTest >> testWontStartWhenRequiredSystemNotFound [
253253
self
254254
should: [ system startUp ]
255255
raise: SystemControlError
256-
withExceptionDo: [ :error | self assert: error messageText equals: 'System implementing "Customer Querying" not found.' ]
256+
withMessageText: 'System implementing "Customer Querying" not found.'
257257
]

source/Kepler-System-Tests/SystemHotSwapperTest.class.st

+30-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SystemHotSwapperTest >> testCantSwapWhenTheInterfaceIsNotImplemented [
2323
self
2424
should: [ (SystemHotSwapper swapSystemImplementing: #CustomerManagementSystem with: newCMS) applyTo: composite ]
2525
raise: SystemControlError
26-
withExceptionDo: [ :error | self assert: error messageText equals: 'CMS is not implementing Customer Management' ]
26+
withMessageText: 'CMS is not implementing Customer Management'
2727
]
2828

2929
{ #category : #tests }
@@ -53,3 +53,32 @@ SystemHotSwapperTest >> testSwapping [
5353
assert: composite >> #CustomerQueryingSystem equals: newCMS;
5454
assert: (composite >> #CustomerQueryingSystem) customers size equals: 2
5555
]
56+
57+
{ #category : #tests }
58+
SystemHotSwapperTest >> testSwappingSystemWithDependents [
59+
60+
| composite cms newCMS pms |
61+
62+
cms := SampleCustomerSystem new.
63+
pms := SampleProjectSystem new.
64+
composite := CompositeSystem new
65+
register: cms;
66+
register: pms;
67+
yourself.
68+
composite startUp.
69+
70+
newCMS := FixedCustomerSystem new.
71+
72+
self deny: cms = newCMS.
73+
74+
self
75+
assert: composite >> #CustomerQueryingSystem equals: cms;
76+
assert: pms >> #CustomerQueryingSystem equals: cms.
77+
78+
( SystemHotSwapper swapSystemImplementing: #CustomerQueryingSystem with: newCMS )
79+
applyTo: composite.
80+
81+
self
82+
assert: composite >> #CustomerQueryingSystem equals: newCMS;
83+
assert: pms >> #CustomerQueryingSystem equals: newCMS
84+
]

source/Kepler-System/SubsystemImplementation.class.st

+3-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ SubsystemImplementation >> resetDependencies [
9393
{ #category : #installing }
9494
SubsystemImplementation >> resolveDependencies [
9595

96-
self dependencies do: [ :interfaceKey | dependencies bind: interfaceKey to: self parent >> interfaceKey ]
96+
self resetDependencies.
97+
self dependencies
98+
do: [ :interfaceKey | dependencies bind: interfaceKey to: self parent >> interfaceKey ]
9799
]
98100

99101
{ #category : #'private - controlling' }

0 commit comments

Comments
 (0)