public void Setup() { _register = RegisterFactory.Create(); var composition = new Composition(_register, new TypeLoader(), Mock.Of <IProfilingLogger>(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); composition.Register(_ => Mock.Of <ILogger>()); composition.Register(_ => Mock.Of <IDataTypeService>()); composition.Register(_ => Mock.Of <IContentSection>()); composition.RegisterUnique <IMediaPathScheme, OriginalMediaPathScheme>(); composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); composition.ComposeFileSystems(); composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); _factory = composition.CreateFactory(); Current.Reset(); Current.Factory = _factory; // make sure we start clean // because some tests will create corrupt or weird filesystems FileSystems.Reset(); }
/// <summary> /// This function will parse and check the virtual file system for the game files /// </summary> public override void DiscoverLayout() { // Clear possibly old data. Packages.Clear(); Superbundles.Clear(); FileSystems.Clear(); AuthoritativePackage = null; Layout = null; // Try to find a Data directory if (!FileSystem.DirectoryExists("/game/Data")) #if DEBUG { throw new Exception("Failed to find the Data directory. Content mounting failed."); } #else { return; } #endif // Discover any packages that might exist. if (FileSystem.DirectoryExists("/game/Update")) { DiscoverPackages(); } // Parse the base Layout file. ParseLayout(); // Discover available superbundles. DiscoverSuperbundles(); // Discover filesystems. DiscoverFileSystems(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldContinueAfterError() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldContinueAfterError() { DiagnosticsReporter reporter = new DiagnosticsReporter(); MyProvider myProvider = new MyProvider(_fileSystem); reporter.RegisterOfflineProvider(myProvider); myProvider.AddFile("logs/a.txt", CreateNewFileWithContent("a.txt", "file a")); Path destination = _testDirectory.file("logs.zip").toPath(); ISet <string> classifiers = new HashSet <string>(); classifiers.Add("logs"); classifiers.Add("fail"); using (MemoryStream baos = new MemoryStream()) { PrintStream @out = new PrintStream(baos); NonInteractiveProgress progress = new NonInteractiveProgress(@out, false); reporter.Dump(classifiers, destination, progress, true); assertThat(baos.ToString(), @is(string.Format("1/2 fail.txt%n" + ".................... 20%%%n" + "..........%n" + "Error: Step failed%n" + "2/2 logs/a.txt%n" + ".................... 20%%%n" + ".................... 40%%%n" + ".................... 60%%%n" + ".................... 80%%%n" + ".................... 100%%%n%n"))); } // Verify content URI uri = URI.create("jar:file:" + destination.toAbsolutePath().toUri().RawPath); using (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { IList <string> fileA = Files.readAllLines(fs.getPath("logs/a.txt")); assertEquals(1, fileA.Count); assertEquals("file a", fileA[0]); } }
private ScopeProvider GetScopeProvider(out Mock <IEventAggregator> eventAggregatorMock) { var loggerFactory = NullLoggerFactory.Instance; var fileSystems = new FileSystems( loggerFactory, Mock.Of <IIOHelper>(), Options.Create(new GlobalSettings()), Mock.Of <IHostingEnvironment>()); var mediaFileManager = new MediaFileManager( Mock.Of <IFileSystem>(), Mock.Of <IMediaPathScheme>(), loggerFactory.CreateLogger <MediaFileManager>(), Mock.Of <IShortStringHelper>(), Mock.Of <IServiceProvider>(), Options.Create(new ContentSettings())); eventAggregatorMock = new Mock <IEventAggregator>(); return(new ScopeProvider( new AmbientScopeStack(), new AmbientScopeContextStack(), Mock.Of <IDistributedLockingMechanismFactory>(), Mock.Of <IUmbracoDatabaseFactory>(), fileSystems, new TestOptionsMonitor <CoreDebugSettings>(new CoreDebugSettings()), mediaFileManager, loggerFactory, eventAggregatorMock.Object)); }
private ScopeProvider GetScopeProvider(out Mock <IEventAggregator> eventAggregatorMock) { NullLoggerFactory loggerFactory = NullLoggerFactory.Instance; var fileSystems = new FileSystems( loggerFactory, Mock.Of <IIOHelper>(), Options.Create(new GlobalSettings()), Mock.Of <IHostingEnvironment>()); var mediaFileManager = new MediaFileManager( Mock.Of <IFileSystem>(), Mock.Of <IMediaPathScheme>(), loggerFactory.CreateLogger <MediaFileManager>(), Mock.Of <IShortStringHelper>(), Mock.Of <IServiceProvider>(), Options.Create(new ContentSettings())); eventAggregatorMock = new Mock <IEventAggregator>(); return(new ScopeProvider( Mock.Of <IUmbracoDatabaseFactory>(), fileSystems, Options.Create(new CoreDebugSettings()), mediaFileManager, loggerFactory.CreateLogger <ScopeProvider>(), loggerFactory, Mock.Of <IRequestCache>(), eventAggregatorMock.Object )); }
public StylesheetsTreeController( ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IMenuItemCollectionFactory menuItemCollectionFactory, FileSystems fileSystems, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator) =>
public IScopeProvider GetScopeProvider(ILoggerFactory loggerFactory, FileSystems fileSystems = null, IUmbracoDatabaseFactory databaseFactory = null) { var globalSettings = Options.Create(new GlobalSettings()); var connectionString = ConfigurationManager.ConnectionStrings[Constants.System.UmbracoConnectionName].ConnectionString; var connectionStrings = Options.Create(new ConnectionStrings { UmbracoConnectionString = new ConfigConnectionString(Constants.System.UmbracoConnectionName, connectionString) }); var coreDebugSettings = new CoreDebugSettings(); if (databaseFactory == null) { // var mappersBuilder = new MapperCollectionBuilder(Current.Container); // FIXME: // mappersBuilder.AddCore(); // var mappers = mappersBuilder.CreateCollection(); var mappers = Current.Factory.GetRequiredService <IMapperCollection>(); databaseFactory = new UmbracoDatabaseFactory( loggerFactory.CreateLogger <UmbracoDatabaseFactory>(), loggerFactory, globalSettings, connectionStrings, new Lazy <IMapperCollection>(() => mappers), TestHelper.DbProviderFactoryCreator, new DatabaseSchemaCreatorFactory(Mock.Of <ILogger <DatabaseSchemaCreator> >(), loggerFactory, new UmbracoVersion(), Mock.Of <IEventAggregator>())); } fileSystems ??= new FileSystems(loggerFactory, TestHelper.IOHelper, globalSettings, TestHelper.GetHostingEnvironment()); var coreDebug = TestHelper.CoreDebugSettings; var mediaFileManager = Mock.Of <MediaFileManager>(); var eventAggregator = Mock.Of <IEventAggregator>(); return(new ScopeProvider(databaseFactory, fileSystems, Options.Create(coreDebugSettings), mediaFileManager, loggerFactory.CreateLogger <ScopeProvider>(), loggerFactory, NoAppCache.Instance, eventAggregator)); }
public async Task ImportAsync(string path, SyncOptions options, ISession session) { using (var fs = FileSystems.Create(path)) { var selectedSynchronizers = GetSynchronizers(options.Targets); var selectedCount = selectedSynchronizers.Count; WriteSummary(fs, selectedSynchronizers); var sync = new SyncService(fs); await selectedSynchronizers.Foreach(async (synchronizer, step) => { log.WriteLine(); log.WriteLine("--------------------------------------------------------"); log.WriteLine("* STEP {0} of {1}: Importing {2} started", step, selectedCount, synchronizer.Name); log.WriteLine(); await synchronizer.ImportAsync(sync, options, session); log.WriteLine(); log.WriteLine("* STEP {0} of {1}: Importing {2} completed", step, selectedCount, synchronizer.Name); log.WriteLine("--------------------------------------------------------"); }); } }
private ScopeProvider GetScopeProvider(NullLoggerFactory instance) { var fileSystems = new FileSystems( instance, Mock.Of <IIOHelper>(), Options.Create(new GlobalSettings()), Mock.Of <IHostingEnvironment>()); var mediaFileManager = new MediaFileManager( Mock.Of <IFileSystem>(), Mock.Of <IMediaPathScheme>(), instance.CreateLogger <MediaFileManager>(), Mock.Of <IShortStringHelper>(), Mock.Of <IServiceProvider>(), Options.Create(new ContentSettings())); return(new ScopeProvider( Mock.Of <IUmbracoDatabaseFactory>(), fileSystems, Options.Create(new CoreDebugSettings()), mediaFileManager, Mock.Of <ILogger <ScopeProvider> >(), instance, Mock.Of <IRequestCache>(), Mock.Of <IEventAggregator>() )); }
// invoked by the filesystems when shadowing public ShadowFileSystems(FileSystems fileSystems, string id) { _fileSystems = fileSystems; Id = id; _fileSystems.BeginShadow(id); }
/// <summary> /// Initializes a new instance of the <see cref="CreatedPackageSchemaRepository" /> class. /// </summary> public CreatedPackageSchemaRepository( IUmbracoDatabaseFactory umbracoDatabaseFactory, IHostingEnvironment hostingEnvironment, IOptions <GlobalSettings> globalSettings, FileSystems fileSystems, IEntityXmlSerializer serializer, IDataTypeService dataTypeService, ILocalizationService localizationService, IFileService fileService, IMediaService mediaService, IMediaTypeService mediaTypeService, IContentService contentService, MediaFileManager mediaFileManager, IMacroService macroService, IContentTypeService contentTypeService, string?mediaFolderPath = null, string?tempFolderPath = null) { _umbracoDatabase = umbracoDatabaseFactory.CreateDatabase(); _hostingEnvironment = hostingEnvironment; _fileSystems = fileSystems; _serializer = serializer; _dataTypeService = dataTypeService; _localizationService = localizationService; _fileService = fileService; _mediaService = mediaService; _mediaTypeService = mediaTypeService; _contentService = contentService; _mediaFileManager = mediaFileManager; _macroService = macroService; _contentTypeService = contentTypeService; _xmlParser = new PackageDefinitionXmlParser(); _createdPackagesFolderPath = mediaFolderPath ?? Constants.SystemDirectories.CreatedPackages; _tempFolderPath = tempFolderPath ?? Constants.SystemDirectories.TempData + "/PackageFiles"; }
/// <summary> /// Create zip archive for requested <code>sourceToCompress</code>. /// If <code>sourceToCompress</code> is a directory then content of that directory and all its sub-directories will be added to the archive. /// If <code>sourceToCompress</code> does not exist or is an empty directory then archive will not be created. </summary> /// <param name="fileSystem"> source file system </param> /// <param name="sourceToCompress"> source file to compress </param> /// <param name="destinationZip"> zip file compress source to </param> /// <exception cref="IOException"> when underlying file system access produce IOException </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static void zip(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File sourceToCompress, java.io.File destinationZip) throws java.io.IOException public static void Zip(FileSystemAbstraction fileSystem, File sourceToCompress, File destinationZip) { if (!fileSystem.FileExists(sourceToCompress)) { return; } if (IsEmptyDirectory(fileSystem, sourceToCompress)) { return; } IDictionary <string, string> env = MapUtil.stringMap("create", "true"); Path rootPath = sourceToCompress.toPath(); URI archiveAbsoluteURI = URI.create("jar:file:" + destinationZip.toURI().RawPath); using (FileSystem zipFs = FileSystems.newFileSystem(archiveAbsoluteURI, env)) { IList <FileHandle> fileHandles = fileSystem.StreamFilesRecursive(sourceToCompress).collect(toList()); foreach (FileHandle fileHandle in fileHandles) { Path sourcePath = fileHandle.File.toPath(); Path zipFsPath = fileSystem.IsDirectory(sourceToCompress) ? zipFs.getPath(rootPath.relativize(sourcePath).ToString()) : zipFs.getPath(sourcePath.FileName.ToString()); if (zipFsPath.Parent != null) { Files.createDirectories(zipFsPath.Parent); } Files.copy(sourcePath, zipFsPath); } } }
private void CreateIndexButton_Click(object sender, EventArgs e) { java.nio.file.Path idxPath = FileSystems.getDefault().getPath(IndexDir); FSDirectory dir = FSDirectory.Open(idxPath); JapaneseAnalyzer analyzer = new JapaneseAnalyzer(); IndexWriterConfig config = new IndexWriterConfig(analyzer); IndexWriter writer = new IndexWriter(dir, config); string[] files = System.IO.Directory.GetFiles(this.TargetDirText.Text, "*.htm*", System.IO.SearchOption.AllDirectories); try { foreach (string file in files) { string title, content, f; title = ""; content = ""; f = file; HTMLParse(ref title, ref content, ref f); Field fldTitle = new StringField("title", title, FieldStore.YES); Field fldPlace = new StringField("place", f, FieldStore.YES); Field fldContent = new TextField("content", content, FieldStore.YES); Document doc = new Document(); doc.Add(fldTitle); doc.Add(fldPlace); doc.Add(fldContent); writer.AddDocument(doc); } } catch (System.IO.IOException ex) { System.Console.WriteLine(ex.ToString()); } writer.Close(); }
public ScopeProvider( IAmbientScopeStack ambientScopeStack, IAmbientScopeContextStack ambientContextStack, IDistributedLockingMechanismFactory distributedLockingMechanismFactory, IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, IOptionsMonitor <CoreDebugSettings> coreDebugSettings, MediaFileManager mediaFileManager, ILoggerFactory loggerFactory, IEventAggregator eventAggregator) { DistributedLockingMechanismFactory = distributedLockingMechanismFactory; DatabaseFactory = databaseFactory; _ambientScopeStack = ambientScopeStack; _ambientContextStack = ambientContextStack; _fileSystems = fileSystems; _coreDebugSettings = coreDebugSettings.CurrentValue; _mediaFileManager = mediaFileManager; _logger = loggerFactory.CreateLogger <ScopeProvider>(); _loggerFactory = loggerFactory; _eventAggregator = eventAggregator; // take control of the FileSystems _fileSystems.IsScoped = () => AmbientScope != null && AmbientScope.ScopedFileSystems; coreDebugSettings.OnChange(x => _coreDebugSettings = x); }
public override void TearDown() { base.TearDown(); SafeCallContext.Clear(); FileSystems.ResetShadowId(); ClearFiles(); }
public void Add(IFileSystemProvider fss) { Providers.Add(fss); foreach (var fs in fss.GetFileSystems()) { FileSystems.Add(fs); } }
public void TearDown() { // stay clean (see note in Setup) FileSystems.Reset(); Current.Reset(); _register.DisposeIfDisposable(); }
public void ShadowScopeCompleteWithFileConflict() { var logger = Mock.Of <ILogger>(); var path = IOHelper.MapPath("FileSysTests"); var shadowfs = IOHelper.MapPath("App_Data/TEMP/ShadowFs"); Directory.CreateDirectory(path); var scopedFileSystems = false; var phy = new PhysicalFileSystem(path, "ignore"); var container = Mock.Of <IFactory>(); var fileSystems = new FileSystems(container, logger) { IsScoped = () => scopedFileSystems }; var fs = fileSystems.GetFileSystem <FS>(phy); var sw = (ShadowWrapper)fs.InnerFileSystem; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo"))) sw.AddFile("sub/f1.txt", ms); Assert.IsTrue(phy.FileExists("sub/f1.txt")); Guid id; scopedFileSystems = true; // pretend we have a scope var scope = new ShadowFileSystems(fileSystems, id = Guid.NewGuid()); Assert.IsTrue(Directory.Exists(shadowfs + "/" + id)); using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo"))) sw.AddFile("sub/f2.txt", ms); Assert.IsFalse(phy.FileExists("sub/f2.txt")); // pretend we're another thread w/out scope scopedFileSystems = false; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("bar"))) sw.AddFile("sub/f2.txt", ms); scopedFileSystems = true; // pretend we have a scope Assert.IsTrue(phy.FileExists("sub/f2.txt")); // other thread has written out to fs scope.Complete(); scope.Dispose(); scopedFileSystems = false; Assert.IsTrue(phy.FileExists("sub/f2.txt")); TestHelper.TryAssert(() => Assert.IsFalse(Directory.Exists(shadowfs + "/" + id))); string text; using (var s = phy.OpenFile("sub/f2.txt")) using (var r = new StreamReader(s)) text = r.ReadToEnd(); // the shadow filesystem will happily overwrite anything it can Assert.AreEqual("foo", text); }
public PartialViewsTreeController( ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IMenuItemCollectionFactory menuItemCollectionFactory, FileSystems fileSystems, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator) { FileSystem = fileSystems.PartialViewsFileSystem; }
// initializes a new scope in a nested scopes chain, with its parent public Scope(ScopeProvider scopeProvider, ILogger logger, FileSystems fileSystems, Scope parent, IsolationLevel isolationLevel = IsolationLevel.Unspecified, RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified, IEventDispatcher eventDispatcher = null, bool? scopeFileSystems = null, bool callContext = false, bool autoComplete = false) : this(scopeProvider, logger, fileSystems, parent, null, false, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete) { }
public void ShadowScopeCompleteWithFileConflict() { var path = HostingEnvironment.MapPathContentRoot("FileSysTests"); var shadowfs = HostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs"); Directory.CreateDirectory(path); var scopedFileSystems = false; var phy = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path, "ignore"); var globalSettings = Options.Create(new GlobalSettings()); var fileSystems = new FileSystems(NullLoggerFactory.Instance, IOHelper, globalSettings, HostingEnvironment) { IsScoped = () => scopedFileSystems }; var shadowPath = $"x/{Guid.NewGuid().ToString("N").Substring(0, 6)}"; var sw = fileSystems.CreateShadowWrapper(phy, shadowPath); using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo"))) sw.AddFile("sub/f1.txt", ms); Assert.IsTrue(phy.FileExists("sub/f1.txt")); string id; scopedFileSystems = true; // pretend we have a scope var scope = new ShadowFileSystems(fileSystems, id = ShadowWrapper.CreateShadowId(HostingEnvironment)); Assert.IsTrue(Directory.Exists(shadowfs + "/" + id)); using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo"))) sw.AddFile("sub/f2.txt", ms); Assert.IsFalse(phy.FileExists("sub/f2.txt")); // pretend we're another thread w/out scope scopedFileSystems = false; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("bar"))) sw.AddFile("sub/f2.txt", ms); scopedFileSystems = true; // pretend we have a scope Assert.IsTrue(phy.FileExists("sub/f2.txt")); // other thread has written out to fs scope.Complete(); scope.Dispose(); scopedFileSystems = false; Assert.IsTrue(phy.FileExists("sub/f2.txt")); TestHelper.TryAssert(() => Assert.IsFalse(Directory.Exists(shadowfs + "/" + id))); string text; using (var s = phy.OpenFile("sub/f2.txt")) using (var r = new StreamReader(s)) text = r.ReadToEnd(); // the shadow filesystem will happily overwrite anything it can Assert.AreEqual("foo", text); }
public async Task Export(ImportArguments arguments) { var session = configuration.StartSession(arguments.App); var assets = session.Assets; using (var fs = await FileSystems.CreateAsync(arguments.Path, session.WorkingDirectory)) { var folderTree = new FolderTree(session); var folderNames = new HashSet <string>(); var parentId = await folderTree.GetIdAsync(arguments.TargetFolder); var downloadPipeline = new DownloadPipeline(session, log, fs) { FilePathProviderAsync = async asset => { var assetFolder = await folderTree.GetPathAsync(asset.ParentId); var assetPath = asset.FileName; if (!string.IsNullOrWhiteSpace(assetFolder)) { assetPath = Path.Combine(assetFolder, assetPath); } if (!folderNames.Add(assetPath)) { assetPath = Path.Combine(assetFolder !, $"{asset.Id}_{asset.FileName}"); } return(FilePath.Create(assetPath)); } }; try { await assets.GetAllByQueryAsync(session.App, async asset => { await downloadPipeline.DownloadAsync(asset); }, new AssetQuery { ParentId = parentId }); } finally { await downloadPipeline.CompleteAsync(); } log.WriteLine("> Export completed"); } }
public ScopeProvider(IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, ILogger logger) { DatabaseFactory = databaseFactory; _fileSystems = fileSystems; _logger = logger; // take control of the FileSystems _fileSystems.IsScoped = () => AmbientScope != null && AmbientScope.ScopedFileSystems; _scopeReference = new ScopeReference(this); }
public TemplateSerializer(IEntityService entityService, ILogger <TemplateSerializer> logger, IShortStringHelper shortStringHelper, IFileService fileService, FileSystems fileSystems) : base(entityService, logger) { this.fileService = fileService; this.shortStringHelper = shortStringHelper; _viewFileSystem = fileSystems.MvcViewsFileSystem; }
/// <summary> /// Creates a ScopeProvider with mocked internals. /// </summary> /// <param name="syntaxProviderMock">The mock of the ISqlSyntaxProvider2, used to count method calls.</param> /// <returns></returns> private ScopeProvider GetScopeProvider(out Mock <IDistributedLockingMechanism> lockingMechanism) { var loggerFactory = NullLoggerFactory.Instance; var fileSystems = new FileSystems( loggerFactory, Mock.Of <IIOHelper>(), Mock.Of <IOptions <GlobalSettings> >(), Mock.Of <IHostingEnvironment>()); var mediaFileManager = new MediaFileManager( Mock.Of <IFileSystem>(), Mock.Of <IMediaPathScheme>(), loggerFactory.CreateLogger <MediaFileManager>(), Mock.Of <IShortStringHelper>(), Mock.Of <IServiceProvider>(), Options.Create(new ContentSettings())); var databaseFactory = new Mock <IUmbracoDatabaseFactory>(); var database = new Mock <IUmbracoDatabase>(); var sqlContext = new Mock <ISqlContext>(); lockingMechanism = new Mock <IDistributedLockingMechanism>(); lockingMechanism.Setup(x => x.ReadLock(It.IsAny <int>(), It.IsAny <TimeSpan?>())) .Returns(Mock.Of <IDistributedLock>()); lockingMechanism.Setup(x => x.WriteLock(It.IsAny <int>(), It.IsAny <TimeSpan?>())) .Returns(Mock.Of <IDistributedLock>()); var lockingMechanismFactory = new Mock <IDistributedLockingMechanismFactory>(); lockingMechanismFactory.Setup(x => x.DistributedLockingMechanism) .Returns(lockingMechanism.Object); // Setup mock of database factory to return mock of database. databaseFactory.Setup(x => x.CreateDatabase()).Returns(database.Object); databaseFactory.Setup(x => x.SqlContext).Returns(sqlContext.Object); // Setup mock of database to return mock of sql SqlContext database.Setup(x => x.SqlContext).Returns(sqlContext.Object); var syntaxProviderMock = new Mock <ISqlSyntaxProvider>(); // Setup mock of ISqlContext to return syntaxProviderMock sqlContext.Setup(x => x.SqlSyntax).Returns(syntaxProviderMock.Object); return(new ScopeProvider( new AmbientScopeStack(), new AmbientScopeContextStack(), lockingMechanismFactory.Object, databaseFactory.Object, fileSystems, new TestOptionsMonitor <CoreDebugSettings>(new CoreDebugSettings()), mediaFileManager, loggerFactory, Mock.Of <IEventAggregator>())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToAttachToPidAndRunThreadDump() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToAttachToPidAndRunThreadDump() { long pid = PID; assertThat(pid, @is(not(0))); // Write config file Files.createFile(TestDirectory.file("neo4j.conf").toPath()); // write neo4j.pid file File run = TestDirectory.directory("run"); Files.write(Paths.get(run.AbsolutePath, "neo4j.pid"), pid.ToString().GetBytes()); // Run command, should detect running instance try { using (RealOutsideWorld outsideWorld = new RealOutsideWorld()) { string[] args = new string[] { "threads", "--to=" + TestDirectory.absolutePath().AbsolutePath + "/reports" }; Path homeDir = TestDirectory.directory().toPath(); DiagnosticsReportCommand diagnosticsReportCommand = new DiagnosticsReportCommand(homeDir, homeDir, outsideWorld); diagnosticsReportCommand.Execute(args); } } catch (IncorrectUsage e) { if (e.Message.Equals("Unknown classifier: threads")) { return; // If we get attach API is not available for example in some IBM jdk installs, ignore this test } throw e; } // Verify that we took a thread dump File reports = TestDirectory.directory("reports"); File[] files = reports.listFiles(); assertThat(files, notNullValue()); assertThat(Files.Length, @is(1)); Path report = files[0].toPath(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.net.URI uri = java.net.URI.create("jar:file:" + report.toUri().getRawPath()); URI uri = URI.create("jar:file:" + report.toUri().RawPath); using (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { string threadDump = new string( Files.readAllBytes(fs.getPath("threaddump.txt"))); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: assertThat(threadDump, containsString(typeof(DiagnosticsReportCommandIT).FullName)); } }
/// <summary> /// RAMDirectoryのインデックスをFSIndexとして保存する /// </summary> /// <param name="ramDir"></param> /// <param name="savePath"></param> /// <param name="analyzer"></param> private static void SaveFSIndexFromRAMIndex(FlexLucene.Store.Directory ramDir, string savePath, Analyzer analyzer) { var fsIndexDir = FSDirectory.Open(FileSystems.getDefault().getPath(savePath)); var fsConfig = new IndexWriterConfig(analyzer); IndexWriter fsIndexWriter = new IndexWriter(fsIndexDir, fsConfig); try { fsIndexWriter.AddIndexes(new FlexLucene.Store.Directory[] { ramDir }); fsIndexWriter.Commit(); } finally { fsIndexWriter.Close(); } }
public ScopeProvider(IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, IOptions <CoreDebugSettings> coreDebugSettings, MediaFileManager mediaFileManager, ILogger <ScopeProvider> logger, ILoggerFactory loggerFactory, IRequestCache requestCache, IEventAggregator eventAggregator) { DatabaseFactory = databaseFactory; _fileSystems = fileSystems; _coreDebugSettings = coreDebugSettings.Value; _mediaFileManager = mediaFileManager; _logger = logger; _loggerFactory = loggerFactory; _requestCache = requestCache; _eventAggregator = eventAggregator; // take control of the FileSystems _fileSystems.IsScoped = () => AmbientScope != null && AmbientScope.ScopedFileSystems; }
/// <summary> /// Constructor /// </summary> /// <param name="fileSystems">The file systems.</param> public FileSystem(IEnumerable <IFileSystem> fileSystems) { fileSystems ??= Array.Empty <IFileSystem>(); FileSystems = fileSystems.Where(x => x.GetType().Assembly != typeof(FileSystem).Assembly) .ToDictionary(x => x.Name); foreach (var FileSystem in fileSystems.Where(x => x.GetType().Assembly == typeof(FileSystem).Assembly)) { if (!FileSystems.ContainsKey(FileSystem.Name)) { FileSystems.Add(FileSystem.Name, FileSystem); } } }
public void SetUpFileSystem() { string path = HostingEnvironment.MapPathWebRoot(GlobalSettings.UmbracoCssPath); _fileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, GetRequiredService <ILogger <PhysicalFileSystem> >(), path, "/css"); _fileSystems = FileSystemsCreator.CreateTestFileSystems(LoggerFactory, IOHelper, GetRequiredService <IOptions <GlobalSettings> >(), HostingEnvironment, null, null, _fileSystem, null, null); Stream stream = CreateStream("body {background:#EE7600; color:#FFF;}"); _fileSystem.AddFile("styles.css", stream); }