[squeak-dev] Re: [BUG][FIX][FIX],
was: (Re: Re: Flaw in SocketStream>>peek detected)
Andreas Raab
andreas.raab at gmx.de
Fri Jan 15 01:15:31 UTC 2010
Igor Stasenko wrote:
> My first attempt to fix it was also flawed. Thanks to Stephan for
> pointing it out. (You can read our discussion here:
> http://code.google.com/p/pharo/issues/detail?id=1813)
>
>
> I hope this time its fixing it! :)
From what I can tell, the changes are completely equivalent. Could you
please write a test that illustrates what you think was wrong with the
previous version? Attached are some tests that (I think) show that
there's really no difference in these versions.
Cheers,
- Andreas
-------------- next part --------------
'From Squeak3.11alpha of 12 January 2010 [latest update: #8864] on 14 January 2010 at 5:13:12 pm'!
TestCase subclass: #SocketStreamTest
instanceVariableNames: 'server client other'
classVariableNames: ''
poolDictionaries: ''
category: 'NetworkTests-Kernel'!
!SocketStreamTest methodsFor: 'setup' stamp: 'ar 1/14/2010 17:10'!
setUp
server := Socket newTCP.
server listenOn: 0 backlogSize: 1.
client := SocketStream openConnectionToHostNamed: 'localhost' port: server localPort.
other := server waitForAcceptFor: 1.
self assert: other notNil.
! !
!SocketStreamTest methodsFor: 'setup' stamp: 'ar 1/14/2010 16:58'!
tearDown
other ifNotNil:[other destroy].
client ifNotNil:[client socket destroy].
server ifNotNil:[server destroy].! !
!SocketStreamTest methodsFor: 'tests' stamp: 'ar 1/14/2010 17:08'!
testPeekCloseNoResponse
"This is a test for peek where the other end closes the socket."
| result |
[(Delay forMilliseconds: 100) wait. other closeAndDestroy] fork.
result := client peek.
self assert: result = nil.! !
!SocketStreamTest methodsFor: 'tests' stamp: 'ar 1/14/2010 17:09'!
testPeekCloseNoResponseNoSignal
"This is a test for peek where the other end closes the socket"
| result |
client shouldSignal: false.
[(Delay forMilliseconds: 100) wait. other closeAndDestroy] fork.
result := client peek.
self assert: result = nil.! !
!SocketStreamTest methodsFor: 'tests' stamp: 'ar 1/14/2010 17:13'!
testPeekTimeoutNoResponse
"This is a test illustrating the behavior on timeout"
client timeout: 1.
self should:[client peek] raise: ConnectionTimedOut.
! !
!SocketStreamTest methodsFor: 'tests' stamp: 'ar 1/14/2010 17:08'!
testPeekWithResponse
"Illustrates peek behavior with associcated response"
| result |
[(Delay forMilliseconds: 100) wait. other sendData: 'Hello World'] fork.
result := client peek.
self assert: result = $H.! !
More information about the Squeak-dev
mailing list
|