public void ResolveSolrOperations()
        {
            // Arrange
            var builder = new ContainerBuilder();
            var cores = new SolrServers {
                                new SolrServerElement {
                                        Id = "entity1",
                                        DocumentType = typeof (Entity1).AssemblyQualifiedName,
                                        Url = "http://localhost:8983/solr/coreEntity1",
                                    },
                            };

            builder.RegisterModule(new SolrNetModule(cores));
            var container = builder.Build();

            // Act
            var m = container.Resolve<ISolrOperations<Entity1>>();

            // Assert
            Assert.IsTrue(m is SolrServer<Entity1>);
        }
Example #2
0
 /// <summary>
 ///   Register multi-core server
 /// </summary>
 /// <param name = "solrServers"></param>
 public SolrNetModule(SolrServers solrServers)
 {
     this.solrServers = solrServers;
 }
        public void ResolveSolrOperations_withNamedMultiCore_sameDocumentType()
        {
            var readCoreId = "entity1_readcore";
            var writeCoreId = "entity1_writecore";

            // Arrange
            var builder = new ContainerBuilder();
            var cores = new SolrServers {
                                new SolrServerElement {
                                        Id = readCoreId,
                                        DocumentType = typeof (Entity1).AssemblyQualifiedName,
                                        Url = "http://localhost:8983/solr/readcoreEntity1",
                                    },
                               new SolrServerElement {
                                        Id = writeCoreId,
                                        DocumentType = typeof (Entity1).AssemblyQualifiedName,
                                        Url = "http://localhost:8983/solr/writecoreEntity1",
                                },
                            };

            builder.RegisterModule(new SolrNetModule(cores));
            var container = builder.Build();

            // Act
            var readSolrOperations = container.ResolveNamed<ISolrOperations<Entity1>>(readCoreId);
            var writeSolrOperations = container.ResolveNamed<ISolrOperations<Entity1>>(writeCoreId);
            var solrReadOnlyOperations = container.ResolveNamed<ISolrReadOnlyOperations<Entity1>>(readCoreId);

            // Assert
            Assert.IsTrue(readSolrOperations is SolrServer<Entity1>);
            Assert.IsTrue(writeSolrOperations is SolrServer<Entity1>);
            Assert.IsTrue(solrReadOnlyOperations is SolrServer<Entity1>);
        }
Example #4
0
 /// <summary>
 /// Register multi-core server
 /// </summary>
 /// <param name="solrServers"></param>
 public SolrNetModule(SolrServers solrServers)
 {
     _solrServers = solrServers;
 }
        public void ResolveSolrReadOnlyOperations_viaNamedWithMultiCoreForDictionary()
        {
            // Arrange 
            var builder = new ContainerBuilder();
            var cores = new SolrServers {
                                new SolrServerElement {
                                        Id = "dictionary1",
                                        DocumentType = typeof (Dictionary<string, object>).AssemblyQualifiedName,
                                        Url = "http://localhost:8983/solr/coreDictionaryEntity1",
                                    },
                               new SolrServerElement {
                                        Id = "dictionary2",
                                        DocumentType = typeof (Dictionary<string, object>).AssemblyQualifiedName,
                                        Url = "http://localhost:8983/solr/coreDictionaryEntity2",
                                },
                            };

            builder.RegisterModule(new SolrNetModule(cores));
            var container = builder.Build();

            // Act
            var solrReadOnlyOperations1 = container.ResolveNamed<ISolrReadOnlyOperations<Dictionary<string, object>>>("dictionary1");
            var solrReadOnlyOperations2 = container.ResolveNamed<ISolrReadOnlyOperations<Dictionary<string, object>>>("dictionary2");

            // Assert
            Assert.IsTrue(solrReadOnlyOperations1 is SolrServer<Dictionary<string, object>>);
            Assert.IsTrue(solrReadOnlyOperations2 is SolrServer<Dictionary<string, object>>);
        }
        public void ResolveSolrOperations_viaNamedWithMultiCore()
        {
            // Arrange 
            var builder = new ContainerBuilder();
            var cores = new SolrServers {
                                new SolrServerElement {
                                        Id = "entity1",
                                        DocumentType = typeof (Entity1).AssemblyQualifiedName,
                                        Url = "http://localhost:8983/solr/coreEntity1",
                                    },
                               new SolrServerElement {
                                        Id = "entity2",
                                        DocumentType = typeof (Entity2).AssemblyQualifiedName,
                                        Url = "http://localhost:8983/solr/coreEntity2",
                                },
                            };

            builder.RegisterModule(new SolrNetModule(cores));
            var container = builder.Build();

            // Act
            var solrOperations1 = container.ResolveNamed<ISolrOperations<Entity1>>("entity1");
            var solrOperations2 = container.ResolveNamed<ISolrOperations<Entity2>>("entity2");

            // Assert
            Assert.IsTrue(solrOperations1 is SolrServer<Entity1>);
            Assert.IsTrue(solrOperations2 is SolrServer<Entity2>);
        }