h1. Testing the hydra-head Plugin h2. I. Install the Testing Rails Application In order to run the tests, you need to have a properly configured rails app installed in the hydra-plugin_test_host directory. See "DEVELOP_PLUGIN":https://github.com/projecthydra/hydra-head/blob/master/DEVELOP_PLUGIN.textile for instructions on setting this up. h2. II. Running the full Continuous Integration build _Stop any copies of jetty (or anything else using port 8983) before running this command._ This will spin up jetty pre-configured with Fedora and Solr on port 8983, import your fixtures into it, run the tests, and stop jetty.
  rake hyhead:ci RAILS_ENV=test 
h2. III. Running the Tests Manually h4. (1) Start Jetty, preloaded with Fedora and Solr applications See below to reset jetty when re-running tests, or when running a simultaneous development instance. _Stop any copies of jetty (or anything else using port 8983) before running this command._ You must do this at the root of the hydra-head plugin directory, not within the hydra-plugin_test_host directory. Note that java 1.6 must be invoked by the "java" command or Fedora won't work.
  rake hydra:jetty:load RAILS_ENV=test
This will start up jetty on port 8983. h4. (2) Load test fixtures into Fedora/Solr. You must do this at the root of the hydra-head plugin directory, not within the hydra-plugin_test_host directory. NOTE: to ensure that the tests do not rely on non-test data, do this first:
  rake hydra:default_fixtures:delete
  rake hydra:default_fixtures:refresh environment=test
(TO DO: get rid of irrelevant fixtures; get rid of non-generic fixtures.) h4. (3) Run specs.
  rake hyhead:spec
OR
  rake hyhead:remove_plugin_from_host
  rake hyhead:copy_plugin_to_host
  rake hyhead:rspec
h2. If you need to Re-run the tests: h4. Clean out and reload the databases:
  cd hydra-plugin_test_host
  rake db:drop RAILS_ENV=test
    or
  rake db:drop:all   (to ensure that the tests do not rely on non-test data)
  rake db:migrate RAILS_ENV=test  
  cd ..
h2. Don't forget to stop Jetty! It's easy to forget a running jetty, start another jetty process, and then get confusing behavior because you have two jetty instances on the same port. To stop jetty: From the rails application directory (my-hydra-head-test-app)
  rake hydra:jetty:stop
Use ps to ensure the java process has stopped. If not, kill it manually. h4. Clean out and reload the fixtures: 1. Stop jetty
  rake hydra:jetty:stop
Use ps to ensure the java process has stopped. If not, kill it manually. 2. Clean out Solr and Fedora on Jetty (Note: this will also wipe out the development data until we use the single solr instance of hydra-jetty) TODO: can this be a single rake task?
  cd jetty
  git clean -df
  git checkout .
  git status     should show nothing to commit
  cd ..   (back to root of the _plugin_)
3. Re-initialize and start Jetty:
  rake hydra:jetty:load RAILS_ENV=test
4. Reload the pristine fixtures. NOTE: to ensure that the tests do not rely on non-test data, do this first:
  rake hydra:default_fixtures:delete
  rake hydra:default_fixtures:refresh environment=test