rhodes 3.2.0.beta.5 → 3.2.0.beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. data/CHANGELOG +3 -0
  2. data/Manifest.txt +10 -1
  3. data/Rakefile +6 -0
  4. data/bin/get-rhodes-info +4 -27
  5. data/bin/set-rhodes-sdk +4 -1
  6. data/doc/build.txt +12 -3
  7. data/doc/extensions.txt +26 -0
  8. data/installer/Rakefile +156 -0
  9. data/installer/ServiceLib.nsh +369 -0
  10. data/installer/jake.rb +478 -0
  11. data/installer/rhostudio.nsi +76 -143
  12. data/lib/extensions/digest-sha1/ext/Rakefile +58 -40
  13. data/lib/extensions/fileutils/fileutils.rb +3 -2
  14. data/lib/extensions/hmac/hmac-md5.rb +11 -0
  15. data/lib/extensions/hmac/hmac-rmd160.rb +11 -0
  16. data/lib/extensions/hmac/hmac-sha1.rb +11 -0
  17. data/lib/extensions/hmac/hmac-sha2.rb +25 -0
  18. data/lib/extensions/hmac/hmac.rb +118 -0
  19. data/lib/extensions/hmac/ruby_hmac.rb +2 -0
  20. data/lib/extensions/net-http/net/http.rb +1 -1
  21. data/lib/framework/rho/render.rb +1 -1
  22. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +1 -6
  23. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +52 -8
  24. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +8 -15
  25. data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +4 -5
  26. data/platform/android/build/android.rake +3 -1
  27. data/platform/iphone/rbuild/iphone.rake +7 -7
  28. data/platform/shared/common/RhodesApp.cpp +18 -14
  29. data/platform/shared/common/RhodesApp.h +1 -0
  30. data/platform/shared/rubyext/System.cpp +3 -0
  31. data/platform/symbian/build/symbian.rake +13 -5
  32. data/platform/wp7/RhoRubyLib/net/NetRequest.cs +9 -1
  33. data/rakefile.rb +6 -0
  34. data/res/generators/templates/application/Rakefile +10 -1
  35. data/res/generators/templates/application/app/layout.erb +1 -1
  36. data/res/generators/templates/application/build.yml +2 -2
  37. data/res/generators/templates/application/public/jqmobile/{jquery.mobile.iphone.css → jquery-mobile-iphone.css} +0 -0
  38. data/res/generators/templates/application/public/js/jqmobile-patch.js +23 -20
  39. data/spec/framework_spec/app/spec/library/digest/sha1/file_spec.rb +3 -3
  40. data/spec/framework_spec/app/spec/library/net/http/http/Proxy_spec.rb +3 -2
  41. data/spec/framework_spec/app/spec/library/net/http/http/copy_spec.rb +1 -1
  42. data/spec/framework_spec/app/spec/library/net/http/http/delete_spec.rb +1 -1
  43. data/spec/framework_spec/app/spec/library/net/http/http/finish_spec.rb +1 -1
  44. data/spec/framework_spec/app/spec/library/net/http/http/fixtures/http_server.rb +18 -12
  45. data/spec/framework_spec/app/spec/library/net/http/http/get_print_spec.rb +2 -2
  46. data/spec/framework_spec/app/spec/library/net/http/http/get_response_spec.rb +2 -2
  47. data/spec/framework_spec/app/spec/library/net/http/http/get_spec.rb +3 -3
  48. data/spec/framework_spec/app/spec/library/net/http/http/head_spec.rb +1 -1
  49. data/spec/framework_spec/app/spec/library/net/http/http/initialize_spec.rb +2 -2
  50. data/spec/framework_spec/app/spec/library/net/http/http/inspect_spec.rb +4 -4
  51. data/spec/framework_spec/app/spec/library/net/http/http/lock_spec.rb +1 -1
  52. data/spec/framework_spec/app/spec/library/net/http/http/mkcol_spec.rb +1 -1
  53. data/spec/framework_spec/app/spec/library/net/http/http/move_spec.rb +1 -1
  54. data/spec/framework_spec/app/spec/library/net/http/http/new_spec.rb +7 -7
  55. data/spec/framework_spec/app/spec/library/net/http/http/newobj_spec.rb +2 -2
  56. data/spec/framework_spec/app/spec/library/net/http/http/options_spec.rb +1 -1
  57. data/spec/framework_spec/app/spec/library/net/http/http/port_spec.rb +2 -2
  58. data/spec/framework_spec/app/spec/library/net/http/http/post_form_spec.rb +1 -1
  59. data/spec/framework_spec/app/spec/library/net/http/http/post_spec.rb +1 -1
  60. data/spec/framework_spec/app/spec/library/net/http/http/propfind_spec.rb +1 -1
  61. data/spec/framework_spec/app/spec/library/net/http/http/proppatch_spec.rb +1 -1
  62. data/spec/framework_spec/app/spec/library/net/http/http/proxy_address_spec.rb +2 -2
  63. data/spec/framework_spec/app/spec/library/net/http/http/proxy_pass_spec.rb +3 -3
  64. data/spec/framework_spec/app/spec/library/net/http/http/proxy_port_spec.rb +3 -3
  65. data/spec/framework_spec/app/spec/library/net/http/http/proxy_user_spec.rb +3 -3
  66. data/spec/framework_spec/app/spec/library/net/http/http/put_spec.rb +1 -1
  67. data/spec/framework_spec/app/spec/library/net/http/http/request_spec.rb +1 -1
  68. data/spec/framework_spec/app/spec/library/net/http/http/send_request_spec.rb +1 -1
  69. data/spec/framework_spec/app/spec/library/net/http/http/set_debug_output_spec.rb +1 -1
  70. data/spec/framework_spec/app/spec/library/net/http/http/shared/request_get.rb +1 -1
  71. data/spec/framework_spec/app/spec/library/net/http/http/shared/request_head.rb +1 -1
  72. data/spec/framework_spec/app/spec/library/net/http/http/shared/request_post.rb +1 -1
  73. data/spec/framework_spec/app/spec/library/net/http/http/shared/request_put.rb +1 -1
  74. data/spec/framework_spec/app/spec/library/net/http/http/shared/started.rb +1 -1
  75. data/spec/framework_spec/app/spec/library/net/http/http/start_spec.rb +8 -8
  76. data/spec/framework_spec/app/spec/library/net/http/http/trace_spec.rb +1 -1
  77. data/spec/framework_spec/app/spec/library/net/http/http/unlock_spec.rb +1 -1
  78. data/spec/framework_spec/app/spec_runner.rb +1 -1
  79. data/spec/framework_spec/build.yml +2 -2
  80. data/spec/phone_spec/app/spec/rhom_object_spec.rb +43 -2
  81. data/version +1 -1
  82. metadata +14 -5
@@ -589,13 +589,13 @@ namespace "run" do
589
589
 
590
590
  # Run local http server
591
591
  $iphonespec = true
592
- httpserver = false
593
- httpserver = true if File.exist? "#{$app_path}/app/spec/library/net/http/http/fixtures/http_server.rb"
592
+ #httpserver = false
593
+ #httpserver = true if File.exist? "#{$app_path}/app/spec/library/net/http/http/fixtures/http_server.rb"
594
594
 
595
- if httpserver
596
- require "#{$app_path}/app/spec/library/net/http/http/fixtures/http_server"
597
- NetHTTPSpecs.start_server
598
- end
595
+ #if httpserver
596
+ # require "#{$app_path}/app/spec/library/net/http/http/fixtures/http_server"
597
+ # NetHTTPSpecs.start_server
598
+ #end
599
599
 
600
600
  Jake.before_run_spec
601
601
 
@@ -658,7 +658,7 @@ namespace "run" do
658
658
 
659
659
  $stdout.flush
660
660
 
661
- NetHTTPSpecs.stop_server if httpserver
661
+ #NetHTTPSpecs.stop_server if httpserver
662
662
 
663
663
  exit $failed.to_i unless $dont_exit_on_failure
664
664
 
@@ -752,14 +752,24 @@ void CRhodesApp::initHttpServer()
752
752
  }
753
753
 
754
754
  const char* CRhodesApp::getFreeListeningPort()
755
+ {
756
+ if ( m_strListeningPorts.length() > 0 )
757
+ return m_strListeningPorts.c_str();
758
+
759
+ int nFreePort = determineFreeListeningPort();
760
+ m_strListeningPorts = convertToStringA(nFreePort);
761
+
762
+ LOG(INFO) + "Free listening port: " + m_strListeningPorts;
763
+
764
+ return m_strListeningPorts.c_str();
765
+ }
766
+
767
+ int CRhodesApp::determineFreeListeningPort()
755
768
  {
756
769
  int sockfd = -1;
757
770
  sockaddr_in serv_addr = sockaddr_in();
758
- int noerrors = 1;
771
+ int nFreePort = 0, noerrors = 1;
759
772
 
760
- if ( m_strListeningPorts.length() > 0 )
761
- return m_strListeningPorts.c_str();
762
-
763
773
  LOG(INFO) + "Trying to get free listening port.";
764
774
 
765
775
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
@@ -837,13 +847,12 @@ const char* CRhodesApp::getFreeListeningPort()
837
847
  if (getsockname( sockfd, (struct sockaddr *)&serv_addr, &length ) != 0)
838
848
  {
839
849
  LOG(WARNING) + "Can not get socket info";
840
- noerrors = 0;
850
+ nFreePort = 0;
841
851
  }
842
852
  else
843
853
  {
844
- sprintf(buf, "%d", (int)ntohs(serv_addr.sin_port));
845
- LOG(INFO) + "Got port to bind on: " + buf;
846
- m_strListeningPorts = buf;
854
+ nFreePort = (int)ntohs(serv_addr.sin_port);
855
+ LOG(INFO) + "Got port to bind on: " + nFreePort;
847
856
  }
848
857
  }
849
858
 
@@ -854,12 +863,7 @@ const char* CRhodesApp::getFreeListeningPort()
854
863
  closesocket(sockfd);
855
864
  #endif
856
865
 
857
- if ( !noerrors )
858
- m_strListeningPorts = "0";
859
-
860
- LOG(INFO) + "Free listening port: " + m_strListeningPorts;
861
-
862
- return m_strListeningPorts.c_str();
866
+ return nFreePort;
863
867
  }
864
868
 
865
869
  void CRhodesApp::initAppUrls()
@@ -153,6 +153,7 @@ public:
153
153
 
154
154
  void notifyLocalServerStarted();
155
155
  const char* getFreeListeningPort();
156
+ int determineFreeListeningPort();
156
157
 
157
158
  void setSendingLog(boolean bSending){m_bSendingLog = bSending; }
158
159
  protected:
@@ -112,6 +112,9 @@ VALUE rho_sys_get_property(char* szPropName)
112
112
  if (strcasecmp("rhodes_port",szPropName) == 0)
113
113
  return rho_ruby_create_integer(atoi(RHODESAPP().getFreeListeningPort()));
114
114
 
115
+ if (strcasecmp("free_server_port",szPropName) == 0)
116
+ return rho_ruby_create_integer(RHODESAPP().determineFreeListeningPort());
117
+
115
118
  if (strcasecmp("is_emulator",szPropName) == 0)
116
119
  return rho_ruby_create_boolean(0);
117
120
 
@@ -90,6 +90,7 @@ namespace "build" do
90
90
  ENV['GCCPATH']= $symbiandir+"/tools/gcce4"
91
91
  ENV['DEFALT_MKSPEC_PATH']=$sdkprefix+"/mkspecs/default"
92
92
  ENV['QMAKE_PATH']=$sdkprefix+"/bin"
93
+ ENV['QT_SIS_OPTIONS']="-u"
93
94
 
94
95
 
95
96
  if($ver == "9.4")
@@ -133,6 +134,9 @@ namespace "build" do
133
134
  #end
134
135
 
135
136
  mkdir_p $targetdir if not File.exists? $targetdir
137
+ rm $targetdir+"/"+$appname+"_unsigned.sis" if File.exists? $targetdir+"/"+$appname+"_unsigned.sis"
138
+ cp $startdir + "/"+$config["build"]["symbianpath"] + "/rhodes/"+$appname+"_unsigned.sis", $targetdir+"/"+$appname+"_unsigned.sis"
139
+
136
140
  rm $targetdir+"/"+$appname+".sis" if File.exists? $targetdir+"/"+$appname+".sis"
137
141
  cp $startdir + "/"+$config["build"]["symbianpath"] + "/rhodes/"+$appname+".sis", $targetdir+"/"+$appname+".sis"
138
142
 
@@ -171,9 +175,13 @@ namespace "build" do
171
175
  rm_r "db" if File.exists? "db"
172
176
  rm_r "lib" if File.exists? "lib"
173
177
 
174
- mv "rhodes/apps", pwd
175
- mv "rhodes/db", pwd
176
- mv "rhodes/lib", pwd
178
+ #mv "rhodes/apps", pwd
179
+ #mv "rhodes/db", pwd
180
+ #mv "rhodes/lib", pwd
181
+
182
+ cp_r $srcdir + "/apps", pwd
183
+ cp_r $srcdir + "/db", pwd
184
+ cp_r $srcdir + "/lib", pwd
177
185
 
178
186
  cp "rhodes/release/rhodes.exe", pwd if File.exists? "rhodes/release/rhodes.exe"
179
187
 
@@ -208,7 +216,7 @@ end
208
216
  namespace "device" do
209
217
  namespace "symbian" do
210
218
  desc "Build production for device"
211
- task :production => ["config:symbian","build:symbian:rhobundle","build:symbian:rhodesdev"] do
219
+ task :production => ["build:symbian:rhobundle","build:symbian:rhodesdev"] do
212
220
 
213
221
 
214
222
 
@@ -245,7 +253,7 @@ namespace "device" do
245
253
  end
246
254
 
247
255
  namespace "run" do
248
- task :symbian => ["config:symbian","build:symbian:rhobundle","build:symbian:rhodesemu"] do
256
+ task :symbian => ["build:symbian:rhobundle","build:symbian:rhodesemu"] do
249
257
 
250
258
 
251
259
 
@@ -29,6 +29,8 @@ using System.Net;
29
29
  using rho.common;
30
30
  using System.Threading;
31
31
  using System.Text;
32
+ using IronRuby.Runtime;
33
+ using IronRuby.Builtins;
32
34
  using System.IO;
33
35
 
34
36
  namespace rho.net
@@ -507,7 +509,13 @@ namespace rho.net
507
509
  if (pResp.isSuccess())
508
510
  {
509
511
  if (m_strCookies == "" && m_strRespBody.Contains("rhoconnect_session"))
510
- m_strCookies = m_strRespBody;
512
+ {
513
+ m_strRespBody = m_strRespBody.Replace('{', ' ');
514
+ m_strRespBody = m_strRespBody.Replace('}', ' ');
515
+ m_strRespBody = m_strRespBody.Replace('"', ' ');
516
+ string[] cookies = m_strRespBody.Split(':');
517
+ m_strCookies = cookies[1].Trim();
518
+ }
511
519
  pResp.setCookies(m_strCookies);
512
520
  }
513
521
 
data/rakefile.rb CHANGED
@@ -1098,6 +1098,12 @@ namespace "run" do
1098
1098
  $appname = $app_config["name"].nil? ? "Rhodes" : $app_config["name"]
1099
1099
  if !File.exists?($path)
1100
1100
  puts "Cannot find RhoSimulator: '#{$path}' does not exists"
1101
+ puts "Check sdk path in build.yml - it should point to latest rhodes (run set-rhodes-sdk in application folder) OR"
1102
+
1103
+ if $config['env']['paths']['rhosimulator'] and $config['env']['paths']['rhosimulator'].length() > 0
1104
+ puts "Check 'env:paths:rhosimulator' path in '<rhodes>/rhobuild.yml' OR"
1105
+ end
1106
+
1101
1107
  puts "Install Rhodes gem OR"
1102
1108
  puts "Install RhoSimulator and modify 'env:paths:rhosimulator' section in '<rhodes>/rhobuild.yml'"
1103
1109
  exit 1
@@ -10,7 +10,16 @@ $app_config = YAML::load_file("build.yml")
10
10
  $app_path = File.expand_path(File.dirname(__FILE__))
11
11
 
12
12
  if ENV["RHO_HOME"].nil?
13
- rakefilepath = "#{$app_config["sdk"]}/Rakefile"
13
+ if $app_config["sdk"]
14
+ rakefilepath = "#{$app_config["sdk"]}/Rakefile"
15
+ else
16
+ begin
17
+ rakefilepath = File.dirname(`get-rhodes-info --rhodes-path`)
18
+ rakefilepath = File.join(rakefilepath, "Rakefile")
19
+ rescue
20
+ rakefilepath = ""
21
+ end
22
+ end
14
23
  else
15
24
  rakefilepath = "#{ENV["RHO_HOME"]}/Rakefile"
16
25
  end
@@ -24,7 +24,7 @@
24
24
  <link rel="stylesheet" href="/public/jqmobile/jquery.mobile-1.0rc1.min.css">
25
25
  <link rel="stylesheet" href="/public/css/jqmobile-patch.css">
26
26
  <%% if System::get_property('platform') == 'APPLE' %>
27
- <link href="/public/jqmobile/jquery.mobile.iphone.css" type="text/css" rel="stylesheet"/>
27
+ <link href="/public/jqmobile/jquery-mobile-iphone.css" type="text/css" rel="stylesheet"/>
28
28
  <%% end %>
29
29
 
30
30
  <script type="text/javascript">
@@ -1,4 +1,4 @@
1
- sdk: "<%=@sdk_path%>"
1
+ #sdk: "<%=@sdk_path%>"
2
2
  sdkversion: <%=Rhodes::VERSION%>
3
3
  name: <%=@app_name%>
4
4
  version: 1.0
@@ -9,7 +9,7 @@ wmsdk: "Windows Mobile 6 Professional SDK (ARMV4I)"
9
9
  applog: rholog.txt
10
10
  iphone:
11
11
  configuration: Release
12
- sdk: iphonesimulator4.3
12
+ sdk: iphonesimulator5.0
13
13
  provisionprofile:
14
14
  codesignidentity:
15
15
  entitlements:
@@ -38,7 +38,13 @@
38
38
 
39
39
  options.success = function(html, textStatus, jqXHR) {
40
40
  if (jqXHR.getResponseHeader('Wait-Page')) {
41
- // do nothing
41
+ // We cannot just do nothing on wait-page being received, because
42
+ // at this moment jQM already have isPageTransitioning lock is set.
43
+ // Due to this lock is private part of jQM we have no control on it.
44
+ // So we are going to tag Wait-Page HTML content by some HTML attribute
45
+ // to detect it in "pagebeforechange" event handler and then perform
46
+ // preventDefault() to let jQM to release isPageTransitioning lock.
47
+ origSuccess('<div data-role="page" data-rho-wait-page="true"><!-- intentionally empty --></div>');
42
48
  } else {
43
49
  origSuccess(html);
44
50
  }
@@ -46,6 +52,20 @@
46
52
 
47
53
  });
48
54
 
55
+ $(document).bind( "pagebeforechange", function(e, data) {
56
+ // We only want to handle changePage() calls where the caller is
57
+ // providing us an already loaded page.
58
+ if ( !(typeof data.toPage === "string") ) {
59
+ var pageDiv = data.toPage[0];
60
+ if ("true" === pageDiv.getAttribute("data-rho-wait-page")) {
61
+ //Make sure to tell changePage() we've handled this call so it doesn't
62
+ //have to do anything. So jQM can release isPageTransitioning lock
63
+ e.preventDefault();
64
+ }
65
+ }
66
+ });
67
+
68
+
49
69
  //shared page enhancements
50
70
  function enhancePage( $page, role ) {
51
71
  // If a role was specified, make sure the data-role attribute
@@ -134,14 +154,14 @@
134
154
  // reference to an embedded page. If so, it may have been dynamically
135
155
  // injected by a developer, in which case it would be lacking a data-url
136
156
  // attribute and in need of enhancement.
137
- if ( page.length === 0 && !path.isPath( dataUrl ) ) {
157
+ if ( page.length === 0 && dataUrl && !path.isPath( dataUrl ) ) {
138
158
  page = settings.pageContainer.children( "#" + dataUrl )
139
159
  .attr( "data-" + $.mobile.ns + "url", dataUrl )
140
160
  }
141
161
 
142
162
  // If we failed to find a page in the DOM, check the URL to see if it
143
163
  // refers to the first page in the application.
144
- if ( page.length === 0 && $.mobile.firstPage && path.isFirstPageUrl( absUrl ) ) {
164
+ if ( page.length === 0 && $.mobile.firstPage && absUrl && path.isFirstPageUrl( absUrl ) ) {
145
165
  page = $( $.mobile.firstPage );
146
166
  }
147
167
 
@@ -276,18 +296,6 @@
276
296
  // wait for page creation to leverage options defined on widget
277
297
  page.one( 'pagecreate', $.mobile._bindPageRemove );
278
298
 
279
- /*
280
- page.one('pagecreate', function(){
281
-
282
- // when dom caching is not enabled bind to remove the page on hide
283
- if( !page.data("page").options.domCache ){
284
- page.bind( "pagehide.remove", function(){
285
- $(this).remove();
286
- });
287
- }
288
- });
289
- */
290
-
291
299
  enhancePage( page, settings.role );
292
300
 
293
301
  // Enhancing the page may result in new dialogs/sub pages being inserted
@@ -319,11 +327,6 @@
319
327
  $.mobile.loadPage.defaults = original_loadPage.defaults;
320
328
 
321
329
  function insertAsyncPage(data) {
322
- //setTimeout(function(){
323
- // /*$('.waiting').remove();*/
324
- // $.mobile.hidePageLoadingMsg();
325
- //},450);
326
-
327
330
  $.mobile.loadPage("inline://", {html: data})
328
331
  .done(function( url, options, newPage, dupCachedPage ) {
329
332
  options.duplicateCachedPage = dupCachedPage;
@@ -33,9 +33,9 @@ describe "Digest::SHA1.file" do
33
33
 
34
34
  it_behaves_like :file_read_directory, :file, Digest::SHA1
35
35
 
36
- it 'raises a Errno::ENOENT when passed a path that does not exist' do
37
- lambda { Digest::SHA1.file("") }.should raise_error(Errno::ENOENT)
38
- end
36
+ #it 'raises a Errno::ENOENT when passed a path that does not exist' do
37
+ # lambda { Digest::SHA1.file("") }.should raise_error(Errno::ENOENT)
38
+ #end
39
39
 
40
40
  it 'raises a TypeError when passed nil' do
41
41
  lambda { Digest::SHA1.file(nil) }.should raise_error(TypeError)
@@ -1,5 +1,6 @@
1
1
  require File.expand_path('../../../../../spec_helper', __FILE__)
2
2
  require 'net/http'
3
+ require File.expand_path('../fixtures/http_server', __FILE__)
3
4
 
4
5
  describe "Net::HTTP.Proxy" do
5
6
  it "returns a new subclass of Net::HTTP" do
@@ -22,14 +23,14 @@ end
22
23
  describe "Net::HTTP#proxy?" do
23
24
  describe "when self is no proxy class instance" do
24
25
  it "returns false" do
25
- Net::HTTP.new("127.0.0.1", 3454).proxy?.should be_false
26
+ Net::HTTP.new("127.0.0.1", NetHTTPSpecs.server_port).proxy?.should be_false
26
27
  end
27
28
  end
28
29
 
29
30
  describe "when self is a proxy class instance" do
30
31
  it "returns false" do
31
32
  http_with_proxy = Net::HTTP.Proxy("127.0.0.1", 1234, "rspec", "rocks")
32
- http_with_proxy.new("127.0.0.1", 3454).proxy?.should be_true
33
+ http_with_proxy.new("127.0.0.1", NetHTTPSpecs.server_port).proxy?.should be_true
33
34
  end
34
35
  end
35
36
  end
@@ -12,7 +12,7 @@ describe "Net::HTTP#copy" do
12
12
  end
13
13
 
14
14
  before(:each) do
15
- @http = Net::HTTP.start("127.0.0.1", 3454)
15
+ @http = Net::HTTP.start("127.0.0.1", NetHTTPSpecs.server_port)
16
16
  end
17
17
 
18
18
  it "sends a COPY request to the passed path and returns the response" do
@@ -12,7 +12,7 @@ describe "Net::HTTP#delete" do
12
12
  end
13
13
 
14
14
  before(:each) do
15
- @http = Net::HTTP.start("127.0.0.1", 3454)
15
+ @http = Net::HTTP.start("127.0.0.1", NetHTTPSpecs.server_port)
16
16
  end
17
17
 
18
18
  it "sends a DELETE request to the passed path and returns the response" do
@@ -12,7 +12,7 @@ describe "Net::HTTP#finish" do
12
12
  end
13
13
 
14
14
  before(:each) do
15
- @http = Net::HTTP.new("127.0.0.1", 3454)
15
+ @http = Net::HTTP.new("127.0.0.1", NetHTTPSpecs.server_port)
16
16
  end
17
17
 
18
18
  describe "when self has been started" do
@@ -49,39 +49,45 @@ module NetHTTPSpecs
49
49
  end
50
50
 
51
51
  class << self
52
- @server = nil
53
-
52
+ @@server = nil
53
+ @@server_port = 0
54
+
55
+ def server_port
56
+ @@server_port
57
+ end
58
+
54
59
  def start_server
55
- unless @server
60
+ unless @@server
61
+ @@server_port = System::get_property('free_server_port')
56
62
  server_config = {
57
63
  :BindAddress => "127.0.0.1",
58
- :Port => 3454,
64
+ :Port => @@server_port, #NetHTTPSpecs.server_port,
59
65
  :Logger => WEBrick::Log.new(NullWriter.new),
60
66
  :AccessLog => [],
61
67
  :ShutdownSocketWithoutClose => true,
62
68
  :ServerType => Thread
63
69
  }
64
70
 
65
- @server = WEBrick::HTTPServer.new(server_config)
71
+ @@server = WEBrick::HTTPServer.new(server_config)
66
72
 
67
- @server.mount_proc('/') do |req, res|
73
+ @@server.mount_proc('/') do |req, res|
68
74
  res.content_type = "text/plain"
69
75
  res.body = "This is the index page."
70
76
  end
71
- @server.mount('/request', RequestServlet)
72
- @server.mount("/request/body", RequestBodyServlet)
73
- @server.mount("/request/header", RequestHeaderServlet)
77
+ @@server.mount('/request', RequestServlet)
78
+ @@server.mount("/request/body", RequestBodyServlet)
79
+ @@server.mount("/request/header", RequestHeaderServlet)
74
80
 
75
- @server.start
81
+ @@server.start
76
82
  end
77
83
 
78
84
  # On initial startup or if we re-enter, we wait until the
79
85
  # server is really running.
80
- Thread.pass until @server.status == :Running
86
+ Thread.pass until @@server.status == :Running
81
87
  end
82
88
 
83
89
  def shutdown_server
84
- @server.shutdown if @server
90
+ @@server.shutdown if @@server
85
91
  end
86
92
 
87
93
  def stop_server