23
23
24
24
module Selenium
25
25
describe Server do
26
- let ( :mock_process ) { instance_double ( WebDriver ::ChildProcess ) . as_null_object }
26
+ let ( :mock_process ) do
27
+ instance_double ( WebDriver ::ChildProcess ) . tap do |mock |
28
+ allow ( mock ) . to receive ( :start )
29
+ allow ( mock ) . to receive ( :wait )
30
+ allow ( mock ) . to receive ( :stop )
31
+ allow ( mock ) . to receive ( :detach= )
32
+ allow ( mock ) . to receive ( :io )
33
+ allow ( mock ) . to receive ( :io= )
34
+ end
35
+ end
27
36
let ( :mock_poller ) { instance_double ( WebDriver ::SocketPoller , connected? : true , closed? : true ) }
28
37
let ( :repo ) { 'https://api.github.com/repos/seleniumhq/selenium/releases' }
29
38
let ( :port ) { WebDriver ::PortProber . above ( 4444 ) }
@@ -49,7 +58,8 @@ module Selenium
49
58
it 'uses the given jar file and port' do
50
59
allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
51
60
allow ( WebDriver ::ChildProcess ) . to receive ( :build )
52
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '1234' )
61
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '1234' ,
62
+ '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
53
63
. and_return ( mock_process )
54
64
55
65
server = described_class . new ( 'selenium_server_deploy.jar' , port : 1234 , background : true )
@@ -58,13 +68,15 @@ module Selenium
58
68
server . start
59
69
expect ( File ) . to have_received ( :exist? ) . with ( 'selenium_server_deploy.jar' )
60
70
expect ( WebDriver ::ChildProcess ) . to have_received ( :build )
61
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '1234' )
71
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '1234' ,
72
+ '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
62
73
end
63
74
64
75
it 'waits for the server process by default' do
65
76
allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
66
77
allow ( WebDriver ::ChildProcess ) . to receive ( :build )
67
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s )
78
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s ,
79
+ '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
68
80
. and_return ( mock_process )
69
81
70
82
server = described_class . new ( 'selenium_server_deploy.jar' , port : port )
@@ -75,14 +87,16 @@ module Selenium
75
87
76
88
expect ( File ) . to have_received ( :exist? ) . with ( 'selenium_server_deploy.jar' )
77
89
expect ( WebDriver ::ChildProcess ) . to have_received ( :build )
78
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s )
90
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s ,
91
+ '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
79
92
expect ( mock_process ) . to have_received ( :wait )
80
93
end
81
94
82
95
it 'adds additional args' do
83
96
allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
84
97
allow ( WebDriver ::ChildProcess ) . to receive ( :build )
85
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s , 'foo' , 'bar' )
98
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s ,
99
+ '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s , 'foo' , 'bar' )
86
100
. and_return ( mock_process )
87
101
88
102
server = described_class . new ( 'selenium_server_deploy.jar' , port : port , background : true )
@@ -94,7 +108,8 @@ module Selenium
94
108
expect ( File ) . to have_received ( :exist? ) . with ( 'selenium_server_deploy.jar' )
95
109
expect ( WebDriver ::ChildProcess ) . to have_received ( :build )
96
110
. with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' ,
97
- '--port' , port . to_s , 'foo' , 'bar' )
111
+ '--port' , port . to_s , '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s ,
112
+ 'foo' , 'bar' )
98
113
end
99
114
100
115
it 'adds additional JAVA options args' do
@@ -105,6 +120,8 @@ module Selenium
105
120
'-jar' , 'selenium_server_deploy.jar' ,
106
121
'standalone' ,
107
122
'--port' , port . to_s ,
123
+ '--override-max-sessions' , 'true' ,
124
+ '--max-sessions' , Etc . nprocessors . to_s ,
108
125
'foo' ,
109
126
'bar' )
110
127
. and_return ( mock_process )
@@ -197,7 +214,8 @@ module Selenium
197
214
it 'raises Selenium::Server::Error if the server is not launched within the timeout' do
198
215
allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
199
216
allow ( WebDriver ::ChildProcess ) . to receive ( :build )
200
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s )
217
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s ,
218
+ '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
201
219
. and_return ( mock_process )
202
220
203
221
poller = instance_double ( WebDriver ::SocketPoller )
0 commit comments