From c48f36f6a23e771e1e583cff5b20fdcb2ffae82a Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 3 Apr 2020 15:36:57 +1100 Subject: [PATCH] Even more IOHelper reduction, fixes some tests --- src/Umbraco.Core/IO/PhysicalFileSystem.cs | 1 + src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs | 9 +++++---- .../LuceneIndexDiagnosticsFactory.cs | 9 +++++---- src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs | 7 ++++--- src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs | 7 ++++--- .../UmbracoExamineIndexDiagnostics.cs | 5 +++-- .../UmbracoIndexesCreator.cs | 15 ++++++++------- src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs | 8 +++++--- .../Packaging/PackageExtractionTests.cs | 3 ++- .../PublishedContent/PublishedMediaTests.cs | 14 +++++++------- src/Umbraco.Tests/UmbracoExamine/EventsTest.cs | 2 +- .../UmbracoExamine/IndexInitializer.cs | 5 +++-- src/Umbraco.Tests/UmbracoExamine/IndexTest.cs | 14 +++++++------- src/Umbraco.Tests/UmbracoExamine/SearchTests.cs | 2 +- .../AspNet/AspNetHostingEnvironment.cs | 2 +- 15 files changed, 57 insertions(+), 46 deletions(-) diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index 52c210ad28..403557958a 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -59,6 +59,7 @@ namespace Umbraco.Core.IO if (Path.IsPathRooted(rootPath) == false) { // but the test suite App.config cannot really "root" anything so we have to do it here + // TODO: This will map to the web content root (www) not the web app root, is that what we want? Else we need to use IHostingEnvironment.ApplicationPhysicalPath var localRoot = _ioHelper.MapPath("~"); rootPath = Path.Combine(localRoot, rootPath); } diff --git a/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs b/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs index b1d529e6c6..df230bc3da 100644 --- a/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs +++ b/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs @@ -7,6 +7,7 @@ using Lucene.Net.Store; using Umbraco.Core.Configuration; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Hosting; using Umbraco.Core.IO; namespace Umbraco.Examine @@ -18,13 +19,13 @@ namespace Umbraco.Examine public abstract class LuceneIndexCreator : IIndexCreator { private readonly ITypeFinder _typeFinder; - private readonly IIOHelper _ioHelper; + private readonly IHostingEnvironment _hostingEnvironment; private readonly IIndexCreatorSettings _settings; - protected LuceneIndexCreator(ITypeFinder typeFinder, IIOHelper ioHelper, IIndexCreatorSettings settings) + protected LuceneIndexCreator(ITypeFinder typeFinder, IHostingEnvironment hostingEnvironment, IIndexCreatorSettings settings) { _typeFinder = typeFinder; - _ioHelper = ioHelper; + _hostingEnvironment = hostingEnvironment; _settings = settings; } @@ -40,7 +41,7 @@ namespace Umbraco.Examine public virtual Lucene.Net.Store.Directory CreateFileSystemLuceneDirectory(string folderName) { - var dirInfo = new DirectoryInfo(Path.Combine(_ioHelper.MapPath(Constants.SystemDirectories.TempData), "ExamineIndexes", folderName)); + var dirInfo = new DirectoryInfo(Path.Combine(_hostingEnvironment.MapPath(Constants.SystemDirectories.TempData), "ExamineIndexes", folderName)); if (!dirInfo.Exists) System.IO.Directory.CreateDirectory(dirInfo.FullName); diff --git a/src/Umbraco.Examine.Lucene/LuceneIndexDiagnosticsFactory.cs b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnosticsFactory.cs index cc1fc115ca..9141f7f6dd 100644 --- a/src/Umbraco.Examine.Lucene/LuceneIndexDiagnosticsFactory.cs +++ b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnosticsFactory.cs @@ -1,5 +1,6 @@ using Examine; using Examine.LuceneEngine.Providers; +using Umbraco.Core.Hosting; using Umbraco.Core.Logging; using Umbraco.Core.IO; @@ -12,12 +13,12 @@ namespace Umbraco.Examine public class LuceneIndexDiagnosticsFactory : IndexDiagnosticsFactory { private readonly ILogger _logger; - private readonly IIOHelper _ioHelper; + private readonly IHostingEnvironment _hostingEnvironment; - public LuceneIndexDiagnosticsFactory(ILogger logger, IIOHelper ioHelper) + public LuceneIndexDiagnosticsFactory(ILogger logger, IHostingEnvironment hostingEnvironment) { _logger = logger; - _ioHelper = ioHelper; + _hostingEnvironment = hostingEnvironment; } public override IIndexDiagnostics Create(IIndex index) @@ -25,7 +26,7 @@ namespace Umbraco.Examine if (!(index is IIndexDiagnostics indexDiag)) { if (index is LuceneIndex luceneIndex) - indexDiag = new LuceneIndexDiagnostics(luceneIndex, _logger, _ioHelper); + indexDiag = new LuceneIndexDiagnostics(luceneIndex, _logger, _hostingEnvironment); else indexDiag = base.Create(index); } diff --git a/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs index 1c8cd4b074..70b44340bd 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs @@ -11,6 +11,7 @@ using Lucene.Net.Store; using Umbraco.Core.Composing; using Umbraco.Core.Logging; using Examine.LuceneEngine; +using Umbraco.Core.Hosting; using Umbraco.Core.IO; namespace Umbraco.Examine @@ -33,7 +34,7 @@ namespace Umbraco.Examine /// /// /// - /// + /// /// /// /// @@ -44,12 +45,12 @@ namespace Umbraco.Examine FieldDefinitionCollection fieldDefinitions, Analyzer defaultAnalyzer, IProfilingLogger profilingLogger, - IIOHelper ioHelper, + IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, ILocalizationService languageService, IContentValueSetValidator validator, IReadOnlyDictionary indexValueTypes = null) - : base(name, luceneDirectory, fieldDefinitions, defaultAnalyzer, profilingLogger, ioHelper, runtimeState, validator, indexValueTypes) + : base(name, luceneDirectory, fieldDefinitions, defaultAnalyzer, profilingLogger, hostingEnvironment, runtimeState, validator, indexValueTypes) { if (validator == null) throw new ArgumentNullException(nameof(validator)); LanguageService = languageService ?? throw new ArgumentNullException(nameof(languageService)); diff --git a/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs index 880440f4f9..696c6a58a5 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs @@ -9,6 +9,7 @@ using Umbraco.Core; using Examine; using Examine.LuceneEngine; using Lucene.Net.Store; +using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Directory = Lucene.Net.Store.Directory; @@ -38,7 +39,7 @@ namespace Umbraco.Examine /// /// /// - /// + /// /// /// /// @@ -48,7 +49,7 @@ namespace Umbraco.Examine FieldDefinitionCollection fieldDefinitions, Analyzer defaultAnalyzer, IProfilingLogger profilingLogger, - IIOHelper ioHelper, + IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, IValueSetValidator validator = null, IReadOnlyDictionary indexValueTypes = null) @@ -61,7 +62,7 @@ namespace Umbraco.Examine if (luceneDirectory is FSDirectory fsDir) LuceneIndexFolder = fsDir.Directory; - _diagnostics = new UmbracoExamineIndexDiagnostics(this, ProfilingLogger, ioHelper); + _diagnostics = new UmbracoExamineIndexDiagnostics(this, ProfilingLogger, hostingEnvironment); } private readonly bool _configBased = false; diff --git a/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs index 2ac8fde960..777b198232 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs @@ -2,6 +2,7 @@ using System.Linq; using Lucene.Net.Store; using Umbraco.Core; +using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; @@ -11,8 +12,8 @@ namespace Umbraco.Examine { private readonly UmbracoExamineIndex _index; - public UmbracoExamineIndexDiagnostics(UmbracoExamineIndex index, ILogger logger, IIOHelper ioHelper) - : base(index, logger, ioHelper) + public UmbracoExamineIndexDiagnostics(UmbracoExamineIndex index, ILogger logger, IHostingEnvironment hostingEnvironment) + : base(index, logger, hostingEnvironment) { _index = index; } diff --git a/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs b/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs index 0f60a7580c..3cf7d6d386 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoIndexesCreator.cs @@ -7,6 +7,7 @@ using Examine; using Umbraco.Core.Configuration; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Hosting; using Umbraco.Core.IO; namespace Umbraco.Examine @@ -25,21 +26,21 @@ namespace Umbraco.Examine IPublicAccessService publicAccessService, IMemberService memberService, IUmbracoIndexConfig umbracoIndexConfig, - IIOHelper ioHelper, + IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, - IIndexCreatorSettings settings) : base(typeFinder, ioHelper, settings) + IIndexCreatorSettings settings) : base(typeFinder, hostingEnvironment, settings) { ProfilingLogger = profilingLogger ?? throw new System.ArgumentNullException(nameof(profilingLogger)); LanguageService = languageService ?? throw new System.ArgumentNullException(nameof(languageService)); PublicAccessService = publicAccessService ?? throw new System.ArgumentNullException(nameof(publicAccessService)); MemberService = memberService ?? throw new System.ArgumentNullException(nameof(memberService)); UmbracoIndexConfig = umbracoIndexConfig; - IOHelper = ioHelper ?? throw new System.ArgumentNullException(nameof(ioHelper)); + HostingEnvironment = hostingEnvironment ?? throw new System.ArgumentNullException(nameof(hostingEnvironment)); RuntimeState = runtimeState ?? throw new System.ArgumentNullException(nameof(runtimeState)); } protected IProfilingLogger ProfilingLogger { get; } - protected IIOHelper IOHelper { get; } + protected IHostingEnvironment HostingEnvironment { get; } protected IRuntimeState RuntimeState { get; } protected ILocalizationService LanguageService { get; } protected IPublicAccessService PublicAccessService { get; } @@ -68,7 +69,7 @@ namespace Umbraco.Examine new UmbracoFieldDefinitionCollection(), new CultureInvariantWhitespaceAnalyzer(), ProfilingLogger, - IOHelper, + HostingEnvironment, RuntimeState, LanguageService, UmbracoIndexConfig.GetContentValueSetValidator() @@ -84,7 +85,7 @@ namespace Umbraco.Examine new UmbracoFieldDefinitionCollection(), new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), ProfilingLogger, - IOHelper, + HostingEnvironment, RuntimeState, LanguageService, UmbracoIndexConfig.GetPublishedContentValueSetValidator()); @@ -99,7 +100,7 @@ namespace Umbraco.Examine CreateFileSystemLuceneDirectory(Constants.UmbracoIndexes.MembersIndexPath), new CultureInvariantWhitespaceAnalyzer(), ProfilingLogger, - IOHelper, + HostingEnvironment, RuntimeState, UmbracoIndexConfig.GetMemberValueSetValidator() ); diff --git a/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs index 0e9128d31a..12678fa00a 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoMemberIndex.cs @@ -1,6 +1,7 @@ using Examine; using Lucene.Net.Analysis; using Umbraco.Core; +using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Directory = Lucene.Net.Store.Directory; @@ -20,7 +21,8 @@ namespace Umbraco.Examine /// /// /// - /// + /// + /// /// /// public UmbracoMemberIndex( @@ -29,10 +31,10 @@ namespace Umbraco.Examine Directory luceneDirectory, Analyzer analyzer, IProfilingLogger profilingLogger, - IIOHelper ioHelper, + IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, IValueSetValidator validator = null) : - base(name, luceneDirectory, fieldDefinitions, analyzer, profilingLogger, ioHelper, runtimeState, validator) + base(name, luceneDirectory, fieldDefinitions, analyzer, profilingLogger, hostingEnvironment, runtimeState, validator) { } diff --git a/src/Umbraco.Tests/Packaging/PackageExtractionTests.cs b/src/Umbraco.Tests/Packaging/PackageExtractionTests.cs index 83620d35f5..20efc422f4 100644 --- a/src/Umbraco.Tests/Packaging/PackageExtractionTests.cs +++ b/src/Umbraco.Tests/Packaging/PackageExtractionTests.cs @@ -17,7 +17,8 @@ namespace Umbraco.Tests.Packaging private static FileInfo GetTestPackagePath(string packageName) { const string testPackagesDirName = "Packaging\\Packages"; - string path = Path.Combine(TestHelper.IOHelper.MapPath("~"), testPackagesDirName, packageName); + var hosting = TestHelper.GetHostingEnvironment(); + string path = Path.Combine(hosting.ApplicationPhysicalPath, testPackagesDirName, packageName); return new FileInfo(path); } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs index 1aa049e25e..854e24d162 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs @@ -120,7 +120,7 @@ namespace Umbraco.Tests.PublishedContent var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockMediaService()); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(true))) using (indexer.ProcessNonAsync()) { @@ -149,7 +149,7 @@ namespace Umbraco.Tests.PublishedContent var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockMediaService()); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, //include unpublished content since this uses the 'internal' indexer, it's up to the media cache to filter validator: new ContentValueSetValidator(false))) using (indexer.ProcessNonAsync()) @@ -197,7 +197,7 @@ namespace Umbraco.Tests.PublishedContent var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockMediaService()); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(true))) using (indexer.ProcessNonAsync()) { @@ -225,7 +225,7 @@ namespace Umbraco.Tests.PublishedContent var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockMediaService()); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(true))) using (indexer.ProcessNonAsync()) { @@ -253,7 +253,7 @@ namespace Umbraco.Tests.PublishedContent var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockMediaService()); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(true))) using (indexer.ProcessNonAsync()) { @@ -282,7 +282,7 @@ namespace Umbraco.Tests.PublishedContent using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(true))) using (indexer.ProcessNonAsync()) { @@ -307,7 +307,7 @@ namespace Umbraco.Tests.PublishedContent var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockMediaService()); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(true))) using (indexer.ProcessNonAsync()) { diff --git a/src/Umbraco.Tests/UmbracoExamine/EventsTest.cs b/src/Umbraco.Tests/UmbracoExamine/EventsTest.cs index 20e774c78a..6eb4a17dcf 100644 --- a/src/Umbraco.Tests/UmbracoExamine/EventsTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/EventsTest.cs @@ -19,7 +19,7 @@ namespace Umbraco.Tests.UmbracoExamine public void Events_Ignoring_Node() { using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, //make parent id 999 so all are ignored validator: new ContentValueSetValidator(false, 999))) using (indexer.ProcessNonAsync()) diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs index 76ada2169e..b97d3de141 100644 --- a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs +++ b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs @@ -8,6 +8,7 @@ using Lucene.Net.Analysis.Standard; using Lucene.Net.Store; using Moq; using Umbraco.Core; +using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; @@ -155,7 +156,7 @@ namespace Umbraco.Tests.UmbracoExamine public static UmbracoContentIndex GetUmbracoIndexer( IProfilingLogger profilingLogger, - IIOHelper ioHelper, + IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, Directory luceneDir, Analyzer analyzer = null, @@ -177,7 +178,7 @@ namespace Umbraco.Tests.UmbracoExamine new UmbracoFieldDefinitionCollection(), analyzer, profilingLogger, - ioHelper, + hostingEnvironment, runtimeState, languageService, validator); diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs index e6fe5170e4..f4ec4dbd1e 100644 --- a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs @@ -33,7 +33,7 @@ namespace Umbraco.Tests.UmbracoExamine var contentValueSetBuilder = IndexInitializer.GetContentValueSetBuilder(Factory.GetInstance(), false); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(false))) using (indexer.ProcessNonAsync()) { @@ -126,7 +126,7 @@ namespace Umbraco.Tests.UmbracoExamine var mediaRebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockMediaService()); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(false))) using (indexer.ProcessNonAsync()) { @@ -154,7 +154,7 @@ namespace Umbraco.Tests.UmbracoExamine using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir)) + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir)) using (indexer.ProcessNonAsync()) using (var searcher = ((LuceneSearcher)indexer.GetSearcher()).GetLuceneSearcher()) { @@ -191,7 +191,7 @@ namespace Umbraco.Tests.UmbracoExamine var validator = new ContentValueSetValidator(false, 1116); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, validator: validator)) + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: validator)) using (indexer.ProcessNonAsync()) { var searcher = indexer.GetSearcher(); @@ -234,7 +234,7 @@ namespace Umbraco.Tests.UmbracoExamine var validator = new ContentValueSetValidator(false, 2222); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer1 = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, validator: validator)) + using (var indexer1 = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: validator)) using (indexer1.ProcessNonAsync()) { var searcher = indexer1.GetSearcher(); @@ -277,7 +277,7 @@ namespace Umbraco.Tests.UmbracoExamine { var rebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockContentService(), ScopeProvider.SqlContext, false); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir, + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir, validator: new ContentValueSetValidator(false))) using (indexer.ProcessNonAsync()) { @@ -319,7 +319,7 @@ namespace Umbraco.Tests.UmbracoExamine var rebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetInstance(), IndexInitializer.GetMockContentService(), ScopeProvider.SqlContext, false); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir)) + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir)) using (indexer.ProcessNonAsync()) { var searcher = indexer.GetSearcher(); diff --git a/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs b/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs index dc4f68e823..d722bf89ae 100644 --- a/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs +++ b/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs @@ -58,7 +58,7 @@ namespace Umbraco.Tests.UmbracoExamine var rebuilder = IndexInitializer.GetContentIndexRebuilder(propertyEditors, contentService, ScopeProvider.SqlContext, true); using (var luceneDir = new RandomIdRamDirectory()) - using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, IOHelper, RuntimeState, luceneDir)) + using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir)) using (indexer.ProcessNonAsync()) { indexer.CreateIndex(); diff --git a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs index b9791b99dd..59271bf88d 100644 --- a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs +++ b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs @@ -21,7 +21,7 @@ namespace Umbraco.Web.Hosting ApplicationId = HostingEnvironment.ApplicationID; // when we are not hosted (i.e. unit test or otherwise) we'll need to get the root path from the executing assembly ApplicationPhysicalPath = HostingEnvironment.ApplicationPhysicalPath ?? Assembly.GetExecutingAssembly().GetRootDirectorySafe(); - ApplicationVirtualPath = hostingSettings.ApplicationVirtualPath ?? HostingEnvironment.ApplicationVirtualPath.EnsureStartsWith("/"); + ApplicationVirtualPath = hostingSettings.ApplicationVirtualPath ?? HostingEnvironment.ApplicationVirtualPath?.EnsureStartsWith("/") ?? "/"; IISVersion = HttpRuntime.IISVersion; }