public void CopyFileWithPathsExpectedRecursiveCopy()
        {
            var          innerDir     = Guid.NewGuid().ToString();
            var          tempPath     = Path.GetTempPath();
            var          tempFileName = Path.GetFileName(Path.GetTempFileName());
            const string TempData     = "some string data";

            if (tempFileName != null)
            {
                var    tempFile      = Path.Combine(tempPath, innerDir, innerDir, tempFileName);
                string directoryName = Path.GetDirectoryName(tempFile);
                if (directoryName != null)
                {
                    Directory.CreateDirectory(directoryName);
                }
                var upperLevelDir = Path.Combine(tempPath, innerDir);
                File.WriteAllText(tempFile, TempData);
                var dst         = Path.Combine(tempPath, Guid.NewGuid().ToString());
                var scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(upperLevelDir, string.Empty, null, true));
                var dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(dst, string.Empty, null, true));

                var moveTO = new Dev2CRUDOperationTO(true);
                ActivityIOFactory.CreateOperationsBroker().Copy(scrEndPoint, dstEndPoint, moveTO);
                var newFilePath = Path.Combine(dst, innerDir, tempFileName);
                Assert.IsTrue(File.Exists(newFilePath));
                Assert.IsTrue(File.Exists(tempFile));
            }
        }
Example #2
0
        public void ActivityIOBroker_Zip_WhenOverwriteSetTrue_ShouldOverwriteFile()
        {
            //------------Setup for test--------------------------
            tempFile = Path.GetTempFileName();
            var zipPathName = Path.GetTempPath() + NewFileName + ".zip";
            IActivityIOOperationsEndPoint scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(tempFile, string.Empty, null, true, ""));
            IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(zipPathName, string.Empty, null, true, ""));
            Dev2ZipOperationTO            zipTO       = ActivityIOFactory.CreateZipTO(null, null, null, true);

            File.WriteAllText(zipPathName, "");
            //------------Assert Preconditions-------------------
            Assert.IsTrue(zipTO.Overwrite);
            Assert.IsTrue(File.Exists(zipPathName));
            var readAllBytes = File.ReadAllBytes(zipPathName);

            Assert.AreEqual(0, readAllBytes.Length);
            //------------Execute Test---------------------------
            ActivityIOFactory.CreateOperationsBroker().Zip(scrEndPoint, dstEndPoint, zipTO);
            //------------Assert Results-------------------------
            Assert.IsTrue(File.Exists(zipPathName));
            readAllBytes = File.ReadAllBytes(zipPathName);
            Assert.AreNotEqual(0, readAllBytes.Length);
            File.Delete(tempFile);
            File.Delete(zipPathName);
        }
 void CreateSourceFileWithSomeDummyData()
 {
     try
     {
         Dev2Logger.Log.Debug(string.Format("Source File: {0}", ScenarioContext.Current.Get <string>(ActualSourceHolder)));
         var             broker = ActivityIOFactory.CreateOperationsBroker();
         IActivityIOPath source = ActivityIOFactory.CreatePathFromString(ScenarioContext.Current.Get <string>(ActualSourceHolder),
                                                                         ScenarioContext.Current.Get <string>(SourceUsernameHolder),
                                                                         ScenarioContext.Current.Get <string>(SourcePasswordHolder),
                                                                         true);
         var ops = ActivityIOFactory.CreatePutRawOperationTO(WriteType.Overwrite, Guid.NewGuid().ToString());
         IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
         if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
         {
             var result = broker.PutRaw(sourceEndPoint, ops);
             if (result != "Success")
             {
                 result = broker.PutRaw(sourceEndPoint, ops);
                 if (result != "Success")
                 {
                     Dev2Logger.Log.Debug("Create Source File for file op test error");
                 }
             }
         }
     }
     catch (Exception e)
     {
         Dev2Logger.Log.Debug("Create Source File for file op test error", e);
     }
 }
Example #4
0
        public void PutWithOverwriteTrue_UNCPathValidUser_File_Present_FileInStream()
        {
            Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(true);
            string tmp  = TestResource.PathOperations_UNC_Path_Secure + Guid.NewGuid() + ".test";
            string tmp2 = TestResource.PathOperations_UNC_Path_Secure + Guid.NewGuid() + ".test";

            PathIOTestingUtils.CreateAuthedUNCPath(tmp, false, _inDomain);
            IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(tmp, (_inDomain ? "DEV2\\" : ".\\") + TestResource.PathOperations_Correct_Username, TestResource.PathOperations_Correct_Password);
            IActivityIOPath src = ActivityIOFactory.CreatePathFromString(tmp2, (_inDomain ? "DEV2\\" : ".\\") + TestResource.PathOperations_Correct_Username, TestResource.PathOperations_Correct_Password);
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
            Stream stream        = new MemoryStream(File.ReadAllBytes(_tmpfile1));
            var    directoryInfo = new FileInfo(src.Path).Directory;

            if (directoryInfo != null)
            {
                int len = FileSystemPro.Put(stream, dst, opTO, directoryInfo.ToString(), new List <string>());
                stream.Close();

                PathIOTestingUtils.DeleteAuthedUNCPath(tmp);
                PathIOTestingUtils.DeleteAuthedUNCPath(tmp2);

                Assert.IsTrue(len > 0);
            }
            else
            {
                Assert.Fail();
            }
        }
Example #5
0
        public void PutWithOverwriteTrue_FileNot_Present_Expect_FileReadAndDataInputToStream()
        {
            Dev2CRUDOperationTO opTO = new Dev2CRUDOperationTO(true);
            string tmp = Path.GetTempFileName();

            File.Delete(tmp);
            IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(tmp, "", "");
            IActivityIOPath src = ActivityIOFactory.CreatePathFromString(_tmpfile2, "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
            Stream stream        = FileSystemPro.Get(src, new List <string>());
            var    directoryInfo = new FileInfo(src.Path).Directory;

            if (directoryInfo != null)
            {
                int len = FileSystemPro.Put(stream, dst, opTO, directoryInfo.ToString(), new List <string>());
                stream.Close();

                File.Delete(tmp);

                Assert.IsTrue(len > 0);
            }
            else
            {
                Assert.Fail();
            }
        }
        public void CreateOperationEndPointFromIOPath_Expected_IActivityIOOperationsEndPoint_FTPProvider_Type()
        {
            var path   = ActivityIOFactory.CreatePathFromString(ParserStrings.PathOperations_FTP_Path, "", "");
            var result = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);

            Assert.IsTrue(result.GetType() == typeof(Dev2FTPProvider));
        }
Example #7
0
        static void RunCopy()
        {
            IActivityIOPath source = ActivityIOFactory.CreatePathFromString(ScenarioContext.Current.Get <string>(CommonSteps.ActualSourceHolder),
                                                                            ScenarioContext.Current.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                            ScenarioContext.Current.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                            true);
            IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);


            string resourceName = "Dev2.Activities.Specs.Toolbox.FileAndFolder.Unzip.Test.zip";

            if (ScenarioContext.Current.ContainsKey("WhenTheUnzipFileToolIsExecutedWithASingleFile"))
            {
                resourceName = "TestFile.zip";
            }
            Assembly      assembly       = Assembly.GetExecutingAssembly();
            List <string> filesToCleanup = new List <string>();

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                if (stream != null)
                {
                    sourceEndPoint.Put(stream, sourceEndPoint.IOPath, new Dev2CRUDOperationTO(true), null, filesToCleanup);
                }
            }
            filesToCleanup.ForEach(File.Delete);
        }
        private void BootstrapPersistence(string baseDir)
        {
            lock (InitLock)
            {
                if (_debugPath == null)
                {
                    if (baseDir != null)
                    {
                        _rootPath = baseDir;
                    }

                    if (_rootPath.EndsWith("\\"))
                    {
                        _debugPersistPath = _rootPath + SavePath;
                    }
                    else
                    {
                        _debugPersistPath = _rootPath + "\\" + SavePath;
                    }

                    _debugPath         = ActivityIOFactory.CreatePathFromString(_debugPersistPath, "", "");
                    _debugOptsEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(_debugPath);
                }
            }
        }
Example #9
0
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update)
        {
            IList <OutputTO> outputs = new List <OutputTO>();

            allErrors = new ErrorResultTO();
            var colItr = new WarewolfListIterator();

            //get all the possible paths for all the string variables
            var inputItr = new WarewolfIterator(dataObject.Environment.Eval(InputPath, update));

            colItr.AddVariableToIterateOn(inputItr);

            var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username, update));

            colItr.AddVariableToIterateOn(unameItr);

            var passItr = new WarewolfIterator(dataObject.Environment.Eval(DecryptedPassword, update));

            colItr.AddVariableToIterateOn(passItr);

            var privateKeyItr = new WarewolfIterator(dataObject.Environment.Eval(PrivateKeyFile, update));

            colItr.AddVariableToIterateOn(privateKeyItr);

            outputs.Add(DataListFactory.CreateOutputTO(Result));

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", dataObject.Environment, update);
                AddDebugInputItemUserNamePassword(dataObject.Environment, update);
                if (!string.IsNullOrEmpty(PrivateKeyFile))
                {
                    AddDebugInputItem(PrivateKeyFile, "Private Key File", dataObject.Environment, update);
                }
            }

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();
                IActivityIOPath           ioPath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                                          colItr.FetchNextValue(unameItr),
                                                                                          colItr.FetchNextValue(passItr),
                                                                                          true, colItr.FetchNextValue(privateKeyItr));
                IActivityIOOperationsEndPoint endpoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ioPath);
                try
                {
                    string result = broker.Get(endpoint);
                    outputs[0].OutputStrings.Add(result);
                }
                catch (Exception e)
                {
                    outputs[0].OutputStrings.Add(null);
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
        protected static void RemovedFilesCreatedForTesting()
        {
            // ReSharper disable EmptyGeneralCatchClause


            Dev2Logger.Log.Debug("Cleanup");

            var    broker = ActivityIOFactory.CreateOperationsBroker();
            string destLocation;

            if (ScenarioContext.Current != null && ScenarioContext.Current.TryGetValue(CommonSteps.ActualDestinationHolder, out destLocation))
            {
                IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(destLocation,
                                                                             ScenarioContext.Current.Get <string>(CommonSteps.DestinationUsernameHolder),
                                                                             ScenarioContext.Current.Get <string>(CommonSteps.DestinationPasswordHolder),
                                                                             true);
                IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                try
                {
                    if (dstEndPoint.PathIs(dstEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(dstEndPoint);
                    }
                }
                catch (Exception)
                {
                    Dev2Logger.Log.Debug("Cleanup Error");
                    //    throw;
                }
            }

            string sourceLocation;

            if (ScenarioContext.Current != null && ScenarioContext.Current.TryGetValue(CommonSteps.ActualSourceHolder, out sourceLocation))
            {
                IActivityIOPath source = ActivityIOFactory.CreatePathFromString(sourceLocation,
                                                                                ScenarioContext.Current.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                                ScenarioContext.Current.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                                true);
                IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
                try
                {
                    if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(sourceEndPoint);
                    }
                }
                catch (Exception)
                {
                    Dev2Logger.Log.Debug("Cleanup Error");
                    //The file may already be deleted
                    // throw;
                }
            }

            // SOME SILLY CHICKEN BUNDLED TWO DIS-JOIN OPERATIONS IN THIS METHOD.
            // THIS CAUSED THE SFTP SERVER TO NEVER SHUTDOWN WHEN THE COMMONSTEPS.ACTUALSOURCEHOLDER KEY WAS NOT PRESENT!
            // ;)
        }
Example #11
0
        public void ListDirectory_StarDotStar_With_NoContents_Expected_NoFilesInList()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(_tmpdir3 + "\\*.*", "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            IList <IActivityIOPath>       result        = FileSystemPro.ListDirectory(path);

            Assert.IsTrue(result.Count == 0);
        }
Example #12
0
        public void DeleteUNCWith_DirPresent_Expected_DeleteSuccesful()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(_uncdir1, "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path) as Dev2FileSystemProvider;
            bool ok = FileSystemPro != null && FileSystemPro.Delete(path);

            Assert.IsTrue(ok);
        }
        public void ListDirectory_StarDotStar_With_Contents_Expected_ListOfDirectoriesAndFiles()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(Path.GetTempPath() + "\\*.*", "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            IList <IActivityIOPath>       result        = FileSystemPro.ListDirectory(path);

            Assert.IsTrue(result.Count > 0);
        }
// ReSharper disable InconsistentNaming
        public void CreateOperationEndPointFromIOPath_Expected_IActivityIOOperationsEndPoint_FileSysytemProvider_Type()
// ReSharper restore InconsistentNaming
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(ParserStrings.PathOperations_FileSystem_Path, "", "");
            IActivityIOOperationsEndPoint result = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);

            Assert.IsTrue(result.GetType() == typeof(Dev2FileSystemProvider));
        }
Example #15
0
        public void ListDirectoryWithValidUsername_ValidPath_Expected_List()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(ParserStrings.PathOperations_FTP_Auth + "DontDelete/", ParserStrings.PathOperations_Correct_Username, ParserStrings.PathOperations_Correct_Password);
            IActivityIOOperationsEndPoint FTPPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            IList <IActivityIOPath>       tmp    = FTPPro.ListDirectory(path);

            Assert.AreEqual(6, tmp.Count);
        }
Example #16
0
        public void IsFileSystemPathType()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(_tmpfile1, "", "");
            IActivityIOOperationsEndPoint fileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);

            fileSystemPro.Get(path, new List <string>());
            Assert.IsTrue(fileSystemPro is Dev2FileSystemProvider);
        }
Example #17
0
        public void ListDirectory_With_Contents_Expected_ListAllFiles()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(_tmpdir1, "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            IList <IActivityIOPath>       result        = FileSystemPro.ListDirectory(path);

            Assert.IsTrue(result.Count == 2);
        }
Example #18
0
        public void DeleteUNCWith_FilePresent_Expectd_DeleteSucessful()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(_uncfile1, "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool ok = FileSystemPro.Delete(path);

            Assert.IsTrue(ok);
        }
Example #19
0
        protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors)
        {
            IList <OutputTO> outputs = new List <OutputTO>();


            allErrors = new ErrorResultTO();

            var colItr = new WarewolfListIterator();

            //get all the possible paths for all the string variables

            var inputItr = new WarewolfIterator(dataObject.Environment.Eval(InputPath));

            colItr.AddVariableToIterateOn(inputItr);

            var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username));

            colItr.AddVariableToIterateOn(unameItr);

            var passItr = new WarewolfIterator(dataObject.Environment.Eval(Password));

            colItr.AddVariableToIterateOn(passItr);


            outputs.Add(DataListFactory.CreateOutputTO(Result));

            if (dataObject.IsDebugMode())
            {
                AddDebugInputItem(InputPath, "Input Path", dataObject.Environment);
                AddDebugInputItemUserNamePassword(dataObject.Environment);
            }

            while (colItr.HasMoreData())
            {
                IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker();

                try
                {
                    IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                                 colItr.FetchNextValue(unameItr),
                                                                                 colItr.FetchNextValue(passItr),
                                                                                 true);

                    IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                    string result = broker.Delete(dstEndPoint);
                    outputs[0].OutputStrings.Add(result);
                }
                catch (Exception e)
                {
                    outputs.Add(DataListFactory.CreateOutputTO(Result, "Failure"));
                    //outputs[0].OutputStrings.Add(null);
                    allErrors.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
Example #20
0
        public void Create_Should()
        {
            var tempPath    = Path.GetTempPath() + "SomeName.zip";
            var scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(tempPath, string.Empty, null, true, ""));
            var activityOperationsBroker = ActivityIOFactory.CreateOperationsBroker();
            var create = activityOperationsBroker.Create(scrEndPoint, new Dev2CRUDOperationTO(false, false), false);

            Assert.AreEqual("Success", create);
        }
        protected override IList <OutputTO> TryExecuteConcreteAction(IDSFDataObject context, out ErrorResultTO error, int update)
        {
            IsNotCertVerifiable = true;

            error = new ErrorResultTO();
            IList <OutputTO> outputs = new List <OutputTO>();

            using (var colItr = new WarewolfListIterator())
            {
                //get all the possible paths for all the string variables
                var inputItr = new WarewolfIterator(context.Environment.Eval(InputPath, update));
                colItr.AddVariableToIterateOn(inputItr);

                var unameItr = new WarewolfIterator(context.Environment.Eval(Username, update));
                colItr.AddVariableToIterateOn(unameItr);

                var passItr = new WarewolfIterator(context.Environment.Eval(DecryptedPassword, update));
                colItr.AddVariableToIterateOn(passItr);

                var privateKeyItr = new WarewolfIterator(context.Environment.Eval(PrivateKeyFile, update));
                colItr.AddVariableToIterateOn(privateKeyItr);

                if (context.IsDebugMode())
                {
                    AddDebugInputItem(InputPath, "Input Path", context.Environment, update);
                    AddDebugInputItem(new DebugItemStaticDataParams(GetReadType().GetDescription(), "Read"));
                    AddDebugInputItemUserNamePassword(context.Environment, update);
                    if (!string.IsNullOrEmpty(PrivateKeyFile))
                    {
                        AddDebugInputItem(PrivateKeyFile, "Private Key File", context.Environment, update);
                    }
                }

                while (colItr.HasMoreData())
                {
                    var broker = ActivityIOFactory.CreateOperationsBroker();
                    var ioPath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr),
                                                                        colItr.FetchNextValue(unameItr),
                                                                        colItr.FetchNextValue(passItr),
                                                                        true, colItr.FetchNextValue(privateKeyItr));
                    var endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ioPath);

                    try
                    {
                        ExecuteConcreteAction(outputs, broker, endPoint);
                    }
                    catch (Exception e)
                    {
                        outputs.Add(DataListFactory.CreateOutputTO(null));
                        error.AddError(e.Message);
                        break;
                    }
                }

                return(outputs);
            }
        }
Example #22
0
        protected override IList <OutputTO> TryExecuteConcreteAction(IDSFDataObject context, out ErrorResultTO error, int update)
        {
            IList <OutputTO> outputs = new List <OutputTO>();

            error = new ErrorResultTO();
            var colItr = new WarewolfListIterator();

            //get all the possible paths for all the string variables

            var outputItr = new WarewolfIterator(context.Environment.Eval(OutputPath, update));

            colItr.AddVariableToIterateOn(outputItr);

            var passItr = new WarewolfIterator(context.Environment.Eval(DecryptedPassword, update));

            colItr.AddVariableToIterateOn(passItr);

            var privateKeyItr = new WarewolfIterator(context.Environment.Eval(PrivateKeyFile, update));

            colItr.AddVariableToIterateOn(privateKeyItr);

            if (context.IsDebugMode())
            {
                AddDebugInputItem(new DebugEvalResult(OutputPath, "File or Folder", context.Environment, update));
                AddDebugInputItem(new DebugItemStaticDataParams(Overwrite.ToString(), "Overwrite"));
                AddDebugInputItemUserNamePassword(context.Environment, update);
                if (!string.IsNullOrEmpty(PrivateKeyFile))
                {
                    AddDebugInputItem(PrivateKeyFile, "Destination Private Key File", context.Environment, update);
                }
            }

            while (colItr.HasMoreData())
            {
                var broker = ActivityIOFactory.CreateOperationsBroker();
                var opTo   = new Dev2CRUDOperationTO(Overwrite);

                try
                {
                    var dst = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(outputItr),
                                                                     Username,
                                                                     colItr.FetchNextValue(passItr),
                                                                     true, colItr.FetchNextValue(privateKeyItr));
                    var dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                    var result      = broker.Create(dstEndPoint, opTo, true);
                    outputs.Add(DataListFactory.CreateOutputTO(Result, result));
                }
                catch (Exception e)
                {
                    outputs.Add(DataListFactory.CreateOutputTO(Result, "Failure"));
                    error.AddError(e.Message);
                    break;
                }
            }

            return(outputs);
        }
Example #23
0
        public void CreateDirectoryWithOverwriteFalse_Present_Expected_DirectoryNotCreated()
        {
            Dev2CRUDOperationTO           opTO          = new Dev2CRUDOperationTO(false);
            IActivityIOPath               path          = ActivityIOFactory.CreatePathFromString(_tmpdir1, "", "");
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool ok = FileSystemPro.CreateDirectory(path, opTO);

            Assert.IsFalse(ok);
        }
Example #24
0
        public void DeleteUNCValidUserWith_NoDirPresent_DeleteUnsuccesful()
        {
            string          tmp  = TestResource.PathOperations_UNC_Path_Secure + Guid.NewGuid() + "_dir";
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(tmp, (_inDomain ? "DEV2\\" : ".\\") + TestResource.PathOperations_Correct_Username, TestResource.PathOperations_Correct_Password);
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool ok = FileSystemPro.Delete(path);

            Assert.IsFalse(ok);
        }
        protected void RemovedFilesCreatedForTesting()
        {
            // ReSharper disable EmptyGeneralCatchClause



            var    broker = ActivityIOFactory.CreateOperationsBroker();
            string destLocation;

            if (scenarioContext != null && scenarioContext.TryGetValue(CommonSteps.ActualDestinationHolder, out destLocation))
            {
                IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(destLocation,
                                                                             scenarioContext.Get <string>(CommonSteps.DestinationUsernameHolder),
                                                                             scenarioContext.Get <string>(CommonSteps.DestinationPasswordHolder),
                                                                             true);
                IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                try
                {
                    if (dstEndPoint.PathIs(dstEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(dstEndPoint);
                    }
                }
                catch (Exception)
                {
                    //    throw;
                }
            }

            string sourceLocation;

            if (scenarioContext != null && scenarioContext.TryGetValue(CommonSteps.ActualSourceHolder, out sourceLocation))
            {
                if (string.IsNullOrEmpty(sourceLocation))
                {
                    scenarioContext.TryGetValue(CommonSteps.SourceHolder, out sourceLocation);
                }
                if (string.IsNullOrEmpty(sourceLocation))
                {
                    return;
                }
                IActivityIOPath source = ActivityIOFactory.CreatePathFromString(sourceLocation,
                                                                                scenarioContext.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                                scenarioContext.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                                true);
                IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
                try
                {
                    broker.Delete(sourceEndPoint);
                }
                catch (Exception)
                {
                    //The file may already be deleted
                }
            }
        }
Example #26
0
        public void DeleteUNCWith_NoFilePresent_DeleteUnsucessful()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(_uncfile1 + "abc", "", "");

            File.Delete(_tmpfile1);
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool ok = FileSystemPro.Delete(path);

            Assert.IsFalse(ok);
        }
Example #27
0
        public void DeleteUNCWith_NoDirPresent_Expected_DeleteUnsuccessful()
        {
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(_uncdir1, "", "");

            Directory.Delete(_uncdir1, true);
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool ok = FileSystemPro.Delete(path);

            Assert.IsFalse(ok);
        }
        // ReSharper disable InconsistentNaming
        public void ActivityIOFactory_CreateOperationEndPointFromIOPath_WithSftp_ShouldSetTypeTpSFtp()
        // ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            const string Path = "sftp://sftp.theunlimited.co.za/text.txt";
            //------------Execute Test---------------------------
            IActivityIOOperationsEndPoint scrEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ActivityIOFactory.CreatePathFromString(Path, string.Empty, null, true));

            //------------Assert Results-------------------------
            Assert.AreEqual(enActivityIOPathType.SFTP, scrEndPoint.IOPath.PathType);
        }
Example #29
0
        protected static void RemovedFilesCreatedForTesting()
        {
            // ReSharper disable EmptyGeneralCatchClause


            Dev2Logger.Log.Debug("Cleanup");

            var    broker = ActivityIOFactory.CreateOperationsBroker();
            string destLocation;

            if (ScenarioContext.Current != null && ScenarioContext.Current.TryGetValue(CommonSteps.ActualDestinationHolder, out destLocation))
            {
                IActivityIOPath dst = ActivityIOFactory.CreatePathFromString(destLocation,
                                                                             ScenarioContext.Current.Get <string>(CommonSteps.DestinationUsernameHolder),
                                                                             ScenarioContext.Current.Get <string>(CommonSteps.DestinationPasswordHolder),
                                                                             true);
                IActivityIOOperationsEndPoint dstEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(dst);
                try
                {
                    if (dstEndPoint.PathIs(dstEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(dstEndPoint);
                    }
                }
                catch (Exception)
                {
                    Dev2Logger.Log.Debug("Cleanup Error");
                    //    throw;
                }
            }

            string sourceLocation;

            if (ScenarioContext.Current != null && ScenarioContext.Current.TryGetValue(CommonSteps.ActualSourceHolder, out sourceLocation))
            {
                IActivityIOPath source = ActivityIOFactory.CreatePathFromString(sourceLocation,
                                                                                ScenarioContext.Current.Get <string>(CommonSteps.SourceUsernameHolder),
                                                                                ScenarioContext.Current.Get <string>(CommonSteps.SourcePasswordHolder),
                                                                                true);
                IActivityIOOperationsEndPoint sourceEndPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(source);
                try
                {
                    if (sourceEndPoint.PathIs(sourceEndPoint.IOPath) == enPathType.File)
                    {
                        broker.Delete(sourceEndPoint);
                    }
                }
                catch (Exception)
                {
                    Dev2Logger.Log.Debug("Cleanup Error");
                    //The file may already be deleted
                }
            }
        }
Example #30
0
        public void DeleteUNCValidUserWith_DirPresent_Expected_DeleteSuccessful()
        {
            string tmp = TestResource.PathOperations_UNC_Path_Secure + Guid.NewGuid() + "_dir";

            PathIOTestingUtils.CreateAuthedUNCPath(tmp, true, _inDomain);
            IActivityIOPath path = ActivityIOFactory.CreatePathFromString(tmp, (_inDomain ? "DEV2\\" : ".\\") + TestResource.PathOperations_Correct_Username, TestResource.PathOperations_Correct_Password);
            IActivityIOOperationsEndPoint FileSystemPro = ActivityIOFactory.CreateOperationEndPointFromIOPath(path);
            bool ok = FileSystemPro.Delete(path);

            Assert.IsTrue(ok);
        }