package uk.ac.ebi.quickgo.repo.solr;

import org.junit.ClassRule;
import org.junit.rules.ExternalResource;
import org.junit.rules.TemporaryFolder;

import java.io.IOException;

/**
 * Creates a temporary solr data store, which is deleted on exit. Use this class with
 * the annotation, @ClassRule in tests requiring a temporary solr data store.
 *
 * Created 13/11/15
 * @author Edd
 */
public class TemporarySolrDataStore extends ExternalResource {
    // the property defining the solr data store, used in solr core's solrconfig.xml files
    private static final String SOLR_DATA_DIR = "solr.data.dir";

    @ClassRule
    public static TemporaryFolder temporaryFolder = new TemporaryFolder();

    @Override
    public void before() throws IOException {
        temporaryFolder.create();
        System.setProperty(SOLR_DATA_DIR, temporaryFolder.getRoot().getAbsolutePath());
    }

    @Override
    public void after() {
        temporaryFolder.delete();
    }
}

@@ -27,24 +27,45 @@
 repo.solr;%0A%0A
+import java.io.File;%0A
 import org.j
@@ -479,66 +479,47 @@
 the 
-property defining the solr data store, used in solr core's
+following properties are defined in the
  sol
@@ -600,16 +600,92 @@
 ta.dir%22;
+%0A    private static final String SOLR_PLUGIN_JAR = %22solr.similarity.plugin%22;
 %0A%0A    @C
@@ -951,16 +951,458 @@
 ath());%0A
+        System.setProperty(SOLR_PLUGIN_JAR, pathToSimilarityPlugin());%0A    %7D%0A%0A    private String pathToSimilarityPlugin() %7B%0A        File file = new File(%22../solr-plugin/target/similarity_plugin.jar%22);%0A%0A        if(!file.exists()) %7B%0A            throw new IllegalStateException(%22similarity_plugin.jar does not exist. Please generated the jar before %22 +%0A                    %22running the tests%22);%0A        %7D%0A%0A        return file.getAbsolutePath();%0A
     %7D%0A%0A 

Add custom solr similarity plugin so solrconfig can pick it up.