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