class Neo4jTest::Server

Constants

AlreadyRunningError
JavaMissing
NotRunningError
ServerError

Raised if stop is called but the server is not running

Attributes

bind_address[W]
edition[RW]
neo4j_data_dir[W]
neo4j_home[W]
neo4j_jar[W]
port[W]

Public Class Methods

new(ed = 'community-2.2.0') click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 18
def initialize(ed = 'community-2.2.0')
  ensure_java_installed
  self.edition = ed
end

Public Instance Methods

bind_address() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 34
def bind_address
  @bind_address ||= '127.0.0.1'
end
bootstrap() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 27
def bootstrap
  unless @bootstrapped
    Neo4jTest::Installer.bootstrap edition
    @bootstrapped = true
  end
end
ensure_java_installed() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 82
def ensure_java_installed
  unless defined?(@java_installed)
    @java_installed = Neo4jTest::Java.installed?
    unless @java_installed
      raise JavaMissing.new('You need a Java Runtime Environment to run the Solr server')
    end
  end
  @java_installed
end
install_location() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 92
def install_location
  Neo4jTest::Installer.install_location
end
port() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 38
def port
  @port ||= '7474'
end
start() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 46
def start
  bootstrap

  puts 'Starting Neo4j...'
  if OS::Underlying.windows?
    start_windows_server(start_command)
  else
    start_starnix_server(start_command)
  end
end
start_command() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 42
def start_command
  @start_command ||= 'start'
end
start_starnix_server(command) click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 78
def start_starnix_server(command)
  `#{install_location}/bin/neo4j #{command}`
end
start_windows_server(command) click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 69
def start_windows_server(command)
  if `reg query "HKU\\S-1-5-19"`.size > 0
    `#{install_location}/bin/Neo4j.bat #{command}`  # start service
  else
    puts 'Starting Neo4j directly, not as a service.'
    `#{install_location}/bin/Neo4j.bat`
  end
end
stop() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 57
def stop
  if OS::Underlying.windows?
    if `reg query "HKU\\S-1-5-19"`.size > 0
      `#{install_location}/bin/Neo4j.bat stop`  # stop service
    else
      puts 'You do not have administrative rights to stop the Neo4j Service'
    end
  else
    `#{install_location}/bin/neo4j stop`
  end
end
to_s() click to toggle source
# File lib/neo4j_test_server/neo4j_server.rb, line 23
def to_s
  "http://#{bind_address}:#{port}" unless bind_address.empty? && port.empty?
end