jettywrapper 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ec0896737d3b6280dd860cf58a545b7d2981a5f
4
+ data.tar.gz: c07c9985c43d31605ad61466649cdecb62369995
5
+ SHA512:
6
+ metadata.gz: cea4d28ccafdbc46d26899bc3b28dab6e0880e3d4108e7d78542407e8d1ff5d96ff06305e9db96ef139f887ac4d1a76140a05f465a0c9a97fe3f03e3fa4b0b99
7
+ data.tar.gz: 49e83df77c93fdd816cd56cc2fba3d98440a9fe20ea9b5d43761803957fb3df9002a854733e9f9b1c7838173cce718afa28b90a7f7c9724a007ffe959850e506
data/.gitignore CHANGED
@@ -9,3 +9,6 @@ coverage.data
9
9
  .yardoc
10
10
  doc
11
11
  tmp/
12
+ .rvmrc
13
+ jettywrapper.log
14
+ jetty
@@ -1,3 +0,0 @@
1
- [submodule "jetty"]
2
- path = jetty
3
- url = git://github.com/projecthydra/hydra-jetty.git
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+
6
+ notifications:
7
+ irc: "irc.freenode.org#projecthydra"
8
+
@@ -1,3 +1,6 @@
1
+ 1.4.0
2
+ Download jetty from a zip file
3
+
1
4
  1.3.2
2
5
  Throw error on start if port already in use
3
6
 
@@ -1,8 +1,16 @@
1
1
  h1. jettywrapper
2
2
 
3
+
3
4
  This gem is designed to make it easier to integrate a jetty servlet container into a rails project.
4
5
  Jettywrapper provides rake tasks for starting and stopping jetty, as well as a method (Jettywrapper.wrap) that will start the server before the block and stop the server after the block, which is useful for automated testing.
5
6
 
7
+ jettywrapper supports
8
+ ruby 2.0.0
9
+ ruby 1.9.3
10
+ ruby 1.8.7
11
+ ree 1.8.7
12
+ jruby 1.6.6+
13
+
6
14
  h2. Configuring Jettywrapper
7
15
 
8
16
  Jettywrapper starts the process with a list of options that you can specify in config/jetty.yml (otherwise a default is used). You can provide a per environment configuration, or you can have a default configuration which will be used when a per-environment configuration is not specified.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'bundler'
3
- require 'spec/rake/spectask'
3
+ require 'rspec/core/rake_task'
4
4
  require 'yard'
5
5
 
6
6
  Bundler::GemHelper.install_tasks
@@ -15,15 +15,12 @@ rescue Bundler::BundlerError => e
15
15
  exit e.status_code
16
16
  end
17
17
 
18
- Spec::Rake::SpecTask.new(:spec) do |spec|
19
- spec.libs << 'lib' << 'spec'
20
- spec.spec_files = FileList['spec/**/*_spec.rb']
18
+ RSpec::Core::RakeTask.new(:spec => 'jetty:clean') do |spec|
19
+ # spec.libs << 'lib' << 'spec'
20
+ # spec.spec_files = FileList['spec/**/*_spec.rb']
21
21
  end
22
22
 
23
- Spec::Rake::SpecTask.new(:coverage) do |spec|
24
- spec.libs << 'lib' << 'spec'
25
- spec.pattern = 'spec/**/*_spec.rb'
26
-
23
+ RSpec::Core::RakeTask.new(:coverage) do |spec|
27
24
  ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
28
25
  ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
29
26
 
@@ -57,4 +54,5 @@ rescue LoadError
57
54
  end
58
55
  end
59
56
 
60
- task :default => [:coverage, :doc]
57
+ #task :default => [:coverage, :doc]
58
+ task :default => [:spec]
@@ -1,5 +1,5 @@
1
1
  default:
2
2
  jetty_port: 8983
3
3
  java_opts:
4
- - "-XX:MaxPermSize=128m"
4
+ - "-XX:MaxPermSize=256m"
5
5
  - "-Xmx256m"
@@ -25,14 +25,11 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency "i18n"
26
26
  s.add_dependency "activesupport", ">=3.0.0"
27
27
 
28
- # Bundler will install these gems too if you've checked this out from source from git and run 'bundle install'
29
- # It will not add these as dependencies if you require lyber-core for other projects
30
- s.add_development_dependency "rspec", "< 2.0" # We're not ready to upgrade to rspec 2
31
- s.add_development_dependency 'mocha'
28
+ s.add_development_dependency "rspec"
32
29
  s.add_development_dependency 'rake'
33
30
 
34
31
 
35
- s.add_development_dependency 'yard', '0.6.5' # Yard > 0.6.5 won't generate docs.
32
+ s.add_development_dependency 'yard'#, '0.6.5' # Yard > 0.6.5 won't generate docs.
36
33
  # I don't know why & don't have time to
37
34
  # debug it right now
38
35
 
@@ -7,6 +7,7 @@ require 'timeout'
7
7
  require 'childprocess'
8
8
  require 'active_support/core_ext/hash'
9
9
  require 'erb'
10
+ require 'yaml'
10
11
 
11
12
  Dir[File.expand_path(File.join(File.dirname(__FILE__),"tasks/*.rake"))].each { |ext| load ext } if defined?(Rake)
12
13
 
@@ -16,6 +17,8 @@ class Jettywrapper
16
17
 
17
18
  include Singleton
18
19
  include Loggable
20
+ include ActiveSupport::Benchmarkable
21
+
19
22
 
20
23
  attr_accessor :jetty_home # Jetty's home directory
21
24
  attr_accessor :port # Jetty's port. Default is 8888. Note that attribute is named port, but params passed in expect :jetty_port
@@ -29,7 +32,6 @@ class Jettywrapper
29
32
  # configure the singleton with some defaults
30
33
  def initialize(params = {})
31
34
  self.base_path = self.class.app_root
32
- logger.debug 'Initializing jettywrapper'
33
35
  end
34
36
 
35
37
 
@@ -37,6 +39,62 @@ class Jettywrapper
37
39
  # Methods outside the class << self block must be called on Jettywrapper.instance, as instance methods.
38
40
  class << self
39
41
 
42
+ def url=(url)
43
+ @url = url
44
+ end
45
+
46
+ def url
47
+ @url ||= defined?(ZIP_URL) ? ZIP_URL : 'https://github.com/projecthydra/hydra-jetty/archive/new-solr-schema.zip'
48
+ @url
49
+ end
50
+
51
+ def tmp_dir=(dir)
52
+ @tmp_dir = dir
53
+ end
54
+
55
+ def tmp_dir
56
+ @tmp_dir ||= 'tmp'
57
+ end
58
+
59
+ def zip_file
60
+ File.join tmp_dir, url.split('/').last
61
+ end
62
+
63
+ def jetty_dir
64
+ 'jetty'
65
+ end
66
+
67
+ def download(url = 'https://github.com/projecthydra/hydra-jetty/archive/new-solr-schema.zip')
68
+ self.url = url
69
+ logger.info "Downloading jetty..."
70
+ FileUtils.mkdir tmp_dir unless File.exists? tmp_dir
71
+ system "curl -L #{url} -o #{zip_file}"
72
+ abort "Unable to download jetty from #{url}" unless $?.success?
73
+ end
74
+
75
+ def unzip
76
+ download unless File.exists? zip_file
77
+ logger.info "Unpacking jetty..."
78
+ tmp_save_dir = File.join tmp_dir, 'jetty_generator'
79
+ system "unzip -d #{tmp_save_dir} -qo #{zip_file}"
80
+ abort "Unable to unzip #{zip_file} into tmp_save_dir/" unless $?.success?
81
+
82
+ expanded_dir = expanded_zip_dir(tmp_save_dir)
83
+ system "mv #{expanded_dir} #{jetty_dir}"
84
+ abort "Unable to move #{expanded_dir} into #{jetty_dir}/" unless $?.success?
85
+ end
86
+
87
+ def expanded_zip_dir(tmp_save_dir)
88
+ # This old way is more specific, but won't work for blacklight-jetty
89
+ #expanded_dir = Dir[File.join(tmp_save_dir, "hydra-jetty-*")].first
90
+ Dir[File.join(tmp_save_dir, "*")].first
91
+ end
92
+
93
+ def clean
94
+ system "rm -rf #{jetty_dir}"
95
+ unzip
96
+ end
97
+
40
98
  def reset_config
41
99
  @app_root = nil
42
100
  end
@@ -146,7 +204,7 @@ class Jettywrapper
146
204
  yield
147
205
  rescue
148
206
  error = $!
149
- puts "*** Error starting jetty: #{error}"
207
+ logger.error "*** Error starting jetty: #{error}"
150
208
  ensure
151
209
  # puts "stopping jetty server"
152
210
  jetty_server.stop
@@ -261,7 +319,6 @@ class Jettywrapper
261
319
  def start
262
320
  logger.debug "Starting jetty with these values: "
263
321
  logger.debug "jetty_home: #{@jetty_home}"
264
- logger.debug "solr_home: #{@solr_home}"
265
322
  logger.debug "jetty_command: #{jetty_command.join(' ')}"
266
323
 
267
324
  # Check to see if we can start.
@@ -278,19 +335,21 @@ class Jettywrapper
278
335
  if Jettywrapper.is_port_in_use?(self.port)
279
336
  raise("Port #{self.port} is already in use.")
280
337
  end
281
- Dir.chdir(@jetty_home) do
282
- process.start
283
- end
284
- FileUtils.makedirs(pid_dir) unless File.directory?(pid_dir)
285
- begin
286
- f = File.new(pid_path, "w")
287
- rescue Errno::ENOENT, Errno::EACCES
288
- f = File.new(File.join(base_path,'tmp',pid_file),"w")
338
+ benchmark "Started jetty" do
339
+ Dir.chdir(@jetty_home) do
340
+ process.start
341
+ end
342
+ FileUtils.makedirs(pid_dir) unless File.directory?(pid_dir)
343
+ begin
344
+ f = File.new(pid_path, "w")
345
+ rescue Errno::ENOENT, Errno::EACCES
346
+ f = File.new(File.join(base_path,'tmp',pid_file),"w")
347
+ end
348
+ f.puts "#{process.pid}"
349
+ f.close
350
+ logger.debug "Wrote pid file to #{pid_path} with value #{process.pid}"
351
+ startup_wait!
289
352
  end
290
- f.puts "#{process.pid}"
291
- f.close
292
- logger.debug "Wrote pid file to #{pid_path} with value #{process.pid}"
293
- startup_wait!
294
353
  end
295
354
 
296
355
  # Wait for the jetty server to start and begin listening for requests
@@ -1 +1 @@
1
- GEMVERSION = "1.3.2"
1
+ GEMVERSION = "1.4.0"
@@ -2,6 +2,20 @@
2
2
  require 'yaml'
3
3
 
4
4
  namespace :jetty do
5
+ JETTY_DIR = 'jetty'
6
+
7
+ desc "download the jetty zip file"
8
+ task :download do
9
+ Jettywrapper.download
10
+ end
11
+
12
+ task :unzip do
13
+ Jettywrapper.unzip
14
+ end
15
+
16
+ task :clean do
17
+ Jettywrapper.clean
18
+ end
5
19
 
6
20
  desc "Return the status of jetty"
7
21
  task :status => :environment do
@@ -9,12 +9,14 @@ module Hydra
9
9
  context "integration" do
10
10
  before(:all) do
11
11
  $stderr.reopen("/dev/null", "w")
12
+ Jettywrapper.logger.level=3
12
13
  end
13
14
 
14
15
  it "starts" do
15
16
  jetty_params = {
16
17
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
17
- :startup_wait => 30,
18
+ :startup_wait => 45,
19
+ :java_opts => ["-Xmx256m", '-XX:MaxPermSize=256m'],
18
20
  :jetty_port => TEST_JETTY_PORTS.first
19
21
  }
20
22
  Jettywrapper.configure(jetty_params)
@@ -28,7 +30,7 @@ module Hydra
28
30
 
29
31
  # Can we connect to solr?
30
32
  require 'net/http'
31
- response = Net::HTTP.get_response(URI.parse("http://localhost:#{jetty_params[:jetty_port]}/solr/development/admin/"))
33
+ response = Net::HTTP.get_response(URI.parse("http://localhost:#{jetty_params[:jetty_port]}/solr/"))
32
34
  response.code.should eql("200")
33
35
  ts.stop
34
36
 
@@ -37,7 +39,8 @@ module Hydra
37
39
  it "won't start if it's already running" do
38
40
  jetty_params = {
39
41
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
40
- :startup_wait => 30,
42
+ :startup_wait => 45,
43
+ :java_opts => ["-Xmx256m", '-XX:MaxPermSize=256m'],
41
44
  :jetty_port => TEST_JETTY_PORTS.first
42
45
  }
43
46
  Jettywrapper.configure(jetty_params)
@@ -46,24 +49,27 @@ module Hydra
46
49
  ts.stop
47
50
  ts.start
48
51
  ts.logger.debug "Jetty started from rspec at #{ts.pid}"
49
- response = Net::HTTP.get_response(URI.parse("http://localhost:#{jetty_params[:jetty_port]}/solr/development/admin/"))
52
+ response = Net::HTTP.get_response(URI.parse("http://localhost:#{jetty_params[:jetty_port]}/solr/"))
50
53
  response.code.should eql("200")
51
54
  lambda { ts.start }.should raise_exception(/Server is already running/)
52
55
  ts.stop
53
56
  end
54
57
 
55
- it "can check to see whether a port is already in use" do
56
- jetty_params = {
57
- :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
58
- :jetty_port => TEST_JETTY_PORTS.last,
59
- :startup_wait => 30
60
- }
61
- Jettywrapper.stop(jetty_params)
62
- sleep 10
63
- Jettywrapper.is_port_in_use?(jetty_params[:jetty_port]).should eql(false)
64
- Jettywrapper.start(jetty_params)
65
- Jettywrapper.is_port_in_use?(jetty_params[:jetty_port]).should eql(true)
66
- Jettywrapper.stop(jetty_params)
58
+ describe "is_port_in_use?" do
59
+ describe "when a server is running on the port" do
60
+ before do
61
+ @s = TCPServer.new('127.0.0.1', TEST_JETTY_PORTS.last)
62
+ end
63
+ after do
64
+ @s.close
65
+ end
66
+ it "can check to see whether a port is already in use" do
67
+ Jettywrapper.is_port_in_use?(TEST_JETTY_PORTS.last).should eql(true)
68
+ end
69
+ end
70
+ it "should be false when nothing is running" do
71
+ Jettywrapper.is_port_in_use?(TEST_JETTY_PORTS.last).should eql(false)
72
+ end
67
73
  end
68
74
 
69
75
  it "raises an error if you try to start a jetty that is already running" do
@@ -86,7 +92,7 @@ module Hydra
86
92
  :jetty_port => TEST_JETTY_PORTS.first,
87
93
  :startup_wait => 30
88
94
  }
89
- socket = TCPServer.new(TEST_JETTY_PORTS.first)
95
+ socket = TCPServer.new(TEST_JETTY_PORTS.first)
90
96
  begin
91
97
  ts = Jettywrapper.configure(jetty_params)
92
98
  ts.stop
@@ -11,9 +11,98 @@ require 'rubygems'
11
11
  :jetty_port => TEST_JETTY_PORTS.first,
12
12
  :solr_home => "/path/to/solr",
13
13
  :startup_wait => 0,
14
- :java_opts => ["-Xmx256mb"],
14
+ :java_opts => ["-Xmx256m"],
15
15
  :jetty_opts => ["/path/to/jetty_xml", "/path/to/other_jetty_xml"]
16
16
  }
17
+
18
+ Jettywrapper.logger.level=3
19
+ end
20
+
21
+ context "downloading" do
22
+ context "with default file" do
23
+ it "should download the zip file" do
24
+ Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/new-solr-schema.zip -o tmp/new-solr-schema.zip').and_return(system ('true'))
25
+ Jettywrapper.download
26
+ end
27
+ end
28
+
29
+ context "specifying the file" do
30
+ it "should download the zip file" do
31
+ Jettywrapper.should_receive(:system).with('curl -L http://example.co/file.zip -o tmp/file.zip').and_return(system ('true'))
32
+ Jettywrapper.download('http://example.co/file.zip')
33
+ Jettywrapper.url.should == 'http://example.co/file.zip'
34
+ end
35
+ end
36
+ end
37
+
38
+ context "unzip" do
39
+ before do
40
+ Jettywrapper.url = nil
41
+ end
42
+ context "with default file" do
43
+ it "should download the zip file" do
44
+ File.should_receive(:exists?).and_return(true)
45
+ Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/hydra-jetty-new-solr-schema')
46
+ Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/new-solr-schema.zip').and_return(system ('true'))
47
+ Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/hydra-jetty-new-solr-schema jetty').and_return(system ('true'))
48
+ Jettywrapper.unzip
49
+ end
50
+ end
51
+
52
+ context "specifying the file" do
53
+ before do
54
+ Jettywrapper.url = 'http://example.co/file.zip'
55
+ end
56
+ it "should download the zip file" do
57
+ File.should_receive(:exists?).and_return(true)
58
+ Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/interal_dir')
59
+ Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/file.zip').and_return(system ('true'))
60
+ Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/interal_dir jetty').and_return(system ('true'))
61
+ Jettywrapper.unzip
62
+ end
63
+ end
64
+ end
65
+
66
+ context ".url" do
67
+ before do
68
+ subject.url = nil
69
+ end
70
+ subject {Jettywrapper}
71
+ context "When a constant is set" do
72
+ before do
73
+ ZIP_URL = 'http://example.com/foo.zip'
74
+ end
75
+ after do
76
+ Object.send(:remove_const, :ZIP_URL)
77
+ end
78
+ its(:url) {should == 'http://example.com/foo.zip'}
79
+ end
80
+ context "when a url is set" do
81
+ before do
82
+ subject.url = 'http://example.com/bar.zip'
83
+ end
84
+ its(:url) {should == 'http://example.com/bar.zip'}
85
+ end
86
+ context "when url is not set" do
87
+ its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/new-solr-schema.zip'}
88
+ end
89
+ end
90
+
91
+ context ".tmp_dir" do
92
+ subject {Jettywrapper}
93
+ context "when a dir is set" do
94
+ before do
95
+ subject.tmp_dir = '/opt/tmp'
96
+ end
97
+ its(:tmp_dir) {should == '/opt/tmp'}
98
+ end
99
+ context "when dir is not set" do
100
+ before do
101
+ subject.tmp_dir = nil
102
+ end
103
+ its(:tmp_dir) {should == 'tmp'}
104
+ end
105
+
17
106
  end
18
107
 
19
108
  context "app_root" do
@@ -50,33 +139,32 @@ require 'rubygems'
50
139
 
51
140
  context "config" do
52
141
  it "loads the application jetty.yml first" do
53
- IO.expects(:read).with('./config/jetty.yml').once.returns("default:\n")
142
+ IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n")
54
143
  config = Jettywrapper.load_config
55
144
  end
56
145
 
57
146
  it "loads the application jetty.yml using erb parsing" do
58
- IO.expects(:read).with('./config/jetty.yml').once.returns("default:\n a: <%= 123 %>")
147
+ IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: <%= 123 %>")
59
148
  config = Jettywrapper.load_config
60
149
  config[:a] == 123
61
150
  end
62
151
 
63
152
  it "falls back on the distributed jetty.yml" do
64
- fallback_seq = sequence('fallback sequence')
65
- File.expects(:exists?).in_sequence(fallback_seq).with('./config/jetty.yml').returns(false)
66
- IO.expects(:read).in_sequence(fallback_seq).with { |value| value =~ /jetty.yml/ }.returns("default:\n")
153
+ File.should_receive(:exists?).with('./config/jetty.yml').and_return(false)
154
+ IO.should_receive(:read).with { |value| value =~ /jetty.yml/ }.and_return("default:\n")
67
155
  config = Jettywrapper.load_config
68
156
  end
69
157
 
70
158
  it "supports per-environment configuration" do
71
159
  ENV['environment'] = 'test'
72
- IO.expects(:read).with('./config/jetty.yml').once.returns("default:\n a: 1\ntest:\n a: 2")
160
+ IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1\ntest:\n a: 2")
73
161
  config = Jettywrapper.load_config
74
162
  config[:a].should == 2
75
163
  end
76
164
 
77
165
  it "falls back on a 'default' environment configuration" do
78
166
  ENV['environment'] = 'test'
79
- IO.expects(:read).with('./config/jetty.yml').once.returns("default:\n a: 1")
167
+ IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1")
80
168
  config = Jettywrapper.load_config
81
169
  config[:a].should == 1
82
170
  end
@@ -127,7 +215,7 @@ require 'rubygems'
127
215
  command = ts.jetty_command
128
216
  command.should include("-Dsolr.solr.home=#{@jetty_params[:solr_home]}")
129
217
  command.should include("-Djetty.port=#{@jetty_params[:jetty_port]}")
130
- command.should include("-Xmx256mb")
218
+ command.should include("-Xmx256m")
131
219
  command.should include("start.jar")
132
220
  command.slice(command.index('start.jar')+1, 2).should == @jetty_params[:jetty_opts]
133
221
  end
@@ -143,7 +231,7 @@ require 'rubygems'
143
231
  :jetty_home => '/tmp'
144
232
  }
145
233
  ts = Jettywrapper.configure(jetty_params)
146
- Jettywrapper.any_instance.stubs(:process).returns(stub('proc', :start => nil, :pid=>5454))
234
+ Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>5454))
147
235
  ts.stop
148
236
  ts.start
149
237
  ts.pid.should eql(5454)
@@ -156,21 +244,19 @@ require 'rubygems'
156
244
  }
157
245
  ts = Jettywrapper.configure(jetty_params)
158
246
  ts.stop
159
- Jettywrapper.any_instance.stubs(:process).returns(stub('proc', :start => nil, :pid=>2323))
247
+ Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>2323))
160
248
  swp = Jettywrapper.start(jetty_params)
161
249
  swp.pid.should eql(2323)
162
250
  swp.pid_file.should eql("_tmp.pid")
163
251
  swp.stop
164
252
  end
165
253
 
166
- it "checks to see if its pid files are stale" do
167
- @pending
168
- end
254
+ it "checks to see if its pid files are stale"
169
255
 
170
256
  # return true if it's running, otherwise return false
171
257
  it "can get the status for a given jetty instance" do
172
258
  # Don't actually start jetty, just fake it
173
- Jettywrapper.any_instance.stubs(:process).returns(stub('proc', :start => nil, :pid=>12345))
259
+ Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>12345))
174
260
 
175
261
  jetty_params = {
176
262
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
@@ -184,7 +270,7 @@ require 'rubygems'
184
270
 
185
271
  it "can get the pid for a given jetty instance" do
186
272
  # Don't actually start jetty, just fake it
187
- Jettywrapper.any_instance.stubs(:process).returns(stub('proc', :start => nil, :pid=>54321))
273
+ Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>54321))
188
274
  jetty_params = {
189
275
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
190
276
  }
@@ -199,7 +285,7 @@ require 'rubygems'
199
285
  jetty_params = {
200
286
  :jetty_home => '/tmp', :jetty_port => 8777
201
287
  }
202
- Jettywrapper.any_instance.stubs(:process).returns(stub('proc', :start => nil, :pid=>2323))
288
+ Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>2323))
203
289
  swp = Jettywrapper.start(jetty_params)
204
290
  (File.file? swp.pid_path).should eql(true)
205
291
 
@@ -222,7 +308,7 @@ require 'rubygems'
222
308
  :jetty_home => '/tmp'
223
309
  }
224
310
  ts = Jettywrapper.configure(jetty_params)
225
- Jettywrapper.any_instance.stubs(:process).returns(stub('proc', :start => nil, :pid=>2222))
311
+ Jettywrapper.any_instance.stub(:process).and_return(stub('proc', :start => nil, :pid=>2222))
226
312
  ts.stop
227
313
  ts.pid_file?.should eql(false)
228
314
  ts.start
@@ -244,16 +330,16 @@ require 'rubygems'
244
330
 
245
331
  context "wrapping a task" do
246
332
  it "wraps another method" do
247
- Jettywrapper.any_instance.stubs(:start).returns(true)
248
- Jettywrapper.any_instance.stubs(:stop).returns(true)
333
+ Jettywrapper.any_instance.stub(:start).and_return(true)
334
+ Jettywrapper.any_instance.stub(:stop).and_return(true)
249
335
  error = Jettywrapper.wrap(@jetty_params) do
250
336
  end
251
337
  error.should eql(false)
252
338
  end
253
339
 
254
340
  it "configures itself correctly when invoked via the wrap method" do
255
- Jettywrapper.any_instance.stubs(:start).returns(true)
256
- Jettywrapper.any_instance.stubs(:stop).returns(true)
341
+ Jettywrapper.any_instance.stub(:start).and_return(true)
342
+ Jettywrapper.any_instance.stub(:stop).and_return(true)
257
343
  error = Jettywrapper.wrap(@jetty_params) do
258
344
  ts = Jettywrapper.instance
259
345
  ts.quiet.should == @jetty_params[:quiet]
@@ -266,8 +352,9 @@ require 'rubygems'
266
352
  end
267
353
 
268
354
  it "captures any errors produced" do
269
- Jettywrapper.any_instance.stubs(:start).returns(true)
270
- Jettywrapper.any_instance.stubs(:stop).returns(true)
355
+ Jettywrapper.any_instance.stub(:start).and_return(true)
356
+ Jettywrapper.any_instance.stub(:stop).and_return(true)
357
+ Jettywrapper.instance.logger.should_receive(:error).with("*** Error starting jetty: this is an expected error message")
271
358
  expect { error = Jettywrapper.wrap(@jetty_params) do
272
359
  raise "this is an expected error message"
273
360
  end }.to raise_error "this is an expected error message"
@@ -8,12 +8,10 @@ if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
8
8
  SimpleCov.start
9
9
  end
10
10
 
11
- require 'spec/autorun'
12
- # require 'spec/rails'
11
+ require 'rspec/autorun'
13
12
  require 'jettywrapper'
14
13
 
15
- Spec::Runner.configure do |config|
16
- config.mock_with :mocha
14
+ RSpec.configure do |config|
17
15
  end
18
16
 
19
17
  unless ENV.select { |k,v| k =~ /TEST_JETTY_PORT/ }.empty?
metadata CHANGED
@@ -1,182 +1,154 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jettywrapper
3
- version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease:
6
- segments:
7
- - 1
8
- - 3
9
- - 2
10
- version: 1.3.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Chris Beer
14
8
  - Justin Coyne
15
9
  - Bess Sadler
16
10
  autorequire:
17
11
  bindir: bin
18
12
  cert_chain: []
19
-
20
- date: 2012-07-25 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
23
- type: :runtime
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
34
- version_requirements: *id001
13
+ date: 2013-03-08 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
35
16
  name: logger
36
- - !ruby/object:Gem::Dependency
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
37
22
  type: :runtime
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
48
- version_requirements: *id002
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
49
30
  name: mediashelf-loggable
50
- - !ruby/object:Gem::Dependency
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
51
36
  type: :runtime
52
37
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
62
- version_requirements: *id003
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
63
44
  name: childprocess
64
- - !ruby/object:Gem::Dependency
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
65
50
  type: :runtime
66
51
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- version_requirements: *id004
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
77
58
  name: i18n
78
- - !ruby/object:Gem::Dependency
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
79
64
  type: :runtime
80
65
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 7
87
- segments:
88
- - 3
89
- - 0
90
- - 0
91
- version: 3.0.0
92
- version_requirements: *id005
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
93
72
  name: activesupport
94
- - !ruby/object:Gem::Dependency
95
- type: :development
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.0.0
78
+ type: :runtime
96
79
  prerelease: false
97
- requirement: &id006 !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - <
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 2
105
- - 0
106
- version: "2.0"
107
- version_requirements: *id006
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: 3.0.0
85
+ - !ruby/object:Gem::Dependency
108
86
  name: rspec
109
- - !ruby/object:Gem::Dependency
110
- type: :development
111
- prerelease: false
112
- requirement: &id007 !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 3
118
- segments:
119
- - 0
120
- version: "0"
121
- version_requirements: *id007
122
- name: mocha
123
- - !ruby/object:Gem::Dependency
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
124
92
  type: :development
125
93
  prerelease: false
126
- requirement: &id008 !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
- version: "0"
135
- version_requirements: *id008
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ - !ruby/object:Gem::Dependency
136
100
  name: rake
137
- - !ruby/object:Gem::Dependency
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
138
106
  type: :development
139
107
  prerelease: false
140
- requirement: &id009 !ruby/object:Gem::Requirement
141
- none: false
142
- requirements:
143
- - - "="
144
- - !ruby/object:Gem::Version
145
- hash: 13
146
- segments:
147
- - 0
148
- - 6
149
- - 5
150
- version: 0.6.5
151
- version_requirements: *id009
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ - !ruby/object:Gem::Dependency
152
114
  name: yard
153
- - !ruby/object:Gem::Dependency
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
154
120
  type: :development
155
121
  prerelease: false
156
- requirement: &id010 !ruby/object:Gem::Requirement
157
- none: false
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- hash: 3
162
- segments:
163
- - 0
164
- version: "0"
165
- version_requirements: *id010
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ - !ruby/object:Gem::Dependency
166
128
  name: RedCloth
167
- description: Spin up a jetty instance (e.g., the one at https://github.com/projecthydra/hydra-jetty) and wrap test in it. This lets us run tests against a real copy of solr and fedora.
168
- email:
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ description: Spin up a jetty instance (e.g., the one at https://github.com/projecthydra/hydra-jetty)
142
+ and wrap test in it. This lets us run tests against a real copy of solr and fedora.
143
+ email:
169
144
  - hydra-tech@googlegroups.com
170
145
  executables: []
171
-
172
146
  extensions: []
173
-
174
147
  extra_rdoc_files: []
175
-
176
- files:
148
+ files:
177
149
  - .gitignore
178
150
  - .gitmodules
179
- - .rvmrc
151
+ - .travis.yml
180
152
  - Gemfile
181
153
  - History.txt
182
154
  - README.textile
@@ -193,38 +165,26 @@ files:
193
165
  - tasks/jettywrapper.rake
194
166
  homepage: https://github.com/projecthydra/jettywrapper
195
167
  licenses: []
196
-
168
+ metadata: {}
197
169
  post_install_message:
198
170
  rdoc_options: []
199
-
200
- require_paths:
171
+ require_paths:
201
172
  - lib
202
- required_ruby_version: !ruby/object:Gem::Requirement
203
- none: false
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- hash: 3
208
- segments:
209
- - 0
210
- version: "0"
211
- required_rubygems_version: !ruby/object:Gem::Requirement
212
- none: false
213
- requirements:
214
- - - ">="
215
- - !ruby/object:Gem::Version
216
- hash: 23
217
- segments:
218
- - 1
219
- - 3
220
- - 6
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - '>='
181
+ - !ruby/object:Gem::Version
221
182
  version: 1.3.6
222
183
  requirements: []
223
-
224
184
  rubyforge_project:
225
- rubygems_version: 1.8.15
185
+ rubygems_version: 2.0.0
226
186
  signing_key:
227
- specification_version: 3
187
+ specification_version: 4
228
188
  summary: Convenience tasks for working with jetty from within a ruby project.
229
189
  test_files: []
230
-
190
+ has_rdoc:
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use ree-1.8.7@jettywrapper --create