Exemple #1
0
            public MyJSIndex(int?maxStepsForScript)
            {
                Maps = new HashSet <string>()
                {
                    @"
map('Companies', (company) => {
    var x = [];
    for (var i = 0; i < 50; i++) {
        x.push(i);
    }
    if (company.Address.Country === 'USA') {
        return {
            Name: company.Name,
            Phone: company.Phone,
            City: company.Address.City
        };
    }
})"
                };

                if (maxStepsForScript.HasValue)
                {
                    Configuration = new IndexConfiguration
                    {
                        { RavenConfiguration.GetKey(x => x.Indexing.MaxStepsForScript), maxStepsForScript.ToString() }
                    };
                }
            }
        public void ShouldCreateIndex(
            IndexFor indexFor,
            IndexProvider indexProvider,
            IndexType indexType,
            string createEndpoint,
            string createJson)
        {
            //Arrange
            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostJson(createEndpoint, createJson),
                    MockResponse.Http(201)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                var indexConfiguration = new IndexConfiguration
                {
                    Provider = indexProvider,
                    Type = indexType
                };
                graphClient.CreateIndex("foo", indexConfiguration, indexFor);
            }
        }
 public Reader(
     ILogger <Reader> logger,
     IOptions <IndexConfiguration> configuration)
 {
     _logger        = logger;
     _configuration = configuration.Value;
 }
        public void PopulateIndexConfiguration(Dictionary <string, object> configValues,
                                               out ICloneable configuration)
        {
            IndexConfiguration indexConf = new IndexConfiguration();

            if (configValues.ContainsKey(ConfigType.Name.ToString()))
            {
                indexConf.Name = configValues[ConfigType.Name.ToString()].ToString();
            }

            IndexAttribute attribute = new IndexAttribute();

            if (configValues.ContainsKey(ConfigType.Attribute.ToString()))
            {
                attribute.Name = (string)configValues[ConfigType.Attribute.ToString()];
            }

            if (configValues.ContainsKey(ConfigType.SortOrder.ToString()))
            {
                attribute.Order = (string)configValues[ConfigType.SortOrder.ToString()];
            }
            indexConf.Attributes = attribute;

            if (configValues.ContainsKey(ConfigType.JournalEnabled.ToString()))
            {
                indexConf.JournalEnabled = (bool)configValues[ConfigType.JournalEnabled.ToString()];
            }

            if (configValues.ContainsKey(ConfigType.CachePolicy.ToString()))
            {
                indexConf.CachePolicy = (string)configValues[ConfigType.CachePolicy.ToString()];
            }

            configuration = indexConf;
        }
Exemple #5
0
        /// <summary>
        /// Generates the index page for the documentation.
        /// </summary>
        /// <param name="indexConfiguration">The index configuration.</param>
        /// <returns>The generation errors.</returns>
        public GenerationError[] GenerateIndex(IndexConfiguration indexConfiguration)
        {
            // Data validation
            Ensure.That(() => indexConfiguration).IsNotNull();

            // Try to generate the index html file
            List <GenerationError> generationError = new List <GenerationError>();

            try
            {
                string outputFileHtml = this.fileSystem.Path.Combine(this.OutputDirectory.FullName, indexConfiguration.Output);
                this.GenerateIndexFile(indexConfiguration.Template, outputFileHtml, indexConfiguration);
            }
            catch (TemplateParsingException templateParsingException)
            {
                generationError.Add(new Model.GenerationError(indexConfiguration.Template, string.Format("Error during HTML generation: {0}", templateParsingException.Message), templateParsingException.Line, templateParsingException.Column));
            }
            catch (System.Exception exception)
            {
                generationError.Add(new Model.GenerationError(indexConfiguration.Template, string.Format("Error during HTML generation: {0}", exception.Message), 0, 0));
            }

            // Return generation errors
            return(generationError.ToArray());
        }
Exemple #6
0
        public void ValidConfigurationTwoGenerationsWithHtmlOnlyAndPdfOnly()
        {
            // Declare configuration name
            string fileName = this.FileSystem.Path.Combine("Config", "TwoGenerations.json");

            // Load configuration
            IndexConfiguration indexConfiguration = this.ConfigurationLoader.Load(".", fileName);

            Configuration[] configurations = indexConfiguration.Configurations;

            // Assert
            Assert.AreEqual("Test title 1", configurations[0].Title);
            Assert.AreEqual(true, configurations[0].GenerateHtml);
            Assert.AreEqual(false, configurations[0].GeneratePdf);
            Assert.IsTrue(configurations[0].TemplateHtml.EndsWith("Template.txt"));
            Assert.AreEqual("Template-generated.txt", configurations[0].OutputHtml);
            Assert.AreEqual(null, configurations[0].TemplatePdf);
            Assert.AreEqual(null, configurations[0].OutputPdf);
            Assert.AreEqual(0, configurations[0].Pages.Length);
            Assert.AreEqual("Test title 2", configurations[1].Title);
            Assert.AreEqual(false, configurations[1].GenerateHtml);
            Assert.AreEqual(true, configurations[1].GeneratePdf);
            Assert.AreEqual(null, configurations[1].TemplateHtml);
            Assert.AreEqual(null, configurations[1].OutputHtml);
            Assert.IsTrue(configurations[1].TemplatePdf.EndsWith("Template-pdf.txt"));
            Assert.AreEqual("Template-pdf-generated.txt", configurations[1].OutputPdf);
            Assert.AreEqual(0, configurations[1].Pages.Length);
        }
Exemple #7
0
        public void ShouldThrowExceptionIfHttpCodeIsNot201(
            IndexFor indexFor,
            IndexProvider indexProvider,
            IndexType indexType,
            string createEndpoint,
            string createJson)
        {
            //Arrange
            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostJson(createEndpoint, createJson),
                    MockResponse.Http(500)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                var indexConfiguration = new IndexConfiguration
                {
                    Provider = indexProvider,
                    Type     = indexType
                };
                Assert.Throws <Exception>(() => graphClient.CreateIndex("foo", indexConfiguration, indexFor));
            }
        }
Exemple #8
0
        public void ValidConfiguration(bool readOnly)
        {
            // Declare configuration name
            string fileName = this.FileSystem.Path.Combine("Config", "Simple.json");

            // Handle file attribute
            FileAttributes configurationFileAttributes = this.FileSystem.File.GetAttributes(fileName);

            // Make the file read only
            if (readOnly)
            {
                this.FileSystem.File.SetAttributes(fileName, configurationFileAttributes | FileAttributes.ReadOnly);
            }

            // Load configuration
            IndexConfiguration indexConfiguration = this.ConfigurationLoader.Load(".", fileName);

            Configuration[] configurations = indexConfiguration.Configurations;

            // Assert
            Assert.AreEqual("Test title", configurations[0].Title);
            Assert.AreEqual(true, configurations[0].GenerateHtml);
            Assert.AreEqual(true, configurations[0].GeneratePdf);
            Assert.IsTrue(configurations[0].TemplateHtml.EndsWith("Template/Template.txt".Replace('/', this.FileSystem.Path.DirectorySeparatorChar)));
            Assert.IsTrue(configurations[0].TemplatePdf.EndsWith("Template/Template-pdf.txt".Replace('/', this.FileSystem.Path.DirectorySeparatorChar)));
            Assert.AreEqual("Template-generated.txt", configurations[0].OutputHtml);
            Assert.AreEqual("Template-pdf-generated.txt", configurations[0].OutputPdf);
            Assert.AreEqual(0, configurations[0].Pages.Length);
        }
Exemple #9
0
        public void ValidConfigurationAllValues()
        {
            // Declare configuration name
            string fileName = this.FileSystem.Path.Combine("Config", "AllValues.json");

            // Load configuration
            IndexConfiguration indexConfiguration = this.ConfigurationLoader.Load(".", fileName);

            Configuration[] configurations = indexConfiguration.Configurations;

            // Assert
            Assert.AreEqual("Test title", configurations[0].Title);
            Assert.AreEqual("Test description", configurations[0].Description);
            Assert.AreEqual("icon.png", configurations[0].Icon);
            Assert.AreEqual(true, configurations[0].GenerateHtml);
            Assert.AreEqual(true, configurations[0].GeneratePdf);
            Assert.IsTrue(configurations[0].TemplateHtml.EndsWith("Template.txt"));
            Assert.IsTrue(configurations[0].TemplatePdf.EndsWith("Template-pdf.txt"));
            Assert.AreEqual("doc.html", configurations[0].OutputHtml);
            Assert.AreEqual("doc-pdf-input.html", configurations[0].OutputPdf);
            Assert.AreEqual(3, configurations[0].Pages.Length);
            Assert.IsTrue(configurations[0].Pages[0].Path.EndsWith("Page/Content.md"));
            Assert.AreEqual("First page title", configurations[0].Pages[0].Title);
            Assert.IsTrue(configurations[0].Pages[1].Path.EndsWith("Page/Snippet.md"));
            Assert.AreEqual("Second page title", configurations[0].Pages[1].Title);
            Assert.IsTrue(configurations[0].Pages[2].Path.EndsWith("Page/Table.md"));
            Assert.AreEqual("Third page title", configurations[0].Pages[2].Title);
        }
Exemple #10
0
        public void ShouldCreateIndex(
            IndexFor indexFor,
            IndexProvider indexProvider,
            IndexType indexType,
            string createEndpoint,
            string createJson)
        {
            //Arrange
            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostJson(createEndpoint, createJson),
                    MockResponse.Http(201)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                var indexConfiguration = new IndexConfiguration
                {
                    Provider = indexProvider,
                    Type     = indexType
                };
                graphClient.CreateIndex("foo", indexConfiguration, indexFor);
            }
        }
Exemple #11
0
        /// <summary>
        /// Creates the index on the master server
        /// </summary>
        /// <param name="indexName">Name of the index.</param>
        /// <param name="dropIfExists">if set to <c>true</c> [drop if exists].</param>
        public void CreateIndex(string indexName, bool dropIfExists)
        {
            if (dropIfExists)
            {
                DeleteIndex(indexName);
            }

            var indexConfiguration = new IndexConfiguration
            {
                Provider = IndexProvider.lucene,
                Type     = IndexType.fulltext
            };

            GraphPoolableClient client = null;

            try
            {
                client = GetClient();
                client.GetClient().CreateIndex(indexName, indexConfiguration, IndexFor.Node);
            }
            catch (Exception e)
            {
                LogException("CreateIndex", e);
                InformAboutHostProblems(client, e);
                throw;
            }
        }
Exemple #12
0
        /// <summary>
        /// Generates the index file.
        /// </summary>
        /// <param name="templateName">The template name.</param>
        /// <param name="outputFileHtml">The file to output to.</param>
        /// <param name="indexConfiguration">The index configuration.</param>
        private void GenerateIndexFile(string templateName, string outputFileHtml, IndexConfiguration indexConfiguration)
        {
            // Generate the index html for the configurations using Razor
            var fileConfiguration = new { IndexConfiguration = indexConfiguration };

            this.WriteFile(templateName, outputFileHtml, fileConfiguration);
        }
 public IndexController(IndexConfiguration configuration, IFrameworkContext frameworkContext)
 {
     Configuration = configuration;
     FrameworkContext = frameworkContext;
     _manualResetter = new ManualResetEvent(false);
     Queue = new IndexModificationQueue();
 }
Exemple #14
0
        protected override IndexWriter GetIndex(QueueModel state)
        {
            if (null == state)
            {
                return(null);
            }

            int areaID = state.AreaID;

            IndexConfig config = null;

            if (!areaHash.ContainsKey(areaID) && null == areaHash[areaID])
            {
                config           = new IndexConfig();
                config.IndexPath = IndexConfiguration.GetAreaPath(areaID);

                areaHash[areaID] = config;
            }
            else
            {
                config = areaHash[areaID] as IndexConfig;
            }

            return(config?.Writer);
        }
Exemple #15
0
        public SingleIndexConfiguration(IndexConfiguration clientConfiguration, RavenConfiguration databaseConfiguration)
            : base(() => databaseConfiguration.DatabaseName, null, null)
        {
            _databaseConfiguration = databaseConfiguration;

            Initialize(key => clientConfiguration.GetValue(key) ?? databaseConfiguration.GetSetting(key), throwIfThereIsNoSetMethod: false);

            Validate();
        }
        public override void TestSetUp()
        {
            var serializer = new ServiceStackSerialiser();

            _frameworkContext = new FakeFrameworkContext(serializer);
            _configuration    = new IndexConfiguration(GetPathForTest());
            var controller = new IndexController(_configuration, _frameworkContext);

            CacheProvider = new CacheProvider(controller, false);
        }
        public override void TestSetUp()
        {
            var serializer = new ServiceStackSerialiser();

            _frameworkContext = new FakeFrameworkContext(serializer);
            _configuration = new IndexConfiguration(GetPathForTest());
            var controller = new IndexController(_configuration, _frameworkContext);

            CacheProvider = new CacheProvider(controller, false);
        }
Exemple #18
0
        public BPlusIndex(IndexConfiguration configurations, string collectionName, string path, CollectionIndexManager parent)
        {
            _configuration = configurations; //configurations.Clone() as IndexConfiguration;

            _indexKey = new UniIndexKey(_configuration.Attributes);

            order = _configuration.Attributes.SortOrder;

            _path   = DirectoryUtil.GetIndexPath(path, collectionName, _configuration.IndexName);
            _parent = parent;
        }
        public Indexer(
            ILogger <Indexer> logger,
            IOptions <IndexConfiguration> configuration)
        {
            _logger        = logger;
            _configuration = configuration.Value;

            _host = _configuration.Host;
            _port = _configuration.Port;

            CreateTemplates();
        }
        private void CreateCommerceIndex(string language, IndexConfiguration indexConfig, Type indexType)
        {
            var indexName = _settings.GetCustomIndexName($"{indexConfig.Name}-{Constants.CommerceProviderName}", language);
            var index     = new Index(_settings, _httpClientHelper, indexName);

            if (!index.Exists)
            {
                index.Initialize(indexType);
                index.WaitForStatus();
                index.DisableDynamicMapping(indexType);
                index.WaitForStatus();
            }
        }
Exemple #21
0
        public void ValidDefaultIndexOutputName()
        {
            // Declare configuration name
            string fileName = this.FileSystem.Path.Combine("Config", "ErrorInIndexHtml.json");

            // Load configuration
            IndexConfiguration indexConfiguration = this.ConfigurationLoader.Load(".", fileName);

            Configuration[] configurations = indexConfiguration.Configurations;

            // Assert
            Assert.AreEqual("Malformated-generated.txt", indexConfiguration.Output);
        }
        private static Type GetIndexType(IndexConfiguration index, ElasticSearchSection config)
        {
            if (index.Default || config.IndicesParsed.Count() == 1)
            {
                return(typeof(IndexItem));
            }

            if (String.IsNullOrWhiteSpace(index.Type))
            {
                return(null);
            }

            return(Type.GetType(index.Type, false, true));
        }
Exemple #23
0
        private Protobuf.CreateIndexCommand ConvertIndexProto(IndexConfiguration indexConfig)
        {
            Protobuf.CreateIndexCommand.Builder _createIndexCommand = new CreateIndexCommand.Builder();
            _createIndexCommand.IndexName      = indexConfig.Name;
            _createIndexCommand.CachePolicy    = indexConfig.CachePolicy;
            _createIndexCommand.JournalEnabled = indexConfig.JournalEnabled;
            Protobuf.IndexAttributeProto.Builder _indexAttribute = new Protobuf.IndexAttributeProto.Builder()
            {
                Name = indexConfig.Attributes.Name, Order = indexConfig.Attributes.Order
            };
            _createIndexCommand.Attributes = _indexAttribute.Build();

            return(_createIndexCommand.Build());
        }
Exemple #24
0
        public SingleIndexConfiguration(IndexConfiguration clientConfiguration, RavenConfiguration databaseConfiguration)
            : base(databaseConfiguration)
        {
            _databaseConfiguration = databaseConfiguration;

            Initialize(
                key =>
                new SettingValue(clientConfiguration.GetValue(key) ?? databaseConfiguration.GetSetting(key),
                                 databaseConfiguration.GetServerWideSetting(key)),
                databaseConfiguration.GetServerWideSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory)),
                databaseConfiguration.ResourceType,
                databaseConfiguration.ResourceName,
                throwIfThereIsNoSetMethod: false);
        }
        /// <summary>
        /// 搜索指定类型集合的数据
        /// </summary>
        /// <param name="dataTypes"></param>
        /// <param name="areaID"></param>
        /// <param name="keyword"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        private List <BaseIndexModel> SearchData(IndexDataType[] dataTypes, int areaID, string keyword, int pageIndex, int pageSize, out int count)
        {
            count = 0;

            if (null == dataTypes || dataTypes.Length < 1)
            {
                return(null);
            }

            string indexPath = IndexConfiguration.GetAreaPath(areaID);

            List <string> fields = new List <string> {
                "name"
            };                                                //, "desc"

            BooleanQuery bquery = new BooleanQuery();

            //分词器
            Analyzer analyzer = new StandardAnalyzer(IndexConfiguration.LuceneMatchVersion);

            //关键词搜索条件
            Query kwdQuery = MultiFieldQueryParser.Parse(IndexConfiguration.LuceneMatchVersion, keyword, fields.ToArray(), new Occur[] { Occur.SHOULD }, analyzer);//, Occur.SHOULD

            bquery.Add(kwdQuery, Occur.MUST);

            //区域条件
            Query areaQuery = new QueryParser(IndexConfiguration.LuceneMatchVersion, "areaid", analyzer).Parse(areaID.ToString());

            bquery.Add(areaQuery, Occur.MUST);

            //类型
            BooleanQuery typeQuery = new BooleanQuery();

            foreach (var t in dataTypes)
            {
                Query qt = new QueryParser(IndexConfiguration.LuceneMatchVersion, "datatype", analyzer).Parse(t.ToString("d"));
                typeQuery.Add(qt, Occur.SHOULD);
            }

            bquery.Add(typeQuery, Occur.MUST);

            Sort sort = new Sort(new SortField("updatetime", SortField.STRING, true));

            count = 0;

            var list = SearchHelper.Search <BaseIndexModel>(indexPath, bquery, sort, pageIndex, pageSize, out count);

            return(list);
        }
Exemple #26
0
        public void RecreateIndex(IndexConfiguration indexConfig)
        {
            var databaseDirectory = _databaseContext.DatabaseConfigurations.Storage.StorageProvider.DatabasePath +
                                    _databaseContext.DatabaseName;

            IIndex removedIndex;

            if (_indexes.TryRemove(indexConfig.Name, out removedIndex))
            {
                string attributes;
                _attributeToNameReference.TryRemove(removedIndex.IndexKey.ToString(), out attributes);
            }

            IIndex index = new BPlusIndex(indexConfig, _collectionName, databaseDirectory, this);

            if (!_attributeToNameReference.TryAdd(index.IndexKey.ToString(), index.Name))
            {
                _indexes.TryAdd(removedIndex.Name, removedIndex);
                _attributeToNameReference.TryAdd(removedIndex.IndexKey.ToString(), removedIndex.Name);
                throw new IndexException(ErrorCodes.Indexes.INDEX_ALREADY_DEFINED_FOR_ATTRIBUTES,
                                         new[] { index.IndexKey.ToString() });
            }

            if (removedIndex != null)
            {
                removedIndex.Destroy();
            }
            index.Initialize();

            if (_store != null)
            {
                if (!_indexes.TryAdd(index.Name, index))
                {
                    index.Destroy();
                    if (LoggerManager.Instance.IndexLogger != null)
                    {
                        LoggerManager.Instance.IndexLogger.Error("BPlusIndex",
                                                                 "Failed to initialize index: " + index.Name + ", an index with name " +
                                                                 index.Name + "already exists. ");
                    }
                }

                PopulateIndex(index, _store);
            }
        }
Exemple #27
0
        public void ValidConfigurationWithIndex()
        {
            // Declare configuration name
            string fileName = this.FileSystem.Path.Combine("Config", "WithIndex.json");

            // Load configuration
            IndexConfiguration indexConfiguration = this.ConfigurationLoader.Load(".", fileName);

            Configuration[] configurations = indexConfiguration.Configurations;

            // Assert
            Assert.AreEqual("Index title", indexConfiguration.Title);
            Assert.AreEqual("Index description", indexConfiguration.Description);
            Assert.IsNotNull(indexConfiguration.Template);
            Assert.AreEqual("index.html", indexConfiguration.Output);
            Assert.AreEqual("index-icon.png", indexConfiguration.Icon);
            Assert.AreEqual(1, configurations.Length);
        }
        /// <summary>
        /// 搜索指定类型的数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dataType"></param>
        /// <param name="areaID"></param>
        /// <param name="keyword"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        private List <T> SearchData <T>(IndexDataType dataType, int?areaID, string keyword, int pageIndex, int pageSize, out int count) where T : BaseIndexModel
        {
            string indexPath = string.Empty;

            switch (dataType)
            {
            case IndexDataType.Job: indexPath = IndexConfiguration.GetJobPath(); break;

            case IndexDataType.MallProduct: indexPath = IndexConfiguration.GetMallProductPath(); break;

            case IndexDataType.Merchant: indexPath = IndexConfiguration.GetMerchantPath(); break;

            case IndexDataType.MerchantProduct: indexPath = IndexConfiguration.GetMerchantProductPath(); break;
            }

            List <string> fields = new List <string> {
                "name"
            };                                                //, "desc"

            BooleanQuery bquery = new BooleanQuery();

            //分词器
            Analyzer analyzer = new StandardAnalyzer(IndexConfiguration.LuceneMatchVersion);

            //搜索条件
            Query kwdQuery = MultiFieldQueryParser.Parse(IndexConfiguration.LuceneMatchVersion, keyword, fields.ToArray(), new Occur[] { Occur.SHOULD }, analyzer);//, Occur.SHOULD

            bquery.Add(kwdQuery, Occur.MUST);

            if (areaID.HasValue && areaID.Value > 0)
            {
                Query query = new QueryParser(IndexConfiguration.LuceneMatchVersion, "areaid", analyzer).Parse(areaID.Value.ToString());

                bquery.Add(query, Occur.MUST);
            }

            Sort sort = new Sort(new SortField("updatetime", SortField.STRING, true));

            count = 0;

            var list = SearchHelper.Search <T>(indexPath, bquery, sort, pageIndex, pageSize, out count);

            return(list);
        }
Exemple #29
0
 internal IndexValueDetail(string nodeName,
                           IndexConfiguration configuration, string[] pathChunks, string databaseName)
 {
     _databaseName  = databaseName;
     NodeName       = nodeName;
     NodeType       = PathType.Index;
     IsContainer    = true;
     IsValid        = true;
     Configuration  = configuration;
     PathChunks     = pathChunks;
     ChilderanTable = new PrintableTable();
     ChilderanName  = new List <string>();
     ChilderanTable.AddHeader("Attribute Name", "Order");
     if (configuration.Attributes != null)
     {
         ChilderanTable.AddRow(configuration.Attributes.Name, configuration.Attributes.Order);
         ChilderanName.Add(configuration.Attributes.Name);
     }
 }
        public override bool TryGetNodeDetail(out NodeDetail nodeDetail)
        {
            NodeDetail thisNode = null;
            bool       sucess   = false;

            if (((Indices)Configuration).ContainsIndex(PathChunks[0]))
            {
                IndexConfiguration dbconfig        = (((Indices)Configuration).GetIndex(PathChunks[0]));
                string[]           childPathChunks = new string[this.PathChunks.Length - 1];
                Array.Copy(this.PathChunks, 1, childPathChunks, 0, this.PathChunks.Length - 1);
                thisNode = new IndexValueDetail(PathChunks[0], dbconfig, childPathChunks, _databaseName);
                sucess   = true;
            }
            if (PathChunks.Length == 1)
            {
                nodeDetail = new EndNodeDetail();
                return(sucess);
            }
            return(thisNode.TryGetNodeDetail(out nodeDetail));
        }
Exemple #31
0
        public void ManyErrors()
        {
            // Try to generate configuration with error
            try
            {
                // Declare configuration name
                string fileName = this.FileSystem.Path.Combine("Config", "ManyErrors.json");

                // Load configuration
                IndexConfiguration indexConfiguration = this.ConfigurationLoader.Load(".", fileName);
                Configuration[]    configurations     = indexConfiguration.Configurations;

                // Assert
                Assert.Fail("Expected to fail");
            }
            // Assert correct error
            catch (ConfigurationException argumentException)
            {
                Assert.AreEqual("Error occured during configuration loading", argumentException.Message);
                Assert.AreEqual(6, argumentException.GenerationErrors.Length);
                Assert.AreEqual("Could not find index template 'Template/NotExisting.txt'", argumentException.GenerationErrors[0].Message);
                Assert.AreEqual(3, argumentException.GenerationErrors[0].Line);
                Assert.AreEqual(16, argumentException.GenerationErrors[0].Column);
                Assert.AreEqual("Could not find html template 'Template/NotExisting.txt'", argumentException.GenerationErrors[1].Message);
                Assert.AreEqual(7, argumentException.GenerationErrors[1].Line);
                Assert.AreEqual(25, argumentException.GenerationErrors[1].Column);
                Assert.AreEqual("Could not find html template 'Template/NotExisting-pdf.txt'", argumentException.GenerationErrors[2].Message);
                Assert.AreEqual(29, argumentException.GenerationErrors[2].Line);
                Assert.AreEqual(24, argumentException.GenerationErrors[2].Column);
                Assert.AreEqual("Could not find page 'Page/NotExisting.md'", argumentException.GenerationErrors[3].Message);
                Assert.AreEqual(13, argumentException.GenerationErrors[3].Line);
                Assert.AreEqual(20, argumentException.GenerationErrors[3].Column);
                Assert.AreEqual("Could not find page 'Page/NotExisting.md'", argumentException.GenerationErrors[4].Message);
                Assert.AreEqual(21, argumentException.GenerationErrors[4].Line);
                Assert.AreEqual(20, argumentException.GenerationErrors[4].Column);
                Assert.AreEqual("Could not find page 'Page\\AnotherNotExisting.md'", argumentException.GenerationErrors[5].Message);
                Assert.AreEqual(17, argumentException.GenerationErrors[5].Line);
                Assert.AreEqual(20, argumentException.GenerationErrors[5].Column);
            }
        }
Exemple #32
0
 public IndexReader(IndexConfiguration indexConfiguration, global::Lucene.Net.Index.IndexReader indexReader)
 {
     _indexReader = indexReader;
     _indexConfiguration = indexConfiguration;
 }
Exemple #33
0
        /// <summary>
        /// Initializes a new instance of <see cref="ProjbookEngine"/>.
        /// </summary>
        /// <param name="fileSystem">Initializes the required file system abstraction.</param>
        /// <param name="extensionPath">Initializes the required extension path.</param>
        /// <param name="csprojFile">Initializes the required <see cref="CsprojFile"/>.</param>
        /// <param name="indexConfiguration">Initializes the required <see cref="IndexConfiguration"/>.</param>
        /// <param name="outputDirectoryPath">Initializes the required <see cref="OutputDirectory"/>.</param>
        /// <param name="skipPdf">Initializes the required <see cref="SkipPdf"/>.</param>
        public ProjbookEngine(IFileSystem fileSystem, string csprojFile, string extensionPath, IndexConfiguration indexConfiguration, string outputDirectoryPath, bool skipPdf)
        {
            // Data validation
            Ensure.That(() => fileSystem).IsNotNull();
            Ensure.That(() => csprojFile).IsNotNullOrWhiteSpace();
            Ensure.That(() => indexConfiguration).IsNotNull();
            Ensure.That(() => indexConfiguration.Configurations).HasItems();
            Ensure.That(() => outputDirectoryPath).IsNotNullOrWhiteSpace();
            Ensure.That(fileSystem.File.Exists(csprojFile), string.Format("Could not find '{0}' file", csprojFile)).IsTrue();

            // Initialize
            this.fileSystem              = fileSystem;
            this.CsprojFile              = this.fileSystem.FileInfo.FromFileName(csprojFile);
            this.IndexConfiguration      = indexConfiguration;
            this.OutputDirectory         = this.fileSystem.DirectoryInfo.FromDirectoryName(outputDirectoryPath);
            this.snippetExtractorFactory = new SnippetExtractorFactory(this.fileSystem.DirectoryInfo.FromDirectoryName(this.fileSystem.Path.GetFullPath(extensionPath)));
            this.SkipPdf = skipPdf;
        }
        public void ShouldThrowExceptionIfHttpCodeIsNot201(
            IndexFor indexFor,
            IndexProvider indexProvider,
            IndexType indexType,
            string createEndpoint,
            string createJson)
        {
            //Arrange
            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostJson(createEndpoint, createJson),
                    MockResponse.Http(500)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                var indexConfiguration = new IndexConfiguration
                {
                    Provider = indexProvider,
                    Type = indexType
                };
                Assert.Throws<Exception>(() => graphClient.CreateIndex("foo", indexConfiguration, indexFor));
            }
        }
 private MallProductIndexManager()
 {
     _config           = new IndexConfig();
     _config.IndexPath = IndexConfiguration.GetMallProductPath();
 }
 public IndexController(IndexConfiguration configuration, Func<IFrameworkContext> frameworkContextGetter)
     : this(configuration, (IFrameworkContext)null)
 {
     _frameworkContextGetter = frameworkContextGetter;
 }