示例#1
0
        /// <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);
                }
            }
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.io.File[] schemaIndexFiles() throws java.io.IOException
        private File[] SchemaIndexFiles()
        {
            FileSystemAbstraction fs = _testDirectory.FileSystem;
            File indexDir            = new File(_testDirectory.storeDir(), "schema/index/");

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            return(fs.StreamFilesRecursive(indexDir).map(FileHandle::getFile).toArray(File[] ::new));
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void commonMocking() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CommonMocking()
        {
            IDictionary <MemberId, CoreServerInfo> members = new Dictionary <MemberId, CoreServerInfo>();

            members[_memberId] = mock(typeof(CoreServerInfo));

            FileSystemAbstraction fileSystemAbstraction = mock(typeof(FileSystemAbstraction));

            when(fileSystemAbstraction.StreamFilesRecursive(any(typeof(File)))).thenAnswer(f => Stream.empty());
            when(_localDatabase.databaseLayout()).thenReturn(_databaseLayout);
            when(_localDatabase.storeId()).thenReturn(_localStoreId);
            when(_topologyService.allCoreServers()).thenReturn(_clusterTopology);
            when(_clusterTopology.members()).thenReturn(members);
            when(_topologyService.findCatchupAddress(_memberId)).thenReturn(_fromAddress);
        }
示例#4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private SwitchToSlaveBranchThenCopy newSwitchToSlaveSpy() throws Exception
        private SwitchToSlaveBranchThenCopy NewSwitchToSlaveSpy()
        {
            PageCache pageCacheMock = mock(typeof(PageCache));
            PagedFile pagedFileMock = mock(typeof(PagedFile));

            when(pagedFileMock.LastPageId).thenReturn(1L);
            when(pageCacheMock.Map(any(typeof(File)), anyInt())).thenReturn(pagedFileMock);
            FileSystemAbstraction fileSystemAbstraction = mock(typeof(FileSystemAbstraction));

            when(fileSystemAbstraction.StreamFilesRecursive(any(typeof(File)))).thenAnswer(f => Stream.empty());

            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));

            return(NewSwitchToSlaveSpy(pageCacheMock, storeCopyClient));
        }
示例#5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private SwitchToSlaveCopyThenBranch newSwitchToSlaveSpy() throws Exception
        private SwitchToSlaveCopyThenBranch NewSwitchToSlaveSpy()
        {
            PageCache pageCacheMock = mock(typeof(PageCache));
            PagedFile pagedFileMock = mock(typeof(PagedFile));

            when(pagedFileMock.LastPageId).thenReturn(1L);
            when(pageCacheMock.Map(any(typeof(File)), anyInt())).thenReturn(pagedFileMock);

            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));
            Stream          mockStream      = mock(typeof(Stream));

            when(mockStream.filter(any(typeof(System.Predicate)))).thenReturn(mockStream);
            FileSystemAbstraction fileSystemAbstraction = mock(typeof(FileSystemAbstraction));

            when(fileSystemAbstraction.StreamFilesRecursive(any(typeof(File)))).thenReturn(mockStream);
            return(NewSwitchToSlaveSpy(pageCacheMock, storeCopyClient));
        }