Skip to content

Commit

Permalink
Also catch SocketError next to PrimitiveFailed where appropriate (fro…
Browse files Browse the repository at this point in the history
…m Pharo 11 onwards, remain compatible with Pharo 7,8,9,10)
  • Loading branch information
svenvc committed Jun 3, 2024
1 parent 1a8ed8f commit 7035a17
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setupTLSTo: url
connection sslSession certificateName: self certificate.

[ connection sslSession serverName: url host ]
on: PrimitiveFailed
on: (ZnUtils exceptionSet: #( #SocketError #PrimitiveFailed ))
do: [ :error | "log it?" ].

connection connect
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ readRequestTerminationExceptionSet

^ ZnUtils
exceptionSet:
#(#ConnectionClosed #ConnectionTimedOut #PrimitiveFailed)
#(#ConnectionClosed #ConnectionTimedOut #SocketError #PrimitiveFailed)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ writeResponseTerminationExceptionSet

^ ZnUtils
exceptionSet:
#(#ConnectionClosed #ConnectionTimedOut #PrimitiveFailed)
#(#ConnectionClosed #ConnectionTimedOut #SocketError #PrimitiveFailed)
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
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Zinc-Tests'!
self packageOrganizer ensurePackage: #'Zinc-Tests' withTags: #()!

0 comments on commit 7035a17

Please sign in to comment.