Search in sources :

Example 6 with ManagedSolrServer

use of org.apache.stanbol.commons.solr.managed.ManagedSolrServer in project stanbol by apache.

the class SolrYardTest method initYard.

@BeforeClass
public static final void initYard() throws YardException, IOException {
    // get the working directory
    // use property substitution to test this feature!
    String prefix = System.getProperty("basedir") == null ? "." : "${basedir}";
    String solrServerDir = prefix + TEST_INDEX_REL_PATH;
    log.info("Test Solr Server Directory: " + solrServerDir);
    SolrYardConfig config = new SolrYardConfig(TEST_YARD_ID, TEST_SOLR_CORE_NAME);
    config.setName("Solr Yard Test");
    config.setDescription("The Solr Yard instance used to execute the Unit Tests defined for the Yard Interface");
    config.setAllowInitialisation(true);
    //for unit testing we want immidiate commits (required after STANBOL-1092
    // as the default changed to false)
    config.setImmediateCommit(true);
    //init the ManagedSolrServer used for the UnitTest
    System.setProperty(ManagedSolrServer.MANAGED_SOLR_DIR_PROPERTY, solrServerDir);
    IndexReference solrServerRef = IndexReference.parse(config.getSolrServerLocation());
    solrServerProvider = StandaloneEmbeddedSolrServerProvider.getInstance();
    SolrServer server = solrServerProvider.getSolrServer(solrServerRef, config.isAllowInitialisation() ? config.getIndexConfigurationName() : null);
    //Optional support for the nsPrefix service
    final NamespacePrefixService nsPrefixService;
    ServiceLoader<NamespacePrefixService> spsl = ServiceLoader.load(NamespacePrefixService.class);
    Iterator<NamespacePrefixService> it = spsl.iterator();
    if (it.hasNext()) {
        nsPrefixService = it.next();
    } else {
        nsPrefixService = null;
    }
    yard = new SolrYard(server, config, nsPrefixService);
}
Also used : NamespacePrefixService(org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService) IndexReference(org.apache.stanbol.commons.solr.IndexReference) StandaloneManagedSolrServer(org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer) ManagedSolrServer(org.apache.stanbol.commons.solr.managed.ManagedSolrServer) SolrServer(org.apache.solr.client.solrj.SolrServer) SolrYard(org.apache.stanbol.entityhub.yard.solr.impl.SolrYard) SolrYardConfig(org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig) BeforeClass(org.junit.BeforeClass)

Aggregations

ManagedSolrServer (org.apache.stanbol.commons.solr.managed.ManagedSolrServer)6 SolrServer (org.apache.solr.client.solrj.SolrServer)2 IndexReference (org.apache.stanbol.commons.solr.IndexReference)2 ServiceReference (org.osgi.framework.ServiceReference)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Properties (java.util.Properties)1 SortedMap (java.util.SortedMap)1 ArchiveInputStream (org.apache.commons.compress.archivers.ArchiveInputStream)1 Activate (org.apache.felix.scr.annotations.Activate)1 HttpSolrServer (org.apache.solr.client.solrj.impl.HttpSolrServer)1 NamespacePrefixService (org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService)1 RegisteredSolrServerTracker (org.apache.stanbol.commons.solr.RegisteredSolrServerTracker)1 IndexMetadata (org.apache.stanbol.commons.solr.managed.IndexMetadata)1 StandaloneManagedSolrServer (org.apache.stanbol.commons.solr.managed.standalone.StandaloneManagedSolrServer)1 SolrYard (org.apache.stanbol.entityhub.yard.solr.impl.SolrYard)1 SolrYardConfig (org.apache.stanbol.entityhub.yard.solr.impl.SolrYardConfig)1 BeforeClass (org.junit.BeforeClass)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1