public void Default_database_path_settings() { var config = RavenConfiguration.CreateForTesting("foo", ResourceType.Database, _emptySettingFile); config.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true"); config.Initialize(); Assert.Equal(new PathSetting("Databases/foo").FullPath, config.Core.DataDirectory.FullPath); Assert.Equal(new PathSetting("Databases/foo/Indexes").FullPath, config.Indexing.StoragePath.FullPath); Assert.Null(config.Indexing.TempPath); Assert.Null(config.Storage.TempPath); // actual configuration is created in the following manner config = RavenConfiguration.CreateForDatabase(RavenConfiguration.CreateForServer(null, _emptySettingFile), "foo"); config.Initialize(); Assert.Equal(new PathSetting("Databases/foo").FullPath, config.Core.DataDirectory.FullPath); Assert.Equal(new PathSetting("Databases/foo/Indexes").FullPath, config.Indexing.StoragePath.FullPath); Assert.Null(config.Indexing.TempPath); Assert.Null(config.Storage.TempPath); }
static CloudBackupTestBase() { var configuration = RavenConfiguration.CreateForTesting("foo", ResourceType.Database); configuration.Initialize(); DefaultConfiguration = configuration.Backup; }
public async Task CheckAnalyzers() { using (var store = GetDocumentStore()) { var configuration = RavenConfiguration.CreateForTesting("test", Raven.Server.ServerWide.ResourceType.Server); configuration.Initialize(); var database = await Databases.GetDocumentDatabaseInstanceFor(store); var index = new TestIndex(database, configuration.Indexing); var operation = new TestOperation(index, null); var fields = new Dictionary <string, IndexField>(); fields.Add(Constants.Documents.Indexing.Fields.AllFields, new IndexField()); Assert.Throws <InvalidOperationException>(() => operation.GetAnalyzer(fields, forQuerying: false)); fields.Clear(); fields.Add(Constants.Documents.Indexing.Fields.AllFields, new IndexField { Analyzer = "StandardAnalyzer" }); Assert.Throws <InvalidOperationException>(() => operation.GetAnalyzer(fields, forQuerying: false)); fields.Clear(); fields.Add("Field1", new IndexField { Analyzer = "StandardAnalyzer" }); // field must be 'NotAnalyzed' or 'Analyzed' var analyzer = operation.GetAnalyzer(fields, forQuerying: false); Assert.IsType <LowerCaseKeywordAnalyzer>(analyzer.GetAnalyzer(string.Empty)); Assert.IsType <LowerCaseKeywordAnalyzer>(analyzer.GetAnalyzer("Field1")); fields.Clear(); fields.Add("Field1", new IndexField { Name = "Field1", Analyzer = "StandardAnalyzer", Indexing = FieldIndexing.Exact }); // 'NotAnalyzed' => 'KeywordAnalyzer' analyzer = operation.GetAnalyzer(fields, forQuerying: false); Assert.IsType <LowerCaseKeywordAnalyzer>(analyzer.GetAnalyzer(string.Empty)); Assert.IsType <KeywordAnalyzer>(analyzer.GetAnalyzer("Field1")); fields.Clear(); fields.Add("Field1", new IndexField { Name = "Field1", Analyzer = null, Indexing = FieldIndexing.Search }); // 'Analyzed = null' => 'StandardAnalyzer' analyzer = operation.GetAnalyzer(fields, forQuerying: false); Assert.IsType <LowerCaseKeywordAnalyzer>(analyzer.GetAnalyzer(string.Empty)); Assert.IsType <RavenStandardAnalyzer>(analyzer.GetAnalyzer("Field1")); fields.Clear(); fields.Add("Field1", new IndexField { Name = "Field1", Analyzer = typeof(NotForQueryingAnalyzer).AssemblyQualifiedName, Indexing = FieldIndexing.Search }); analyzer = operation.GetAnalyzer(fields, forQuerying: false); Assert.IsType <LowerCaseKeywordAnalyzer>(analyzer.GetAnalyzer(string.Empty)); Assert.IsType <NotForQueryingAnalyzer>(analyzer.GetAnalyzer("Field1")); fields.Clear(); fields.Add("Field1", new IndexField { Name = "Field1", Analyzer = typeof(NotForQueryingAnalyzer).AssemblyQualifiedName, Indexing = FieldIndexing.Search }); analyzer = operation.GetAnalyzer(fields, forQuerying: true); Assert.IsType <LowerCaseKeywordAnalyzer>(analyzer.GetAnalyzer(string.Empty)); Assert.IsType <RavenStandardAnalyzer>(analyzer.GetAnalyzer("Field1")); fields.Clear(); fields.Add("Field1", new IndexField { Name = "Field1", Analyzer = typeof(NotForQueryingAnalyzer).AssemblyQualifiedName, Indexing = FieldIndexing.Search }); fields.Add("Field2", new IndexField { Name = "Field2", Analyzer = "KeywordAnalyzer", Indexing = FieldIndexing.Search }); analyzer = operation.GetAnalyzer(fields, forQuerying: false); Assert.IsType <LowerCaseKeywordAnalyzer>(analyzer.GetAnalyzer(string.Empty)); Assert.IsType <NotForQueryingAnalyzer>(analyzer.GetAnalyzer("Field1")); Assert.IsType <KeywordAnalyzer>(analyzer.GetAnalyzer("Field2")); } }