Skip to content

Commit

Permalink
Merge pull request #37 from ba-st/36-Dependency-resolution-not-workin…
Browse files Browse the repository at this point in the history
…g-correctly-when-hot-swapping-a-system-with-dependents

Reset dependencies cache before resolving all subsystem dependencies.
  • Loading branch information
gcotelli authored Sep 3, 2019
2 parents fe80525 + 9d1e8b6 commit 7c62f8f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion source/BaselineOfKepler/BaselineOfKepler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ BaselineOfKepler >> baselineKepler: spec [
group: 'Dependent-SUnit-Extensions' with: 'Kepler-SUnit-Model'.

spec
package: 'Kepler-System-Tests' with: [ spec requires: 'Core' ];
package: 'Kepler-System-Tests' with: [ spec requires: #('Core' 'Buoy-SUnit') ];
group: 'Tests' with: 'Kepler-System-Tests';
package: 'Kepler-Time-Tests' with: [ spec requires: 'Kepler-Time' ];
group: 'Tests' with: 'Kepler-Time-Tests';
Expand Down
12 changes: 6 additions & 6 deletions source/Kepler-System-Tests/CompositeSystemTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ CompositeSystemTest >> testCannotRegisterAnAlreadyStartedSystem [
startUp.

self
assert: (composite >> #CustomerManagementSystem) isStarted;
assert: ( composite >> #CustomerManagementSystem ) isStarted;
should: [ CompositeSystem new register: composite >> #CustomerManagementSystem ]
raise: SystemControlError
withExceptionDo: [ :error | self assert: error messageText equals: 'Cannot register a subsystem not stopped (CMS)' ]
withMessageText: 'Cannot register a subsystem not stopped (CMS)'
]

{ #category : #tests }
Expand Down Expand Up @@ -97,7 +97,7 @@ CompositeSystemTest >> testGettingSystemImplementingInterface [
self
should: [ system >> #ProjectManagementSystem ]
raise: SystemControlError
withExceptionDo: [ :error | self assert: error messageText equals: 'System implementing "Project Management" not found.' ]
withMessageText: 'System implementing "Project Management" not found.'
]

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

{ #category : #tests }
Expand Down Expand Up @@ -219,7 +219,7 @@ CompositeSystemTest >> testSystemMissingDependenciesWillNotStart [
self
should: [ composite startUp ]
raise: SystemControlError
withExceptionDo: [ :error | self assert: error messageText equals: 'System implementing "Customer Querying" not found.' ]
withMessageText: 'System implementing "Customer Querying" not found.'
]

{ #category : #tests }
Expand Down Expand Up @@ -253,5 +253,5 @@ CompositeSystemTest >> testWontStartWhenRequiredSystemNotFound [
self
should: [ system startUp ]
raise: SystemControlError
withExceptionDo: [ :error | self assert: error messageText equals: 'System implementing "Customer Querying" not found.' ]
withMessageText: 'System implementing "Customer Querying" not found.'
]
31 changes: 30 additions & 1 deletion source/Kepler-System-Tests/SystemHotSwapperTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SystemHotSwapperTest >> testCantSwapWhenTheInterfaceIsNotImplemented [
self
should: [ (SystemHotSwapper swapSystemImplementing: #CustomerManagementSystem with: newCMS) applyTo: composite ]
raise: SystemControlError
withExceptionDo: [ :error | self assert: error messageText equals: 'CMS is not implementing Customer Management' ]
withMessageText: 'CMS is not implementing Customer Management'
]

{ #category : #tests }
Expand Down Expand Up @@ -53,3 +53,32 @@ SystemHotSwapperTest >> testSwapping [
assert: composite >> #CustomerQueryingSystem equals: newCMS;
assert: (composite >> #CustomerQueryingSystem) customers size equals: 2
]

{ #category : #tests }
SystemHotSwapperTest >> testSwappingSystemWithDependents [

| composite cms newCMS pms |

cms := SampleCustomerSystem new.
pms := SampleProjectSystem new.
composite := CompositeSystem new
register: cms;
register: pms;
yourself.
composite startUp.

newCMS := FixedCustomerSystem new.

self deny: cms = newCMS.

self
assert: composite >> #CustomerQueryingSystem equals: cms;
assert: pms >> #CustomerQueryingSystem equals: cms.

( SystemHotSwapper swapSystemImplementing: #CustomerQueryingSystem with: newCMS )
applyTo: composite.

self
assert: composite >> #CustomerQueryingSystem equals: newCMS;
assert: pms >> #CustomerQueryingSystem equals: newCMS
]
4 changes: 3 additions & 1 deletion source/Kepler-System/SubsystemImplementation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ SubsystemImplementation >> resetDependencies [
{ #category : #installing }
SubsystemImplementation >> resolveDependencies [

self dependencies do: [ :interfaceKey | dependencies bind: interfaceKey to: self parent >> interfaceKey ]
self resetDependencies.
self dependencies
do: [ :interfaceKey | dependencies bind: interfaceKey to: self parent >> interfaceKey ]
]

{ #category : #'private - controlling' }
Expand Down

0 comments on commit 7c62f8f

Please sign in to comment.