Пример #1
0
        public void Download_Subversion_IncludeFiles_ExcludeFolder()
        {
            //Create the excludefilter
            var filefilter   = new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.IncludedFilesFilter, "*.cs");
            var folderfilter = new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.ExcludedFilesFilter, _subFolderLogging + "\\");
            var settings     = new DependencyService.Settings <DownloaderValidSettings>();

            settings.AddSetting(filefilter);
            settings.AddSetting(folderfilter);
            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            var sourceDir = string.Format("{0}/{1}", _svnSrcPath, _componentA);

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(sourceDir, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class3.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class4.cs")));
            //The targets file should not be there
            Assert.IsFalse(File.Exists(Path.Combine(_downloadDir, "component.targets")));
            //The subfolder Logging should no be there, too
            Assert.IsFalse(File.Exists(Path.Combine(_downloadDir, _subFolderLogging, "LoggingClass.cs")));
        }
Пример #2
0
        //Einzelne Dateien herunterladen sinnvoll?
        public void Download_Subversion_DownloadNotExistingFile()
        {
            string notExistingFile = string.Format("{0}/{1}/{2}", _svnSrcPath, _componentA, "notExistingFile");

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(notExistingFile, _downloadDir, new DummyWatermark(), false, new Settings <DownloaderValidSettings>());
        }
        public void Download_FileShare_ExcludeFilterChildLevel_Test()
        {
            // Prepare environment
            string tempPath    = Path.GetTempPath();
            string guid        = System.Guid.NewGuid().ToString();
            string compRootDir = tempPath + guid;

            Directory.CreateDirectory(compRootDir);
            string sourceDir = compRootDir + Path.DirectorySeparatorChar + "SourceDir";
            string destDir   = compRootDir + Path.DirectorySeparatorChar + "DestDir";

            Directory.CreateDirectory(sourceDir);
            Directory.CreateDirectory(destDir);
            string subDir1   = "subDir1";
            string subDir2   = "subDir2";
            string testFile1 = "TestFile1.txt";
            string testFile2 = "TestFile2.txt";
            string testFile3 = "TestFile3.txt";
            string testFile4 = "TestXml1.xml";
            string testFile5 = "TestXml2.xml";
            string testFile6 = "TestXml3.xml";
            string testFile7 = "TestCs1.cs";
            string testFile8 = "TestCs2.cs";
            string testFile9 = "TestCs3.cs";

            Directory.CreateDirectory(Path.Combine(sourceDir, subDir1));
            Directory.CreateDirectory(Path.Combine(sourceDir, subDir2));
            File.Create(Path.Combine(sourceDir, subDir1, testFile1)).Close();
            File.Create(Path.Combine(sourceDir, subDir1, testFile2)).Close();
            File.Create(Path.Combine(sourceDir, subDir1, testFile3)).Close();
            File.Create(Path.Combine(sourceDir, testFile4)).Close();
            File.Create(Path.Combine(sourceDir, testFile5)).Close();
            File.Create(Path.Combine(sourceDir, testFile6)).Close();
            File.Create(Path.Combine(sourceDir, subDir2, testFile7)).Close();
            File.Create(Path.Combine(sourceDir, subDir2, testFile8)).Close();
            File.Create(Path.Combine(sourceDir, subDir2, testFile9)).Close();

            IDependencyDownloaderFactory        df         = new DownloaderFactory();
            IDependencyDownloader               downloader = df.GetDownloader("Downloader_FileShare");
            ISettings <DownloaderValidSettings> settings   = new Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.ExcludedFilesFilter, "subdir1\\"));
            downloader.Download(sourceDir, destDir, new DummyWatermark(), false, settings);

            Assert.IsFalse(File.Exists(Path.Combine(destDir, subDir1, testFile1)));
            Assert.IsFalse(File.Exists(Path.Combine(destDir, subDir1, testFile2)));
            Assert.IsFalse(File.Exists(Path.Combine(destDir, subDir1, testFile3)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, testFile4)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, testFile5)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, testFile6)));
            Assert.IsFalse(Directory.Exists(Path.Combine(destDir, subDir1)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, subDir2, testFile7)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, subDir2, testFile8)));
            Assert.IsTrue(File.Exists(Path.Combine(destDir, subDir2, testFile9)));
        }
Пример #4
0
        public void Download_Subversion_DownloadNotExistingFolder()
        {
            string notExistingFolder = string.Format("{0}/{1}", _svnSrcPath, "notExistingFolder");

            var settings = new Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(notExistingFolder, _downloadDir, new DummyWatermark(), false, settings);
        }
        public void Download_NonExistingSourceDir_Test()
        {
            // Prepare environment
            string tempPath    = Path.GetTempPath();
            string guid        = System.Guid.NewGuid().ToString();
            string compRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(compRootDir);

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_FileShare");

            downloader.Download(compRootDir + Path.DirectorySeparatorChar + "testComp", tempPath, new DummyWatermark(), false, new Settings <DownloaderValidSettings>());
        }
        public void Download_FileShare_FileTypeFilter_Test()
        {
            // Prepare environment
            string tempPath    = Path.GetTempPath();
            string guid        = System.Guid.NewGuid().ToString();
            string compRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(compRootDir);
            string sourceDir = compRootDir + Path.DirectorySeparatorChar + "SourceDir";
            string destDir   = compRootDir + Path.DirectorySeparatorChar + "DestDir";

            Directory.CreateDirectory(sourceDir);
            Directory.CreateDirectory(destDir);
            string testDir   = "testDir";
            string testFile1 = "TestFile1.txt";
            string testFile2 = "testFile2.dll";
            string testFile3 = "testXml1.xml";
            string testFile4 = "Abcd.txt";

            Directory.CreateDirectory(sourceDir + Path.DirectorySeparatorChar + testDir);
            StreamWriter tf1 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile1);

            tf1.WriteLine(testFile1);
            tf1.Close();
            StreamWriter tf2 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testFile2);

            tf2.WriteLine(testFile2);
            tf2.Close();
            StreamWriter tf3 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile3);

            tf3.WriteLine(testFile3);
            tf3.Close();
            StreamWriter tf4 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testFile4);

            tf4.WriteLine(testFile4);
            tf4.Close();

            IDependencyDownloaderFactory        df         = new DownloaderFactory();
            IDependencyDownloader               downloader = df.GetDownloader("Downloader_FileShare");
            ISettings <DownloaderValidSettings> settings   = new Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.IncludedFilesFilter, "Test*.txt;*.dll"));
            downloader.Download(sourceDir, destDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(Directory.Exists(destDir + Path.DirectorySeparatorChar + testDir));
            Assert.IsTrue(File.Exists(destDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile1));
            Assert.IsTrue(File.Exists(destDir + Path.DirectorySeparatorChar + testFile2));
            Assert.IsFalse(File.Exists(destDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile3));
            Assert.IsFalse(File.Exists(destDir + Path.DirectorySeparatorChar + testFile4));
        }
Пример #7
0
        public void Download_Subversion_DownloadExistingFolder_DestinationFolderNotExists()
        {
            Directory.CreateDirectory(_downloadDir);

            var sourceDir = string.Format("{0}/{1}", _svnSrcPath, _componentA);

            var settings = new Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(sourceDir, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Class3.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "Logging", "LoggingClass.cs")));
        }
Пример #8
0
        public void Download_Subversion_FolderWithExternals()
        {
            var sourceDir = string.Format("{0}/{1}", _svnSrcPath, _componentWithExternals);

            var settings = new DependencyService.Settings <DownloaderValidSettings>();

            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(sourceDir, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, "UsingCommon.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, "Common1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, "Common2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, "Common3.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, _subFolderSubCommon, "SubCommon1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, _subFolderSubCommon, "SubCommon2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, _subFolderCommon, _subFolderSubCommon, "SubCommon3.cs")));
        }
Пример #9
0
        public void Download_Subversion_FolderMappingsMoveToSubfolder()
        {
            var targetFolder = @"libs\ComponentA_V10";

            var settings = new DependencyService.Settings <DownloaderValidSettings>();
            //Create the folder mapping
            var mappings = new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.FolderMappings, string.Format("SourceOffset={0}/{1},LocalOffset=.//", _componentA, _subFolderLogging));

            settings.AddSetting(mappings);
            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            var sourceDir = string.Format("{0}/{1}", _svnSrcPath, _componentA);

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(sourceDir, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "ComponentA.1_0.dll")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "component.targets")));
        }
Пример #10
0
        public void Download_Subversion_FolderMappingsRenameFolderSameLevel()
        {
            var targetFolder = "ComponentA_renamed";

            var settings = new DependencyService.Settings <DownloaderValidSettings>();
            //Create the folder mapping
            var mappings = new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.FolderMappings, string.Format("SourceOffset={0},LocalOffset={1};", _componentA, targetFolder));

            settings.AddSetting(mappings);
            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.VersionString, "H"));

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_Subversion");

            downloader.Download(_svnSrcPath, _downloadDir, new DummyWatermark(), false, settings);

            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "Class1.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "Class2.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "Class3.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "Class4.cs")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, "component.targets")));
            Assert.IsTrue(File.Exists(Path.Combine(_downloadDir, targetFolder, _subFolderLogging, "LoggingClass.cs")));
        }
        public void Download_FileShare_ExistingComponent_Test()
        {
            // Prepare environment
            string tempPath    = Path.GetTempPath();
            string guid        = System.Guid.NewGuid().ToString();
            string compRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(compRootDir);
            string sourceDir = compRootDir + Path.DirectorySeparatorChar + "SourceDir";
            string destDir   = compRootDir + Path.DirectorySeparatorChar + "DestDir";

            Directory.CreateDirectory(sourceDir);
            Directory.CreateDirectory(destDir);
            string testDir   = "testDir";
            string testFile1 = "testFile1.txt";
            string testFile2 = "testFile2.txt";

            Directory.CreateDirectory(sourceDir + Path.DirectorySeparatorChar + testDir);
            StreamWriter tf1 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile1);

            tf1.WriteLine(testFile1);
            tf1.Close();
            StreamWriter tf2 = File.CreateText(sourceDir + Path.DirectorySeparatorChar + testFile2);

            tf2.WriteLine(testFile2);
            tf2.Close();

            IDependencyDownloaderFactory df         = new DownloaderFactory();
            IDependencyDownloader        downloader = df.GetDownloader("Downloader_FileShare");

            downloader.Download(sourceDir, destDir, new DummyWatermark(), false, new Settings <DownloaderValidSettings>());

            Assert.IsTrue(Directory.Exists(destDir + Path.DirectorySeparatorChar + testDir));
            Assert.IsTrue(File.Exists(destDir + Path.DirectorySeparatorChar + testDir + Path.DirectorySeparatorChar + testFile1));
            Assert.IsTrue(File.Exists(destDir + Path.DirectorySeparatorChar + testFile2));
        }
        public void Download(string source, string destination, IDependencyDownloaderWatermark watermark, bool force, ISettings <DownloaderValidSettings> settings)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }

            if (watermark == null)
            {
                throw new ArgumentNullException("watermark");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            Logger.Instance().Log(TraceLevel.Info, "{0}: Downloading component {1} to {2} ...", DownloadType, source, destination);

            // Save compressed files to temp path and temporarily store watermarks. Turn of mappings as they only apply to the extracted folder structure
            var tempPath = Path.Combine(destination, "..\\", "DM_TEMP");

            //Create the temp Path
            if (!Directory.Exists(tempPath))
            {
                DirectoryInfo di = Directory.CreateDirectory(tempPath);
            }

            //save the folder mapping
            var tempFolderMapping  = settings.GetSetting(DownloaderValidSettings.FolderMappings);
            var remainingArtefacts = new HashSet <string>(watermark.ArtifactsToClean);


            //Download the zip files and the rest of the contents ignore any mappings to get everything in the temppath
            settings.SettingsDictionary[DownloaderValidSettings.FolderMappings] = null;
            _downloader
            .Download(source, tempPath, watermark, force, settings);
            //var zipWatermarks = new Dictionary<string, object>(watermark.Watermarks);

            // The DownloaderFileShareCopy / DownloaderSourceControlCopy creates artifacts for cleanup,
            // which are deleted by the ZippedDependencyDownloader and must not be saved.
            watermark.ArtifactsToClean = remainingArtefacts;

            //Extract the zipped files in the temp path
            ExtractCompressedFiles(tempPath, tempPath, watermark, force);

            //Set the settings to a move operation
            settings.AddSetting(new KeyValuePair <DownloaderValidSettings, string>(DownloaderValidSettings.OperationType, "Move"));

            //Set the temporary saved mapping again
            settings.SettingsDictionary[DownloaderValidSettings.FolderMappings] = tempFolderMapping;

            //The SourceControlCopy-Provider needs the FileShareCopy-Provider to copy the extracted files from the temp folder to the
            //target folder, because the SourceControlCopy-Provider works not with local folders as source folder
            if (_downloader.DownloadType == "Downloader_SourceControlCopy")
            {
                IDependencyDownloader tmpDownloader = new DownloaderFileShareCopy();
                tmpDownloader.Download(tempPath, destination, watermark, force, settings);
            }
            // Provider: FileShare, BuildResult
            else
            {
                //Copy the files from the temp path to the final destination
                _downloader.Download(tempPath, destination, watermark, force, settings);
            }

            //Cleanup: Delete the temp path
            try
            {
                DeleteTempDirectory(tempPath);
            }
            catch (Exception e)
            {
                Logger.Instance().Log(TraceLevel.Error, "Deleting temp folder {0} did not succeed: {1}", tempPath, e.Message);
                Logger.Instance().Log(TraceLevel.Error, "Stacktrace: {0}", e.StackTrace);
            }
        }