public void Should_throw_exception_for_invalid_url() { var solrServers = new SolrServers { new SolrServerElement { Id = "test", Url = "http:/localhost:8893", DocumentType = typeof(Entity2).AssemblyQualifiedName, } }; ObjectFactory.Initialize(c => c.IncludeRegistry(new SolrNetRegistry(solrServers))); ObjectFactory.GetInstance<SolrConnection>(); }
public SolrNetRegistry(SolrServers solrServers) { For<IReadOnlyMappingManager>().Use<MemoizingMappingManager>() .Ctor<IReadOnlyMappingManager>("mapper").Is(new AttributesMappingManager()); For(typeof (ISolrDocumentActivator<>)).Use(typeof (SolrDocumentActivator<>)); For(typeof(ISolrQueryExecuter<>)).Use(typeof(SolrQueryExecuter<>)); For<ISolrDocumentPropertyVisitor>().Use<DefaultDocumentVisitor>(); For<IMappingValidator>().Use<MappingValidator>(); RegisterParsers(); RegisterValidationRules(); RegisterSerializers(); RegisterOperations(); AddCoresFromConfig(solrServers); }
public void DictionaryDocument_and_multi_core() { var cores = new SolrServers { new SolrServerElement { Id = "default", DocumentType = typeof(Entity).AssemblyQualifiedName, Url = "http://localhost:8983/solr/entity1", }, new SolrServerElement { Id = "entity1dict", DocumentType = typeof(Dictionary<string, object>).AssemblyQualifiedName, Url = "http://localhost:8983/solr/entity1", }, new SolrServerElement { Id = "another", DocumentType = typeof(Entity2).AssemblyQualifiedName, Url = "http://localhost:8983/solr/entity2", }, }; ObjectFactory.Initialize(c => c.IncludeRegistry(new SolrNetRegistry(cores))); var solr1 = ObjectFactory.GetInstance<ISolrOperations<Entity>>(); var solr2 = ObjectFactory.GetInstance<ISolrOperations<Entity2>>(); var solrDict = ObjectFactory.GetInstance<ISolrOperations<Dictionary<string, object>>>(); }
private void AddCoresFromConfig(SolrServers solrServers) { if (solrServers == null) return; var cores = new List<SolrCore>(); foreach (SolrServerElement server in solrServers) { var solrCore = GetCoreFrom(server); cores.Add(solrCore); } foreach (var core in cores) { RegisterCore(core); } }