blacklight 3.0pre1 → 3.0pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +0 -6
- data/README.rdoc +94 -87
- data/blacklight.gemspec +1 -1
- data/config/routes.rb +1 -1
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/catalog.rb +10 -12
- data/lib/blacklight/controller.rb +2 -2
- data/lib/blacklight/engine.rb +5 -2
- data/lib/blacklight/solr/document.rb +1 -1
- data/lib/blacklight/solr/document/marc.rb +1 -16
- data/lib/blacklight/solr_helper.rb +43 -14
- data/lib/blacklight/version.rb +1 -1
- data/lib/generators/blacklight/assets_generator.rb +25 -0
- data/lib/generators/blacklight/blacklight_generator.rb +16 -1
- data/lib/generators/blacklight/jetty_generator.rb +101 -0
- data/lib/generators/blacklight/solr_conf_generator.rb +25 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +0 -1
- data/lib/generators/blacklight/templates/config/solr.yml +14 -2
- data/lib/generators/blacklight/templates/public/images/{blacklight/bg.png → bg.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/border.png → border.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/bul_sq_gry.gif → bul_sq_gry.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/checkmark.gif → checkmark.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/logo.png → logo.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/magnifying_glass.gif → magnifying_glass.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/remove.gif → remove.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/separator.gif → separator.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/start_over.gif → start_over.gif} +0 -0
- data/lib/generators/blacklight/templates/public/javascripts/blacklight.js +5 -0
- data/lib/generators/blacklight/templates/public/stylesheets/blacklight.css +9 -3
- data/lib/generators/blacklight/templates/solr_conf/schema.xml +339 -0
- data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +578 -0
- data/lib/railties/all_tests.rake +11 -0
- data/lib/railties/blacklight.rake +0 -52
- data/lib/railties/blacklight_cucumber.rake +125 -0
- data/lib/railties/blacklight_rspec.rake +128 -0
- data/lib/railties/{test_solr_server.rb → jetty_solr_server.rb} +22 -45
- data/lib/railties/solr_marc.rake +24 -5
- data/test_support/.rspec +1 -0
- data/test_support/data/test_data.utf8.mrc +1 -0
- data/test_support/features/bookmarks.feature +88 -0
- data/test_support/features/did_you_mean.feature +129 -0
- data/test_support/features/folder.feature +67 -0
- data/test_support/features/librarian_view.feature +17 -0
- data/test_support/features/record_view.feature +34 -0
- data/test_support/features/saved_searches.feature +49 -0
- data/test_support/features/search.feature +86 -0
- data/test_support/features/search_filters.feature +121 -0
- data/test_support/features/search_history.feature +95 -0
- data/test_support/features/search_results.feature +61 -0
- data/test_support/features/search_sort.feature +29 -0
- data/test_support/features/step_definitions/bookmarks_steps.rb +5 -0
- data/test_support/features/step_definitions/error_steps.rb +4 -0
- data/test_support/features/step_definitions/folder_steps.rb +26 -0
- data/test_support/features/step_definitions/general_steps.rb +49 -0
- data/test_support/features/step_definitions/record_view_steps.rb +11 -0
- data/test_support/features/step_definitions/saved_searches_steps.rb +21 -0
- data/test_support/features/step_definitions/search_facets_steps.rb +28 -0
- data/test_support/features/step_definitions/search_history_steps.rb +8 -0
- data/test_support/features/step_definitions/search_result_steps.rb +113 -0
- data/test_support/features/step_definitions/search_steps.rb +102 -0
- data/test_support/features/step_definitions/user_steps.rb +4 -0
- data/test_support/features/step_definitions/web_steps.rb +211 -0
- data/test_support/features/support/env.rb +49 -0
- data/test_support/features/support/paths.rb +55 -0
- data/test_support/features/support/selectors.rb +39 -0
- data/test_support/features/unapi.feature +30 -0
- data/test_support/spec/controllers/application_controller_spec.rb +22 -0
- data/test_support/spec/controllers/catalog_controller_spec.rb +480 -0
- data/test_support/spec/controllers/folder_controller_spec.rb +40 -0
- data/test_support/spec/controllers/search_history_controller_spec.rb +45 -0
- data/test_support/spec/data/sample_docs.yml +655 -0
- data/test_support/spec/data/test_data.utf8.mrc +1 -0
- data/test_support/spec/helpers/blacklight_helper_spec.rb +482 -0
- data/test_support/spec/helpers/hash_as_hidden_fields_spec.rb +23 -0
- data/test_support/spec/helpers/render_constraints_helper_spec.rb +64 -0
- data/test_support/spec/helpers/search_history_helper_spec.rb +11 -0
- data/test_support/spec/helpers/solr_helper_spec.rb +873 -0
- data/test_support/spec/lib/blacklight_email_spec.rb +23 -0
- data/test_support/spec/lib/blacklight_sms_spec.rb +23 -0
- data/test_support/spec/lib/blacklight_solr_document_dublin_core_spec.rb +41 -0
- data/test_support/spec/lib/blacklight_solr_document_marc_spec.rb +88 -0
- data/test_support/spec/lib/blacklight_solr_document_spec.rb +173 -0
- data/test_support/spec/lib/blacklight_spec.rb +39 -0
- data/test_support/spec/lib/configurable_spec.rb +97 -0
- data/test_support/spec/lib/facet_paginator_spec.rb +93 -0
- data/test_support/spec/lib/marc_export_spec.rb +444 -0
- data/test_support/spec/lib/search_fields_spec.rb +105 -0
- data/test_support/spec/lib/tasks/blacklight_task_spec.rb +21 -0
- data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +59 -0
- data/test_support/spec/models/bookmark_spec.rb +37 -0
- data/test_support/spec/models/record_mailer_spec.rb +67 -0
- data/test_support/spec/models/search_spec.rb +55 -0
- data/test_support/spec/models/solr_docment_spec.rb +111 -0
- data/test_support/spec/rcov.opts +3 -0
- data/test_support/spec/spec.opts +4 -0
- data/test_support/spec/spec_helper.rb +38 -0
- data/test_support/spec/support/action_controller.rb +42 -0
- data/test_support/spec/support/assert_difference.rb +16 -0
- data/test_support/spec/support/include_text.rb +20 -0
- data/test_support/spec/views/catalog/_constraints_element.html.erb_spec.rb +59 -0
- data/test_support/spec/views/catalog/_document_list.html.erb_spec.rb +8 -0
- data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +182 -0
- data/test_support/spec/views/catalog/_index_partials/_default.erb_spec.rb +70 -0
- data/test_support/spec/views/catalog/_show_partials/_default.html.erb_spec.rb +70 -0
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +141 -0
- data/test_support/spec/views/catalog/show.html.erb_spec.rb +100 -0
- data/test_support/spec/views/catalog/unapi.xml.builder_spec.rb +45 -0
- metadata +95 -98
- data/lib/blacklight/marc.rb +0 -46
- data/lib/blacklight/marc/citation.rb +0 -251
- data/lib/railties/cucumber.rake +0 -53
- data/lib/railties/rspec.rake +0 -188
- data/spec/helpers/catalog_helper_spec.rb +0 -111
- data/spec/views/catalog/_sms_form.html.erb_spec.rb +0 -19
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :blacklight do
|
2
|
+
desc "Run Blacklight cucumber and rspec"
|
3
|
+
task :all_tests => ['blacklight:spec:with_solr', 'blacklight:cucumber:with_solr']
|
4
|
+
|
5
|
+
namespace :all_tests do
|
6
|
+
desc "Run Blacklight rspec and cucumber tests with rcov"
|
7
|
+
rm "blacklight-coverage.data" if File.exist?("blacklight-coverage.data")
|
8
|
+
task :rcov => ['blacklight:spec:rcov', 'blacklight:cucumber:rcov']
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
@@ -11,56 +11,4 @@ namespace :blacklight do
|
|
11
11
|
|
12
12
|
end
|
13
13
|
|
14
|
-
# Rake tasks for Blacklight plugin
|
15
|
-
|
16
|
-
# if you would like to see solr startup messages on STDERR
|
17
|
-
# when starting solr test server during functional tests use:
|
18
|
-
#
|
19
|
-
# rake SOLR_CONSOLE=true
|
20
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'test_solr_server.rb'))
|
21
|
-
|
22
|
-
|
23
|
-
SOLR_PARAMS = {
|
24
|
-
:quiet => ENV['SOLR_CONSOLE'] ? false : true,
|
25
|
-
:jetty_home => ENV['SOLR_JETTY_HOME'] || File.expand_path('./jetty'),
|
26
|
-
:jetty_port => ENV['SOLR_JETTY_PORT'] || 8888,
|
27
|
-
:solr_home => ENV['SOLR_HOME'] || File.expand_path('./jetty/solr')
|
28
|
-
}
|
29
|
-
|
30
|
-
NO_JETTY_MSG = "In order to use solr:spec, you much checkout Blacklight-jetty from our github repository, and place it in the root of your application under the directory /jetty. \n prompt> git clone git@github.com:projectblacklight/blacklight-jetty.git jetty \n You will also need to pupulate your test instance of solr with test data. You can do this with: \n prompt> rake solr:marc:index_test_data RAILS_ENV=test"
|
31
|
-
|
32
|
-
namespace :solr do
|
33
|
-
|
34
|
-
desc "Calls RSpec Examples wrapped in the test instance of Solr"
|
35
|
-
task :spec do
|
36
|
-
raise NO_JETTY_MSG unless File.exists? SOLR_PARAMS[:jetty_home]
|
37
|
-
# wrap tests with a test-specific Solr server
|
38
|
-
error = TestSolrServer.wrap(SOLR_PARAMS) do
|
39
|
-
rm_f "coverage.data"
|
40
|
-
Rake::Task["rake:spec"].invoke
|
41
|
-
#puts `ps aux | grep start.jar`
|
42
|
-
end
|
43
|
-
raise "test failures: #{error}" if error
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "Calls Cucumber Features wrapped in the test instance of Solr"
|
47
|
-
task :features do
|
48
|
-
# wrap tests with a test-specific Solr server
|
49
|
-
error = TestSolrServer.wrap(SOLR_PARAMS) do
|
50
|
-
Rake::Task["cucumber:all"].invoke
|
51
|
-
#puts `ps aux | grep start.jar`
|
52
|
-
end
|
53
|
-
raise "test failures: #{error}" if error
|
54
|
-
end
|
55
|
-
|
56
|
-
desc "Runs all features and specs"
|
57
|
-
task :all do
|
58
|
-
error = TestSolrServer.wrap(SOLR_PARAMS) do
|
59
|
-
Rake::Task["rake:spec"].invoke
|
60
|
-
Rake::Task["cucumber:all"].invoke
|
61
|
-
end
|
62
|
-
raise "test failures: #{error}" if error
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
14
|
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
# Blacklight customization, trick Cucumber into looking in our current
|
8
|
+
# location for Rails.root, even though we're going to give it features
|
9
|
+
# from elsewhere.
|
10
|
+
ENV['RAILS_ROOT'] = Rails.root
|
11
|
+
|
12
|
+
# blacklight_features, where to find features inside blacklight source?
|
13
|
+
blacklight_features = File.expand_path("./test_support/features", Blacklight.root)
|
14
|
+
|
15
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
16
|
+
|
17
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
18
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
19
|
+
|
20
|
+
begin
|
21
|
+
require 'cucumber/rake/task'
|
22
|
+
|
23
|
+
namespace :blacklight do
|
24
|
+
namespace :cucumber do
|
25
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
26
|
+
# Blacklight customization, call features from external location, pass
|
27
|
+
# in feature location wtih cucumber_opts, yeah it's weird but that's how.
|
28
|
+
t.cucumber_opts = blacklight_features
|
29
|
+
|
30
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'default'
|
33
|
+
end
|
34
|
+
|
35
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
36
|
+
# Blacklight customization, call features from external location, pass
|
37
|
+
# in feature location wtih cucumber_opts, yeah it's weird but that's how.
|
38
|
+
t.cucumber_opts = blacklight_features
|
39
|
+
|
40
|
+
|
41
|
+
t.binary = vendored_cucumber_bin
|
42
|
+
t.fork = true # You may get faster startup if you set this to false
|
43
|
+
t.profile = 'wip'
|
44
|
+
end
|
45
|
+
|
46
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
47
|
+
# Blacklight customization, call features from external location, pass
|
48
|
+
# in feature location wtih cucumber_opts, yeah it's weird but that's how.
|
49
|
+
t.cucumber_opts = blacklight_features
|
50
|
+
|
51
|
+
t.binary = vendored_cucumber_bin
|
52
|
+
t.fork = true # You may get faster startup if you set this to false
|
53
|
+
t.profile = 'rerun'
|
54
|
+
end
|
55
|
+
|
56
|
+
Cucumber::Rake::Task.new({:rcov => 'db:test:prepare'}, 'Run features with rcov') do |t|
|
57
|
+
# Blacklight customization, call features from external location, pass
|
58
|
+
# in feature location wtih cucumber_opts, yeah it's weird but that's how.
|
59
|
+
t.cucumber_opts = blacklight_features
|
60
|
+
|
61
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
62
|
+
t.fork = true # You may get faster startup if you set this to false
|
63
|
+
t.profile = 'default'
|
64
|
+
t.rcov = true
|
65
|
+
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/ --aggregate blacklight-coverage.data}
|
66
|
+
t.rcov_opts << %[-o "blacklight-coverage"]
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
desc 'Run all features'
|
71
|
+
task :all => [:ok, :wip]
|
72
|
+
|
73
|
+
|
74
|
+
# Solr wrapper. for now just for blacklight:cucumber, plan to
|
75
|
+
# provide it for all variants eventually.
|
76
|
+
# if you would like to see solr startup messages on STDERR
|
77
|
+
# when starting solr test server during functional tests use:
|
78
|
+
#
|
79
|
+
# rake SOLR_CONSOLE=true
|
80
|
+
require File.expand_path('../jetty_solr_server.rb', __FILE__)
|
81
|
+
desc "blacklight:cucumber with jetty/solr launch"
|
82
|
+
task :with_solr do
|
83
|
+
# wrap tests with a test-specific Solr server
|
84
|
+
# Need to look up where the test jetty is located
|
85
|
+
# from solr.yml, we don't hardcode it anymore.
|
86
|
+
|
87
|
+
solr_yml_path = locate_path("config", "solr.yml")
|
88
|
+
jetty_path = if ( File.exists?( solr_yml_path ))
|
89
|
+
solr_config = YAML::load(File.open(solr_yml_path))
|
90
|
+
solr_config["test"]["jetty_path"] if solr_config["test"]
|
91
|
+
end
|
92
|
+
raise Exception.new("Can't find jetty path to start test jetty. Expect a jetty_path key in config/solr.yml for test environment.") unless jetty_path
|
93
|
+
|
94
|
+
JettySolrServer.new(
|
95
|
+
:jetty_home => File.expand_path(jetty_path, Rails.root),
|
96
|
+
:sleep_after_start => 2).wrap do
|
97
|
+
Rake::Task["blacklight:cucumber"].invoke
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'Alias for blacklight:cucumber:ok'
|
104
|
+
task :cucumber => 'blacklight:cucumber:ok'
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
task :features => :cucumber do
|
112
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
113
|
+
end
|
114
|
+
|
115
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
116
|
+
task 'db:test:prepare' do
|
117
|
+
end
|
118
|
+
rescue LoadError
|
119
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
120
|
+
task :cucumber do
|
121
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# Blacklight customization of the Rake tasks that come with rspec-2, to run
|
2
|
+
# specs located in alternate location (inside BL plugin), and to provide
|
3
|
+
# rake tasks for jetty/solr wrapping.
|
4
|
+
#
|
5
|
+
# Same tasks as in ordinary rspec, but prefixed with blacklight:.
|
6
|
+
#
|
7
|
+
# rspec2 keeps it's rake tasks inside it's own code, it doesn't generate them.
|
8
|
+
# We had to copy them from there and modify, may have to be done again
|
9
|
+
# if rspec2 changes a lot, but this code looks relatively cleanish.
|
10
|
+
begin
|
11
|
+
require 'rspec/core'
|
12
|
+
require 'rspec/core/rake_task'
|
13
|
+
Rake.application.instance_variable_get('@tasks')['default'].prerequisites.delete('test')
|
14
|
+
|
15
|
+
spec_prereq = Rails.configuration.generators.options[:rails][:orm] == :active_record ? "db:test:prepare" : :noop
|
16
|
+
task :noop do; end
|
17
|
+
#task :default => :spec
|
18
|
+
|
19
|
+
blacklight_spec = File.expand_path("./test_support/spec", Blacklight.root)
|
20
|
+
|
21
|
+
# Set env variable to tell our spec/spec_helper.rb where we really are,
|
22
|
+
# so it doesn't have to guess with relative path, which will be wrong
|
23
|
+
# since we allow spec_dir to be in a remote location. spec_helper.rb
|
24
|
+
# needs it before Rails.root is defined there, even though we can
|
25
|
+
# oddly get it here, i dunno.
|
26
|
+
ENV['RAILS_ROOT'] = Rails.root
|
27
|
+
|
28
|
+
namespace :blacklight do
|
29
|
+
|
30
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
31
|
+
RSpec::Core::RakeTask.new(:spec => spec_prereq) do |t|
|
32
|
+
# the user might not have run rspec generator because they don't
|
33
|
+
# actually need it, but without an ./.rspec they won't get color,
|
34
|
+
# let's insist.
|
35
|
+
t.rspec_opts = "--colour"
|
36
|
+
|
37
|
+
# pattern directory name defaults to ./**/*_spec.rb, but has a more concise command line echo
|
38
|
+
t.pattern = "#{blacklight_spec}"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Don't understand what this does or how to make it use our remote stats_directory
|
42
|
+
#task :stats => "spec:statsetup"
|
43
|
+
|
44
|
+
namespace :spec do
|
45
|
+
[:requests, :models, :controllers, :views, :helpers, :mailers, :lib, :routing].each do |sub|
|
46
|
+
desc "Run the code examples in spec/#{sub}"
|
47
|
+
RSpec::Core::RakeTask.new(sub => spec_prereq) do |t|
|
48
|
+
# the user might not have run rspec generator because they don't
|
49
|
+
# actually need it, but without an ./.rspec they won't get color,
|
50
|
+
# let's insist.
|
51
|
+
t.rspec_opts = "--colour"
|
52
|
+
|
53
|
+
# pattern directory name defaults to ./**/*_spec.rb, but has a more concise command line echo
|
54
|
+
t.pattern = "#{blacklight_spec}/#{sub}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Run all specs with rcov"
|
59
|
+
RSpec::Core::RakeTask.new(:rcov => spec_prereq) do |t|
|
60
|
+
t.rcov = true
|
61
|
+
# pattern directory name defaults to ./**/*_spec.rb, but has a more concise command line echo
|
62
|
+
t.pattern = File.join(blacklight_spec, "/**/*_spec.rb")
|
63
|
+
t.rspec_opts = "--colour"
|
64
|
+
t.rcov_opts = '-o "blacklight-coverage" --exclude /gems/,/Library/,/usr/,lib/tasks,.bundle,config,/lib/rspec/,/lib/rspec-'
|
65
|
+
end
|
66
|
+
|
67
|
+
# Blacklight. Solr wrapper. for now just for blacklight:spec, plan to
|
68
|
+
# provide it for all variants eventually.
|
69
|
+
# if you would like to see solr startup messages on STDERR
|
70
|
+
# when starting solr test server during functional tests use:
|
71
|
+
#
|
72
|
+
# rake SOLR_CONSOLE=true
|
73
|
+
require File.expand_path('../jetty_solr_server.rb', __FILE__)
|
74
|
+
desc "blacklight:solr with jetty/solr launch"
|
75
|
+
task :with_solr do
|
76
|
+
# wrap tests with a test-specific Solr server
|
77
|
+
# Need to look up where the test jetty is located
|
78
|
+
# from solr.yml, we don't hardcode it anymore.
|
79
|
+
|
80
|
+
solr_yml_path = locate_path("config", "solr.yml")
|
81
|
+
jetty_path = if ( File.exists?( solr_yml_path ))
|
82
|
+
solr_config = YAML::load(File.open(solr_yml_path))
|
83
|
+
solr_config["test"]["jetty_path"] if solr_config["test"]
|
84
|
+
end
|
85
|
+
raise Exception.new("Can't find jetty path to start test jetty. Expect a jetty_path key in config/solr.yml for test environment.") unless jetty_path
|
86
|
+
|
87
|
+
|
88
|
+
# wrap tests with a test-specific Solr server
|
89
|
+
JettySolrServer.new(
|
90
|
+
:jetty_home => File.expand_path(jetty_path, Rails.root),
|
91
|
+
:sleep_after_start => 2).wrap do
|
92
|
+
Rake::Task["blacklight:spec"].invoke
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# Don't understand what this does or how to make it use our remote stats_directory.
|
98
|
+
# task :statsetup do
|
99
|
+
# require 'rails/code_statistics'
|
100
|
+
# ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
101
|
+
# ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
102
|
+
# ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
103
|
+
# ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
104
|
+
# ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
105
|
+
# ::STATS_DIRECTORIES << %w(Mailer\ specs spec/mailers) if File.exist?('spec/mailers')
|
106
|
+
# ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
|
107
|
+
# ::STATS_DIRECTORIES << %w(Request\ specs spec/requests) if File.exist?('spec/requests')
|
108
|
+
# ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
109
|
+
# ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
110
|
+
# ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
111
|
+
# ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
112
|
+
# ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
113
|
+
# ::CodeStatistics::TEST_TYPES << "Mailer specs" if File.exist?('spec/mailers')
|
114
|
+
# ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
115
|
+
# ::CodeStatistics::TEST_TYPES << "Request specs" if File.exist?('spec/requests')
|
116
|
+
# end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
rescue LoadError
|
120
|
+
# This rescue pattern stolen from cucumber; rspec didn't need it before since
|
121
|
+
# tasks only lived in rspec gem itself, but for Blacklight since we're copying
|
122
|
+
# these tasks into BL, we use the rescue so you can still run BL (without
|
123
|
+
# these tasks) even if you don't have rspec installed.
|
124
|
+
desc 'rspec rake tasks not available (rspec not installed)'
|
125
|
+
task :spec do
|
126
|
+
abort 'Rspec rake tasks not available. Be sure to install rspec gems. '
|
127
|
+
end
|
128
|
+
end
|
@@ -14,37 +14,28 @@
|
|
14
14
|
# The behavior of TestSolrServer can be modified prior to start() by changing
|
15
15
|
# port, solr_home, and quiet properties.
|
16
16
|
|
17
|
-
class
|
18
|
-
|
19
|
-
include Singleton
|
20
|
-
attr_accessor :port, :jetty_home, :solr_home, :quiet
|
17
|
+
class JettySolrServer
|
18
|
+
attr_accessor :port, :jetty_home, :solr_home, :quiet, :sleep_after_start, :pid
|
21
19
|
|
22
20
|
# configure the singleton with some defaults
|
23
|
-
def initialize
|
21
|
+
def initialize(params = {})
|
24
22
|
@pid = nil
|
23
|
+
self.quiet = params.has_key?(:quiet) ? !!params[:quiet] : true
|
24
|
+
self.jetty_home = params[:jetty_home]
|
25
|
+
self.solr_home = params[:solr_home] || File.expand_path("./solr", self.jetty_home)
|
26
|
+
self.port = params[:jetty_port] || 8888
|
27
|
+
self.sleep_after_start = params[:sleep_after_start]
|
25
28
|
end
|
26
29
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
solr_server.quiet = params[:quiet] || true
|
31
|
-
solr_server.jetty_home = params[:jetty_home]
|
32
|
-
solr_server.solr_home = params[:solr_home]
|
33
|
-
solr_server.port = params[:jetty_port] || 8888
|
30
|
+
def wrap
|
31
|
+
puts "JettySolrServer: starting server on #{RUBY_PLATFORM}"
|
32
|
+
self.start
|
34
33
|
begin
|
35
|
-
puts "starting solr server on #{RUBY_PLATFORM}"
|
36
|
-
solr_server.start
|
37
|
-
sleep params[:startup_wait] || 5
|
38
34
|
yield
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
ensure
|
43
|
-
puts "stopping solr server"
|
44
|
-
solr_server.stop
|
35
|
+
ensure
|
36
|
+
puts "JettySolrServer: stopping solr server"
|
37
|
+
self.stop
|
45
38
|
end
|
46
|
-
|
47
|
-
return error
|
48
39
|
end
|
49
40
|
|
50
41
|
def jetty_command
|
@@ -52,10 +43,14 @@ class TestSolrServer
|
|
52
43
|
end
|
53
44
|
|
54
45
|
def start
|
55
|
-
puts "
|
56
|
-
|
57
|
-
puts "jetty_command: #{jetty_command}"
|
46
|
+
puts "\nexecuting: #{jetty_command}\n\n"
|
47
|
+
|
58
48
|
platform_specific_start
|
49
|
+
|
50
|
+
if self.sleep_after_start
|
51
|
+
puts "sleeping #{self.sleep_after_start}s waiting for startup."
|
52
|
+
sleep self.sleep_after_start
|
53
|
+
end
|
59
54
|
end
|
60
55
|
|
61
56
|
def stop
|
@@ -86,15 +81,13 @@ class TestSolrServer
|
|
86
81
|
else # Not Windows
|
87
82
|
|
88
83
|
def jruby_raise_error?
|
89
|
-
raise 'JRuby requires that you start solr manually
|
84
|
+
raise 'JRuby requires that you start solr manually."' if defined?(JRUBY_VERSION)
|
90
85
|
end
|
91
86
|
|
92
87
|
# start the solr server
|
93
88
|
def platform_specific_start
|
94
|
-
|
95
89
|
jruby_raise_error?
|
96
90
|
|
97
|
-
puts self.inspect
|
98
91
|
Dir.chdir(@jetty_home) do
|
99
92
|
@pid = fork do
|
100
93
|
STDERR.close if @quiet
|
@@ -112,19 +105,3 @@ class TestSolrServer
|
|
112
105
|
end
|
113
106
|
|
114
107
|
end
|
115
|
-
#
|
116
|
-
# puts "hello"
|
117
|
-
# SOLR_PARAMS = {
|
118
|
-
# :quiet => ENV['SOLR_CONSOLE'] ? false : true,
|
119
|
-
# :jetty_home => ENV['SOLR_JETTY_HOME'] || File.expand_path('../../jetty'),
|
120
|
-
# :jetty_port => ENV['SOLR_JETTY_PORT'] || 8888,
|
121
|
-
# :solr_home => ENV['SOLR_HOME'] || File.expand_path('test')
|
122
|
-
# }
|
123
|
-
#
|
124
|
-
# # wrap functional tests with a test-specific Solr server
|
125
|
-
# got_error = TestSolrServer.wrap(SOLR_PARAMS) do
|
126
|
-
# puts `ps aux | grep start.jar`
|
127
|
-
# end
|
128
|
-
#
|
129
|
-
# raise "test failures" if got_error
|
130
|
-
#
|
data/lib/railties/solr_marc.rake
CHANGED
@@ -14,8 +14,12 @@ namespace :solr do
|
|
14
14
|
|
15
15
|
desc "Index the supplied test data into Solr"
|
16
16
|
task :index_test_data do
|
17
|
-
|
18
|
-
|
17
|
+
# for now we are assuming test data is located in BL source checkout.
|
18
|
+
ENV['MARC_FILE'] = File.expand_path("./test_support/data/test_data.utf8.mrc", Blacklight.root )
|
19
|
+
|
20
|
+
# solr_path and solr_war_path will be picked up from
|
21
|
+
# jetty_path in solr.yml by main work task.
|
22
|
+
|
19
23
|
Rake::Task[ "solr:marc:index:work" ].invoke
|
20
24
|
end
|
21
25
|
|
@@ -117,11 +121,23 @@ def compute_arguments
|
|
117
121
|
# Solr URL, find from solr.yml, app or plugin
|
118
122
|
# use :replicate_master_url for current env if present, otherwise :url
|
119
123
|
# for current env.
|
124
|
+
# Also take jetty_path from there if present.
|
120
125
|
solr_yml_path = locate_path("config", "solr.yml")
|
121
126
|
if ( File.exists?( solr_yml_path ))
|
122
127
|
solr_config = YAML::load(File.open(solr_yml_path))
|
123
|
-
|
128
|
+
if c = solr_config[::Rails.env]
|
129
|
+
arguments[:solr_url] = c['url']
|
130
|
+
if c['jetty_path']
|
131
|
+
arguments[:solr_path] = File.expand_path(File.join(c['jetty_path'], "solr"), Rails.root)
|
132
|
+
arguments[:solr_war_path] = File.expand_path(File.join(c['jetty_path'], "webapps", "solr.war"), Rails.root)
|
133
|
+
end
|
134
|
+
end
|
124
135
|
end
|
136
|
+
|
137
|
+
# solrmarc.solr.war.path and solr.path, for now pull out of ENV
|
138
|
+
# if present. In progress. jrochkind 25 Apr 2011.
|
139
|
+
arguments[:solr_war_path] = ENV["SOLR_WAR_PATH"] if ENV["SOLR_WAR_PATH"]
|
140
|
+
arguments[:solr_path] = ENV['SOLR_PATH'] if ENV['SOLR_PATH']
|
125
141
|
|
126
142
|
|
127
143
|
return arguments
|
@@ -130,14 +146,17 @@ end
|
|
130
146
|
def solrmarc_command_line(arguments)
|
131
147
|
cmd = "java #{arguments[:solrmarc_mem_arg]} "
|
132
148
|
cmd += " -Dsolr.hosturl=#{arguments[:solr_url]} " unless arguments[:solr_url].blank?
|
149
|
+
|
150
|
+
cmd += " -Dsolrmarc.solr.war.path=#{arguments[:solr_war_path]}" unless arguments[:solr_war_path].blank?
|
151
|
+
cmd += " -Dsolr.path=#{arguments[:solr_path]}" unless arguments[:solr_path].blank?
|
152
|
+
|
133
153
|
cmd += " -jar #{arguments[:solrmarc_jar_path]} #{arguments[:config_properties_path]} #{arguments["MARC_FILE"]}"
|
134
154
|
return cmd
|
135
155
|
end
|
136
156
|
|
137
157
|
|
138
158
|
def locate_path(*subpath_fragments)
|
139
|
-
local_root = File.expand_path File.join(File.dirname(__FILE__), '..', '..')
|
140
|
-
puts "The local_root is #{local_root}"
|
159
|
+
local_root = File.expand_path File.join(File.dirname(__FILE__), '..', '..')
|
141
160
|
subpath = subpath_fragments.join('/')
|
142
161
|
base_match = [Rails.root, local_root].find do |base|
|
143
162
|
File.exists? File.join(base, subpath)
|