author | Claus Gittinger <cg@exept.de> |
Sat, 01 Mar 2014 18:44:57 +0100 | |
changeset 1084 | f3cea5a36b07 |
parent 647 | 588836b3ec73 |
child 1266 | ba8ef71776bd |
permissions | -rw-r--r-- |
646 | 1 |
"{ Package: 'exept:regression' }" |
2 |
||
3 |
"{ NameSpace: RegressionTests }" |
|
4 |
||
5 |
TestCase subclass:#SocketTests |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
1084 | 9 |
category:'tests-Regression-Streams' |
646 | 10 |
! |
11 |
||
12 |
||
13 |
!SocketTests methodsFor:'tests - open-close'! |
|
14 |
||
15 |
test10_concurrentOpenClose |
|
16 |
|p1 p2 sock host port n1 n2| |
|
17 |
||
18 |
host := 'www.exept.de'. |
|
19 |
port := 80. |
|
20 |
n1 := n2 := 0. |
|
21 |
||
22 |
p1 := |
|
23 |
[ |
|
24 |
[true] whileTrue:[ |
|
25 |
sock := Socket newTCPclientToAddress:host port:port. |
|
26 |
Processor yield. |
|
27 |
n1 := n1 + 1. |
|
28 |
sock close |
|
29 |
] |
|
30 |
] newProcess. |
|
31 |
||
32 |
p2 := |
|
33 |
[ |
|
34 |
[true] whileTrue:[ |
|
35 |
sock := Socket newTCPclientToAddress:host port:port. |
|
36 |
Processor yield. |
|
37 |
n2 := n2 + 1. |
|
38 |
sock close |
|
39 |
] |
|
40 |
] newProcess. |
|
41 |
||
42 |
p1 resume. |
|
43 |
p2 resume. |
|
44 |
||
45 |
Delay waitForSeconds:20. |
|
46 |
p1 terminate. |
|
47 |
p2 terminate. |
|
48 |
||
49 |
Transcript showCR:'n1: %1; n2: %2' with:n1 with:n2 |
|
50 |
||
51 |
"Created: / 29-11-2011 / 14:43:57 / cg" |
|
647
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
52 |
! |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
53 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
54 |
test11_concurrentOpenClose |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
55 |
"using a non-existing host name (hoping that the connect will take longer then, |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
56 |
and we can enforce concurrent execution)" |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
57 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
58 |
|p1 p2 sock port n1 n2| |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
59 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
60 |
port := 80. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
61 |
n1 := n2 := 0. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
62 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
63 |
p1 := |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
64 |
[ |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
65 |
|host| |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
66 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
67 |
[true] whileTrue:[ |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
68 |
host := 'www.nonexisting-%1.de' bindWith:(UUID genRandomUUID). |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
69 |
HostNameLookupError handle:[:ex | |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
70 |
] do:[ |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
71 |
sock := Socket newTCPclientToAddress:host port:port. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
72 |
Processor yield. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
73 |
n1 := n1 + 1. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
74 |
sock close |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
75 |
]. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
76 |
] |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
77 |
] newProcess. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
78 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
79 |
p2 := |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
80 |
[ |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
81 |
|host| |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
82 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
83 |
[true] whileTrue:[ |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
84 |
host := 'www.nonexisting-%1.de' bindWith:(UUID genRandomUUID). |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
85 |
HostNameLookupError handle:[:ex | |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
86 |
] do:[ |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
87 |
sock := Socket newTCPclientToAddress:host port:port. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
88 |
Processor yield. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
89 |
n2 := n2 + 1. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
90 |
sock close |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
91 |
] |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
92 |
] |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
93 |
] newProcess. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
94 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
95 |
p1 resume. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
96 |
p2 resume. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
97 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
98 |
Delay waitForSeconds:20. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
99 |
p1 terminate. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
100 |
p2 terminate. |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
101 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
102 |
Transcript showCR:'n1: %1; n2: %2' with:n1 with:n2 |
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
103 |
|
588836b3ec73
added: #test11_concurrentOpenClose
Claus Gittinger <cg@exept.de>
parents:
646
diff
changeset
|
104 |
"Created: / 29-11-2011 / 18:17:04 / cg" |
646 | 105 |
! ! |
106 |
||
107 |
!SocketTests class methodsFor:'documentation'! |
|
108 |
||
109 |
version |
|
110 |
^ '$Header$' |
|
111 |
! |
|
112 |
||
113 |
version_CVS |
|
114 |
^ '$Header$' |
|
115 |
! ! |
|
1084 | 116 |