Sha256: 7777ba2575669683cffd852c80269e2aca05cbebb516fc1f448144c3cdcbf77b

Contents?: true

Size: 1.39 KB

Versions: 13

Compression:

Stored size: 1.39 KB

Contents

# Starts a fedora server and a solr server on a random port and then
# yields the passed block
def with_test_server(&block)
  with_server('test', &block)
end

def with_server(environment, fcrepo_port: nil, solr_port: nil)
  return yield if ENV["#{environment}_SERVER_STARTED"]

  ENV["#{environment}_SERVER_STARTED"] = 'true'

  # setting port: nil assigns a random port.
  solr_params = { port: solr_port, verbose: true, managed: true }
  fcrepo_params = { port: fcrepo_port, verbose: true, managed: true,
                    enable_jms: false, fcrepo_home_dir: "fcrepo4-#{environment}-data" }
  SolrWrapper.wrap(solr_params) do |solr|
    ENV["SOLR_#{environment.upcase}_PORT"] = solr.port
    solr_config_path = File.join('solr', 'config')
    # Check to see if configs exist in a path relative to the working directory
    unless Dir.exist?(solr_config_path)
      $stderr.puts "Solr configuration not found at #{solr_config_path}. Using ActiveFedora defaults"
      # Otherwise use the configs delivered with ActiveFedora.
      solr_config_path = File.join(File.expand_path("../..", File.dirname(__FILE__)), "solr", "config")
    end
    solr.with_collection(name: "hydra-#{environment}", dir: solr_config_path) do
      FcrepoWrapper.wrap(fcrepo_params) do |fcrepo|
        ENV["FCREPO_#{environment.upcase}_PORT"] = fcrepo.port
        yield
      end
    end
  end
  ENV["#{environment}_SERVER_STARTED"] = 'false'
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active-fedora-10.0.0.beta1 lib/active_fedora/rake_support.rb
active-fedora-9.13.0 lib/active_fedora/rake_support.rb
active-fedora-9.12.0 lib/active_fedora/rake_support.rb
active-fedora-9.11.0 lib/active_fedora/rake_support.rb
active-fedora-9.10.4 lib/active_fedora/rake_support.rb
active-fedora-9.10.3 lib/active_fedora/rake_support.rb
active-fedora-9.10.2 lib/active_fedora/rake_support.rb
active-fedora-9.10.1 lib/active_fedora/rake_support.rb
active-fedora-9.10.0 lib/active_fedora/rake_support.rb
active-fedora-9.10.0.pre2 lib/active_fedora/rake_support.rb
active-fedora-9.10.0.pre1 lib/active_fedora/rake_support.rb
active-fedora-9.9.1 lib/active_fedora/rake_support.rb
active-fedora-9.9.0 lib/active_fedora/rake_support.rb