-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also catch SocketError next to PrimitiveFailed where appropriate (fro…
…m Pharo 11 onwards, remain compatible with Pharo 7,8,9,10)
- Loading branch information
Showing
6 changed files
with
35 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
repository/Zinc-Tests.package/ZnClientTest.class/instance/testLogging.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
testing | ||
testLogging | ||
|
||
| client logEventCollection count | | ||
logEventCollection := OrderedCollection new. | ||
ZnLogEvent announcer | ||
when: ZnLogEvent do: [ :event | logEventCollection add: event ]. | ||
when: ZnLogEvent | ||
do: [ :event | logEventCollection add: event ] | ||
for: self. | ||
(client := ZnClient new) | ||
clientId: #C1; | ||
beOneShot. | ||
client get: self smallHtmlUrl. | ||
client close. | ||
count := ZnLogEvent announcer numberOfSubscriptions. | ||
ZnLogEvent announcer | ||
unsubscribe: self. | ||
self assert: ZnLogEvent announcer numberOfSubscriptions equals: count -1. | ||
ZnLogEvent announcer unsubscribe: self. | ||
self | ||
assert: ZnLogEvent announcer numberOfSubscriptions | ||
equals: count - 1. | ||
self deny: logEventCollection isEmpty. | ||
self assert: logEventCollection anyOne clientId equals: #C1 |
33 changes: 23 additions & 10 deletions
33
repository/Zinc-Tests.package/ZnServerTest.class/instance/testLogging.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
tests | ||
testLogging | ||
|
||
| client logEventCollection count renderedLogEvents | | ||
logEventCollection := OrderedCollection new. | ||
ZnLogEvent announcer | ||
when: ZnLogEvent do: [ :event | logEventCollection add: event ]. | ||
when: ZnLogEvent | ||
do: [ :event | logEventCollection add: event ] | ||
for: self. | ||
self withServerDo: [ :server | | ||
1 to: 3 do: [ :logLevel | | ||
server serverId: ('S' , logLevel asString) ; logLevel: logLevel. | ||
server | ||
serverId: 'S' , logLevel asString; | ||
logLevel: logLevel. | ||
client := ZnClient new. | ||
client clientId: ('C' , logLevel asString); logLevel: logLevel. | ||
client | ||
clientId: 'C' , logLevel asString; | ||
logLevel: logLevel. | ||
client get: (server localUrl addPathSegment: #small). | ||
self assert: client isSuccess. | ||
client get: (server localUrl addPathSegment: #error). | ||
self deny: client isSuccess. | ||
server delegate map: #redirect to: [ :request | ZnResponse redirect: #welcome ]. | ||
server delegate | ||
map: #redirect | ||
to: [ :request | ZnResponse redirect: #welcome ]. | ||
client get: (server localUrl addPathSegment: #redirect). | ||
self assert: client isSuccess. | ||
self assert: client isSuccess. | ||
client close ] ]. | ||
count := ZnLogEvent announcer numberOfSubscriptions. | ||
ZnLogEvent announcer | ||
unsubscribe: self. | ||
self assert: ZnLogEvent announcer numberOfSubscriptions equals: count -1. | ||
ZnLogEvent announcer unsubscribe: self. | ||
self | ||
assert: ZnLogEvent announcer numberOfSubscriptions | ||
equals: count - 1. | ||
self deny: logEventCollection isEmpty. | ||
renderedLogEvents := String streamContents: [ :out | | ||
logEventCollection do: [ :event | out print: event; cr ] ]. | ||
renderedLogEvents := String streamContents: [ :out | | ||
logEventCollection do: [ :event | | ||
out | ||
print: event; | ||
cr ] ]. | ||
self deny: renderedLogEvents isEmpty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SystemOrganization addCategory: #'Zinc-Tests'! | ||
self packageOrganizer ensurePackage: #'Zinc-Tests' withTags: #()! |